Updates to 03-2025
This commit is contained in:
parent
bfa3bb1df4
commit
9ae662f63e
243 changed files with 12580 additions and 12018 deletions
151
app/Http/Controllers/Admin/AboController.php
Normal file
151
app/Http/Controllers/Admin/AboController.php
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Request;
|
||||
use App\Services\Shop;
|
||||
use App\Models\UserAbo;
|
||||
use App\Services\AboOrderCart;
|
||||
use App\Repositories\AboRepository;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
|
||||
class AboController extends Controller
|
||||
{
|
||||
protected $aboRepository;
|
||||
|
||||
public function __construct(AboRepository $aboRepository)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->aboRepository = $aboRepository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (Request::get('reset') === 'filter') {
|
||||
set_user_attr('filter_user_shop_id', null);
|
||||
set_user_attr('filter_status', null);
|
||||
set_user_attr('filter_member_id', null);
|
||||
return redirect(route('admin_sales_customers'));
|
||||
}
|
||||
|
||||
//$filter_user_shops = UserAbo::join('user_shops', 'user_shop_id', '=', 'user_shops.id')->orderBy('slug')->get()->pluck('slug', 'id')->unique()->toArray();
|
||||
$filter_members = UserAbo::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();
|
||||
|
||||
$data = [
|
||||
//'filter_user_shops' => $filter_user_shops,
|
||||
'filter_members' => $filter_members,
|
||||
];
|
||||
return view('admin.abo.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
$user_abo = UserAbo::findOrFail($id);
|
||||
|
||||
//init Yard
|
||||
AboOrderCart::initYard($user_abo);
|
||||
$customer_detail = AboOrderCart::getCustomerDetail();
|
||||
AboOrderCart::makeOrderYard($user_abo);
|
||||
|
||||
$comp_products = [];
|
||||
if ($user_abo->is_for === 'me') {
|
||||
$comp_products = Shop::getCompProducts('abo-me');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_abo' => $user_abo,
|
||||
'isAdmin' => true,
|
||||
'customer_detail' => $customer_detail,
|
||||
'view' => $user_abo->is_for,
|
||||
'comp_products' => $comp_products,
|
||||
];
|
||||
return view('admin.abo.detail', $data);
|
||||
}
|
||||
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
if (isset($data['action'])) {
|
||||
if ($data['action'] === 'abo_update_settings') {
|
||||
$user_abo = UserAbo::findOrFail($data['id']);
|
||||
$this->aboRepository->setModel($user_abo);
|
||||
$this->aboRepository->update($data);
|
||||
return redirect(route('admin_abos_detail', [$id]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = UserAbo::with('user_abo_orders')->with('shopping_user')->select('user_abos.*');
|
||||
|
||||
set_user_attr('filter_member_id', Request::get('filter_member_id'));
|
||||
if (Request::get('filter_member_id') != "") {
|
||||
$query->where('user_id', '=', Request::get('filter_member_id'));
|
||||
}
|
||||
|
||||
set_user_attr('filter_status', Request::get('filter_status'));
|
||||
if (Request::get('filter_status') != "") {
|
||||
$query->where('status', '=', Request::get('filter_status'));
|
||||
}
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserAbo $user_abo) {
|
||||
return '<a href="' . route('admin_abos_detail', [$user_abo->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('start_date', function (UserAbo $user_abo) {
|
||||
return $user_abo->start_date;
|
||||
})
|
||||
->addColumn('next_date', function (UserAbo $user_abo) {
|
||||
return $user_abo->next_date;
|
||||
})
|
||||
->addColumn('abo_interval', function (UserAbo $user_abo) {
|
||||
return \App\Services\HTMLHelper::getAboStrLang($user_abo->abo_interval);
|
||||
})
|
||||
->addColumn('status', function (UserAbo $user_abo) {
|
||||
return $user_abo->getStatusFormated();
|
||||
})
|
||||
->addColumn('active', function (UserAbo $user_abo) {
|
||||
return get_active_badge($user_abo->active);
|
||||
})
|
||||
|
||||
->addColumn('is_for', function (UserAbo $user_abo) {
|
||||
return $user_abo->getIsForFormated();
|
||||
})
|
||||
->addColumn('count', function (UserAbo $user_abo) {
|
||||
return $user_abo->getCountOrders();
|
||||
})
|
||||
->addColumn('amount', function (UserAbo $user_abo) {
|
||||
return $user_abo->getFormattedAmount() . ' €';
|
||||
})
|
||||
->addColumn('payment', function (UserAbo $user_abo) {
|
||||
return $user_abo->getPaymentType();
|
||||
})
|
||||
->addColumn('member', function (UserAbo $user_abo) {
|
||||
if (isset($user_abo->shopping_user) && $user_abo->shopping_user->member_id > 0) {
|
||||
return '<a href="' . route('admin_lead_edit', [$user_abo->shopping_user->member_id]) . '">' . $user_abo->shopping_user->member->getFullName() . '</a>';
|
||||
}
|
||||
})
|
||||
->addColumn('payone_userid', function (UserAbo $user_abo) {
|
||||
return $user_abo->payone_userid;
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('next_date', 'next_date $1')
|
||||
->orderColumn('abo_interval', 'abo_interval $1')
|
||||
->orderColumn('status', 'status $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
->orderColumn('is_for', 'is_for $1')
|
||||
->orderColumn('count', 'count $1')
|
||||
->orderColumn('amount', 'amount $1')
|
||||
->orderColumn('payone_userid', 'payone_userid $1')
|
||||
->rawColumns(['id', 'status', 'active', 'is_for', 'member'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ class KasController extends Controller
|
|||
}
|
||||
|
||||
// Fehler abfangen und ausgeben
|
||||
catch (SoapFault $fault)
|
||||
catch (\SoapFault $fault)
|
||||
{
|
||||
trigger_error(" Fehlernummer: {$fault->faultcode},
|
||||
Fehlermeldung: {$fault->faultstring},
|
||||
|
|
@ -88,7 +88,7 @@ class KasController extends Controller
|
|||
}
|
||||
|
||||
// Fehler abfangen und ausgeben
|
||||
catch (SoapFault $fault)
|
||||
catch (\SoapFault $fault)
|
||||
{
|
||||
trigger_error("Fehlernummer: {$fault->faultcode},
|
||||
Fehlermeldung: {$fault->faultstring},
|
||||
|
|
|
|||
|
|
@ -8,48 +8,38 @@ use App\Http\Controllers\Controller;
|
|||
class KasSLLController extends Controller
|
||||
{
|
||||
|
||||
private static $ssl_certificate_sni_csr = "-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIIBfzCCASUCAQAwgYoxCzAJBgNVBAYTAkRFMQ4wDAYDVQQRDAU4Nzc1NTEPMA0G
|
||||
A1UECAwGQmF5ZXJuMRUwEwYDVQQHDAxLaXJjaGhhc2xhY2gxEzARBgNVBAkMCkxl
|
||||
aW5mZWxkIDIxFjAUBgNVBAoMDXJpd2EtdGVjIGUuSy4xFjAUBgNVBAMMDSoubWl2
|
||||
aXRhLmNhcmUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATHOCZrM/6Ry1iMHtpL
|
||||
3OM+nm2NZJwbT91yWM25yaxXkkfgaKxfvjfTSgK3Yl/nE+cSrijT4BdP7H3U2ZnZ
|
||||
Rg0FoDgwNgYJKoZIhvcNAQkOMSkwJzAlBgNVHREEHjAcgg0qLm1pdml0YS5jYXJl
|
||||
ggttaXZpdGEuY2FyZTAKBggqhkjOPQQDBANIADBFAiEAva2vcfT1l/NvrMdFrujf
|
||||
pFrbXTZMecYsa9SDnHXhp1gCIG8BFZSN/mPjM3EZXunj4bb1AXqqdxe+VjPiw6VL
|
||||
lZwE
|
||||
-----END CERTIFICATE REQUEST-----";
|
||||
private static $ssl_certificate_sni_csr = "";
|
||||
private static $ssl_certificate_sni_key = "-----BEGIN PRIVATE KEY-----
|
||||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGd8N4RsRov6Kd81z
|
||||
iclbCpD5e7nT1cTN2u8XQZRU/1ChRANCAATHOCZrM/6Ry1iMHtpL3OM+nm2NZJwb
|
||||
T91yWM25yaxXkkfgaKxfvjfTSgK3Yl/nE+cSrijT4BdP7H3U2ZnZRg0F
|
||||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgohGr2e3ysw/Awvzh
|
||||
qkqDS4iQgRvWwNIYxTcPxpdcndGhRANCAASZjlV2bQbLQrOveMlYOowR3IlfND7z
|
||||
OxauFGabhvWSU1cg2w4U4bu/QXnDXfHHkcLp4M5WgHzX9Nw2m/abyJJ6
|
||||
-----END PRIVATE KEY-----";
|
||||
private static $ssl_certificate_sni_crt = "-----BEGIN CERTIFICATE-----
|
||||
MIIEpzCCBEygAwIBAgIRAOdJ/xXHharlPCF26cIYht0wCgYIKoZIzj0EAwIwgY8x
|
||||
CzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNV
|
||||
BAcTB1NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE3MDUGA1UEAxMu
|
||||
U2VjdGlnbyBFQ0MgRG9tYWluIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBDQTAe
|
||||
Fw0yMzA3MzEwMDAwMDBaFw0yNDA4MzAyMzU5NTlaMBgxFjAUBgNVBAMMDSoubWl2
|
||||
aXRhLmNhcmUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATHOCZrM/6Ry1iMHtpL
|
||||
3OM+nm2NZJwbT91yWM25yaxXkkfgaKxfvjfTSgK3Yl/nE+cSrijT4BdP7H3U2ZnZ
|
||||
Rg0Fo4IC/TCCAvkwHwYDVR0jBBgwFoAU9oUKOxGG4QR9DqoLLNLuzGR7e64wHQYD
|
||||
VR0OBBYEFJco1/8VAvZA85Ct2Z/7XSA+DKNUMA4GA1UdDwEB/wQEAwIHgDAMBgNV
|
||||
HRMBAf8EAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBJBgNVHSAE
|
||||
QjBAMDQGCysGAQQBsjEBAgIHMCUwIwYIKwYBBQUHAgEWF2h0dHBzOi8vc2VjdGln
|
||||
by5jb20vQ1BTMAgGBmeBDAECATCBhAYIKwYBBQUHAQEEeDB2ME8GCCsGAQUFBzAC
|
||||
hkNodHRwOi8vY3J0LnNlY3RpZ28uY29tL1NlY3RpZ29FQ0NEb21haW5WYWxpZGF0
|
||||
aW9uU2VjdXJlU2VydmVyQ0EuY3J0MCMGCCsGAQUFBzABhhdodHRwOi8vb2NzcC5z
|
||||
ZWN0aWdvLmNvbTAlBgNVHREEHjAcgg0qLm1pdml0YS5jYXJlggttaXZpdGEuY2Fy
|
||||
ZTCCAX8GCisGAQQB1nkCBAIEggFvBIIBawFpAHcAdv+IPwq2+5VRwmHM9Ye6NLSk
|
||||
zbsp3GhCCp/mZ0xaOnQAAAGJquwmHwAABAMASDBGAiEA7/7/S0CxtvREygwS3qR5
|
||||
THaAwfObqF09zN4AE+rjGSQCIQDNat5O0VSbx+cwaNrrVWz86C0PnUufqWNkBVEa
|
||||
5XM0bQB2ANq2v2s/tbYin5vCu1xr6HCRcWy7UYSFNL2kPTBI1/urAAABiarsJnYA
|
||||
AAQDAEcwRQIhAMkJ4iRoexvBzGa7zuHLn0/R4iDvUstKVb7ZK1XqjuVQAiACwcKG
|
||||
5WNIIeTjJ+CNDeME8mqHpgbFNWIAiiz0u+ANZwB2AO7N0GTV2xrOxVy3nbTNE6Iy
|
||||
h0Z8vOzew1FIWUZxH7WbAAABiarsJmEAAAQDAEcwRQIgVVxidEYEx6g2xLxAcI57
|
||||
eKJ4NDol/bnhmb0iERQmXOoCIQDf6Hviv4+SO+K3OoxxLI9qzFHNP6sb6aDaXfTW
|
||||
ucyTtTAKBggqhkjOPQQDAgNJADBGAiEA4hOvVoXr58YPVGi5/UEEnyDXlUfX4ZKq
|
||||
9PmblI2ZQVkCIQDRllVwklX+DUBcvzG6hapvn5Wv2171yIeoJo+vm7UO5g==
|
||||
MIIEpDCCBEqgAwIBAgIQVIm0T0SQ6D20YQxMaHEKbDAKBggqhkjOPQQDAjCBjzEL
|
||||
MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE
|
||||
BxMHU2FsZm9yZDEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTcwNQYDVQQDEy5T
|
||||
ZWN0aWdvIEVDQyBEb21haW4gVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMB4X
|
||||
DTI0MDgwMTAwMDAwMFoXDTI1MDkwMTIzNTk1OVowGDEWMBQGA1UEAwwNKi5taXZp
|
||||
dGEuY2FyZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJmOVXZtBstCs694yVg6
|
||||
jBHciV80PvM7Fq4UZpuG9ZJTVyDbDhThu79BecNd8ceRwungzlaAfNf03Dab9pvI
|
||||
knqjggL8MIIC+DAfBgNVHSMEGDAWgBT2hQo7EYbhBH0Oqgss0u7MZHt7rjAdBgNV
|
||||
HQ4EFgQUVCkHH2AasJQFWFs63rdcb6BRvyowDgYDVR0PAQH/BAQDAgeAMAwGA1Ud
|
||||
EwEB/wQCMAAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMEkGA1UdIARC
|
||||
MEAwNAYLKwYBBAGyMQECAgcwJTAjBggrBgEFBQcCARYXaHR0cHM6Ly9zZWN0aWdv
|
||||
LmNvbS9DUFMwCAYGZ4EMAQIBMIGEBggrBgEFBQcBAQR4MHYwTwYIKwYBBQUHMAKG
|
||||
Q2h0dHA6Ly9jcnQuc2VjdGlnby5jb20vU2VjdGlnb0VDQ0RvbWFpblZhbGlkYXRp
|
||||
b25TZWN1cmVTZXJ2ZXJDQS5jcnQwIwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLnNl
|
||||
Y3RpZ28uY29tMCUGA1UdEQQeMByCDSoubWl2aXRhLmNhcmWCC21pdml0YS5jYXJl
|
||||
MIIBfgYKKwYBBAHWeQIEAgSCAW4EggFqAWgAdgDd3Mo0ldfhFgXnlTL6x5/4PRxQ
|
||||
39sAOhQSdgosrLvIKgAAAZEMky0iAAAEAwBHMEUCICSH9TLHP8tqMyBTBpxF1+lw
|
||||
4wAnWf4E5pPJ6651S8P9AiEAkKqOQDaVdoFI1+jM28grXnG5o0vFLUwa0o49KYQ3
|
||||
k+sAdgAN4fIwK9MNwUBiEgnqVS78R3R8sdfpMO8OQh60fk6qNAAAAZEMkyzbAAAE
|
||||
AwBHMEUCIFJfJS4cojUm9nHQ1TVlxpFwOV7QwCj9MOfq0CCkVzsGAiEA8WQrE1ri
|
||||
kJkeIVPSgUVJpIz8TKef2aR+Ivzkzon52QIAdgAS8U40vVNyTIQGGcOPP3oT+Oe1
|
||||
YoeInG0wBYTr5YYmOgAAAZEMkyzBAAAEAwBHMEUCIQCH8/qTmCNea3FdBVk0c3Wu
|
||||
FrvYnoQlTQaaDS/zeTxSzwIge6VO5Aeor30Wu675zBYzNsIru5gXOTl4dteBMYnC
|
||||
0JswCgYIKoZIzj0EAwIDSAAwRQIhAKxmgpPqW6UAcWHCoWAPN673pBMxnCKn3vFq
|
||||
wUkhGrT7AiBDUsDuMhabsGlZ10X2GXcm+1mwxdMLSDYEWiwk5fUaNA==
|
||||
-----END CERTIFICATE-----";
|
||||
private static $ssl_certificate_sni_bundle = "-----BEGIN CERTIFICATE-----
|
||||
MIIDqDCCAy6gAwIBAgIRAPNkTmtuAFAjfglGvXvh9R0wCgYIKoZIzj0EAwMwgYgx
|
||||
|
|
|
|||
|
|
@ -3,13 +3,17 @@
|
|||
namespace App\Http\Controllers\Api;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Services\Payment;
|
||||
use App\Services\Shop;
|
||||
use App\Services\Util;
|
||||
use App\Models\UserAbo;
|
||||
use App\Services\MyLog;
|
||||
use App\Services\Payment;
|
||||
use App\Services\AboHelper;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ShoppingUserService;
|
||||
|
||||
|
||||
class PayoneController extends Controller
|
||||
|
|
@ -41,47 +45,60 @@ class PayoneController extends Controller
|
|||
*/
|
||||
|
||||
if(!isset($data['key']) || !isset($data['param']) || !isset($data['userid']) || !isset($data['txid']) || !isset($data['reference']) || !isset($data['price'])){
|
||||
\Log::channel('payone')->error('PaymentStatus: parameter incomplete: '.json_encode($data));
|
||||
echo "PaymentStatus: parameter incomplete:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2001 App\Http\Controllers\Api\PayoneController::paymentStatus parameter incomplete',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($data['key'] != config('payone.defaults.key')) {
|
||||
\Log::channel('payone')->error('PaymentStatus: Key error: '.json_encode($data));
|
||||
echo "PaymentStatus: Key error:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'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){
|
||||
\Log::channel('payone')->error('PaymentStatus: ShoppingOrder not found: '.json_encode($data));
|
||||
echo "PaymentStatus: ShoppingOrder not found:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2003 App\Http\Controllers\Api\PayoneController::paymentStatus ShoppingOrder not found:',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
$shopping_payment = ShoppingPayment::where('reference', $data['reference'])->first();
|
||||
if(!$shopping_payment){
|
||||
\Log::channel('payone')->error('PaymentStatus: ShoppingPayment not found: '.json_encode($data));
|
||||
echo "PaymentStatus: ShoppingPayment not found:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'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){
|
||||
\Log::channel('payone')->error('PaymentStatus: ShoppingPayment no realation ShoppingOrder: '.json_encode($data));
|
||||
echo "PaymentStatus: ShoppingPayment no realation ShoppingOrder:";
|
||||
var_dump($data);
|
||||
die();
|
||||
}
|
||||
|
||||
if($data['key'] != config('payone.defaults.key')) {
|
||||
\Log::channel('payone')->error('PaymentStatus: Key error: '.json_encode($data));
|
||||
echo "PaymentStatus: ShoppingPayment no realation ShoppingOrder:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'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, '.', '');
|
||||
|
|
@ -89,21 +106,39 @@ class PayoneController extends Controller
|
|||
if($price_amount != $price){
|
||||
$data['shopping_payment-amount'] = $price_amount;
|
||||
$data['price-amount'] = $price;
|
||||
\Log::channel('payone')->error('PaymentStatus: Price error: '.json_encode($data));
|
||||
echo "PaymentStatus: Price error:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2006 App\Http\Controllers\Api\PayoneController::paymentStatus Price error',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
/* TODO -- need this?
|
||||
|
||||
/* TODO -- need this? */
|
||||
if($shopping_payment->txaction == $data['txaction']){
|
||||
\Log::channel('payone')->error('PaymentStatus: same txaction error: '.json_encode($data));
|
||||
echo "PaymentStatus: same txaction:";
|
||||
var_dump($data);
|
||||
die();
|
||||
|
||||
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
|
||||
);
|
||||
//was already paid
|
||||
print("TSOK");
|
||||
exit;
|
||||
}else{
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2007 App\Http\Controllers\Api\PayoneController::paymentStatus same txaction - show',
|
||||
$data
|
||||
);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//create transaction
|
||||
PaymentTransaction::create([
|
||||
'shopping_payment_id' => $shopping_payment->id,
|
||||
|
|
@ -124,19 +159,19 @@ class PayoneController extends Controller
|
|||
|
||||
$send_link = false;
|
||||
$send_mail = true;
|
||||
|
||||
if($data['txaction'] === 'failed'){
|
||||
$shopping_order->setUserHistoryValue(['status' => 6]);
|
||||
|
||||
Util::setInstanceStatusByPayment($shopping_payment, 5);
|
||||
}
|
||||
if($data['txaction'] === 'appointed'){
|
||||
$shopping_order->setUserHistoryValue(['status' => 7]);
|
||||
Shop::userOrders();
|
||||
ShoppingUserService::snycOrdersByShoppingOrder($shopping_order);
|
||||
Util::setInstanceStatusByPayment($shopping_payment, 4);
|
||||
}
|
||||
|
||||
if($data['txaction'] === 'paid'){
|
||||
if(!$shopping_order->paid){
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true, $shopping_payment);
|
||||
}else{
|
||||
$send_mail = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -593,7 +593,7 @@ class ShoppingUserController extends Controller
|
|||
if ($order->price != ($product->price * 100)) {
|
||||
$error[] = "different price: " . ($product->price * 100);
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), (int) $order->qty, $product->price, false, false, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), (int) $order->qty, $product->price, false, false, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class BusinessController extends Controller
|
|||
private $filter_active = [1 => 'aktiv', 2 => 'nicht aktiv', 3 => 'alle'];
|
||||
private $month;
|
||||
private $year;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
|
@ -42,7 +42,7 @@ class BusinessController extends Controller
|
|||
|
||||
$TreeCalcBot = new TreeCalcBot($this->month, $this->year, 'admin');
|
||||
$TreeCalcBot->initStructureAdmin();
|
||||
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(),
|
||||
|
|
@ -61,7 +61,7 @@ class BusinessController extends Controller
|
|||
$data['year'] = session('business_user_filter_year');
|
||||
$TreeCalcBot = new TreeCalcBot($data['month'], $data['year'], 'admin');
|
||||
$TreeCalcBot->initBusinesslUserDetail($user);
|
||||
if(!$TreeCalcBot->business_user){
|
||||
if (!$TreeCalcBot->business_user) {
|
||||
abort(403, 'no user found');
|
||||
}
|
||||
return view('admin.business.user_detail', compact('TreeCalcBot', 'user', 'data'));
|
||||
|
|
@ -82,49 +82,52 @@ class BusinessController extends Controller
|
|||
//return back();
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if(!session('business_user_filter_month')){
|
||||
if (!session('business_user_filter_month')) {
|
||||
session(['business_user_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('business_user_filter_year')){
|
||||
if (!session('business_user_filter_year')) {
|
||||
session(['business_user_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(!session('business_user_filter_active')){
|
||||
if (!session('business_user_filter_active')) {
|
||||
session(['business_user_filter_active' => 1]);
|
||||
}
|
||||
if(!session('business_user_filter_depiction')){
|
||||
if (!session('business_user_filter_depiction')) {
|
||||
session(['business_user_filter_depiction' => 'active']);
|
||||
}
|
||||
|
||||
if(Request::get('business_user_filter_depiction')){
|
||||
if (Request::get('business_user_filter_depiction')) {
|
||||
session(['business_user_filter_depiction' => Request::get('business_user_filter_depiction')]);
|
||||
}
|
||||
if(Request::get('business_user_filter_name')){
|
||||
if (Request::get('business_user_filter_name')) {
|
||||
session(['business_user_filter_name' => Request::get('business_user_filter_name')]);
|
||||
} else {
|
||||
session(['business_user_filter_name' => '']);
|
||||
}
|
||||
if(Request::get('business_user_filter_active')){
|
||||
if (Request::get('business_user_filter_active')) {
|
||||
session(['business_user_filter_active' => Request::get('business_user_filter_active')]);
|
||||
}
|
||||
if(Request::get('business_user_filter_month')){
|
||||
if (Request::get('business_user_filter_month')) {
|
||||
session(['business_user_filter_month' => Request::get('business_user_filter_month')]);
|
||||
}
|
||||
if(Request::get('business_user_filter_year')){
|
||||
if (Request::get('business_user_filter_year')) {
|
||||
session(['business_user_filter_year' => Request::get('business_user_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function userDatatable()
|
||||
{
|
||||
{
|
||||
$this->month = Request::get('business_user_filter_month');
|
||||
$this->year = Request::get('business_user_filter_year');
|
||||
|
||||
//only the currently month get from Users -> older month from UserBusiness
|
||||
return $this->userCurrentlyDatatable();
|
||||
if(TreeCalcBot::isFromStored($this->month, $this->year)){
|
||||
return $this->userCurrentlyDatatable();
|
||||
if (TreeCalcBot::isFromStored($this->month, $this->year)) {
|
||||
return $this->userStoredDatatable();
|
||||
}else{
|
||||
} else {
|
||||
return $this->userCurrentlyDatatable();
|
||||
}
|
||||
}
|
||||
|
|
@ -132,16 +135,16 @@ class BusinessController extends Controller
|
|||
private function initStoredSearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
|
||||
$query = UserBusiness::select('user_businesses.*')->where('month', $this->month)->where('year', $this->year);
|
||||
if(Request::get('business_user_filter_active')){
|
||||
if(Request::get('business_user_filter_active') == 1){
|
||||
if (Request::get('business_user_filter_active')) {
|
||||
if (Request::get('business_user_filter_active') == 1) {
|
||||
$query->where('user_businesses.active_account', 1);
|
||||
}
|
||||
if(Request::get('business_user_filter_active') == 2){
|
||||
if (Request::get('business_user_filter_active') == 2) {
|
||||
$query->where('user_businesses.active_account', 0);
|
||||
}
|
||||
if(Request::get('business_user_filter_active') == 3){
|
||||
if (Request::get('business_user_filter_active') == 3) {
|
||||
//both -> payment_account only not null
|
||||
}
|
||||
}
|
||||
|
|
@ -149,18 +152,18 @@ class BusinessController extends Controller
|
|||
}
|
||||
|
||||
private function userStoredDatatable()
|
||||
{
|
||||
{
|
||||
$query = $this->initStoredSearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserBusiness $userBusiness) {
|
||||
return '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$userBusiness->user_id.'"
|
||||
data-id="' . $userBusiness->user_id . '"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button>'.
|
||||
(config('app.debug') === true ? '<a href="' . route('admin_business_user_detail', [$userBusiness->user_id]) . '" class="btn icon-btn btn-xs btn-primary"><span class="fa fa-calculator"></span></a>' : '');
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-calculator"></span></button>' .
|
||||
(config('app.debug') === true ? '<a href="' . route('admin_business_user_detail', [$userBusiness->user_id]) . '" class="btn icon-btn btn-xs btn-primary"><span class="fa fa-calculator"></span></a>' : '');
|
||||
})
|
||||
->addColumn('m_account', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->m_account;
|
||||
|
|
@ -169,19 +172,19 @@ class BusinessController extends Controller
|
|||
return $userBusiness->user_level_name;
|
||||
})
|
||||
->addColumn('is_qual_kp', function (UserBusiness $userBusiness) {
|
||||
if($userBusiness->m_level_id){
|
||||
if ($userBusiness->m_level_id) {
|
||||
$isQualKP = ($userBusiness->sales_volume_points_sum >= $userBusiness->qual_kp) ? true : false;
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-danger').'"> KU '.$userBusiness->qual_kp.'</span>';
|
||||
return '<span class="badge ' . ($isQualKP ? 'badge-outline-success' : 'badge-outline-danger') . '"> KU ' . $userBusiness->qual_kp . '</span>';
|
||||
}
|
||||
return '-';
|
||||
})
|
||||
->addColumn('sales_volume_KP_points', function (UserBusiness $userBusiness) {
|
||||
return '<div class="no-line-break">'.$userBusiness->sales_volume_points_sum.'</div>'.
|
||||
'<span class="small no-line-break">E: '.$userBusiness->sales_volume_KP_points.' | S: '.$userBusiness->sales_volume_points_shop.'</span>';
|
||||
return '<div class="no-line-break">' . $userBusiness->sales_volume_points_sum . '</div>' .
|
||||
'<span class="small no-line-break">E: ' . $userBusiness->sales_volume_KP_points . ' | S: ' . $userBusiness->sales_volume_points_shop . '</span>';
|
||||
})
|
||||
->addColumn('sales_volume_total', function (UserBusiness $userBusiness) {
|
||||
return '<div class="no-line-break">'.formatNumber($userBusiness->sales_volume_total_sum).' €</div>'.
|
||||
'<span class="small no-line-break">E: '.formatNumber($userBusiness->sales_volume_total).' | S: '.formatNumber($userBusiness->sales_volume_total_shop).'</span>';
|
||||
return '<div class="no-line-break">' . formatNumber($userBusiness->sales_volume_total_sum) . ' €</div>' .
|
||||
'<span class="small no-line-break">E: ' . formatNumber($userBusiness->sales_volume_total) . ' | S: ' . formatNumber($userBusiness->sales_volume_total_shop) . '</span>';
|
||||
})
|
||||
->addColumn('email', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->email;
|
||||
|
|
@ -193,23 +196,23 @@ class BusinessController extends Controller
|
|||
return $userBusiness->last_name;
|
||||
})
|
||||
->addColumn('sponsor', function (UserBusiness $userBusiness) {
|
||||
if($userBusiness->sponsor){
|
||||
if ($userBusiness->sponsor) {
|
||||
$sponsor = "";
|
||||
if($userBusiness->sponsor->is_sponsor){
|
||||
$sponsor .= $userBusiness->sponsor->first_name." ".$userBusiness->sponsor->last_name;
|
||||
$sponsor .= " ".'<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$userBusiness->sponsor->user_id.'"
|
||||
if ($userBusiness->sponsor->is_sponsor) {
|
||||
$sponsor .= $userBusiness->sponsor->first_name . " " . $userBusiness->sponsor->last_name;
|
||||
$sponsor .= " " . '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="' . $userBusiness->sponsor->user_id . '"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button><br>';
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-calculator"></span></button><br>';
|
||||
|
||||
$sponsor .= '<span class="small no-line-break">' . $userBusiness->sponsor->email;
|
||||
$sponsor .= ' | ' . $userBusiness->sponsor->m_account;
|
||||
$sponsor .= '</span>';
|
||||
}
|
||||
|
||||
$sponsor .= '<span class="small no-line-break">'.$userBusiness->sponsor->email;
|
||||
$sponsor .= ' | '.$userBusiness->sponsor->m_account;
|
||||
$sponsor .= '</span>';
|
||||
}
|
||||
|
||||
return $sponsor;
|
||||
}
|
||||
return '-';
|
||||
|
|
@ -222,25 +225,25 @@ class BusinessController extends Controller
|
|||
return $userBusiness->active_date ? formatDate($userBusiness->active_date) : "-";
|
||||
})
|
||||
|
||||
|
||||
->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 . '%');
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -253,29 +256,29 @@ class BusinessController extends Controller
|
|||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_KP_points', 'sales_volume_total', 'sponsor', 'active_account'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
private function initCurrentlySearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = User::join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.*', 'user_accounts.m_account', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->where('users.deleted_at', '=', null)
|
||||
->where('users.id', '!=', 1)
|
||||
->where('users.admin', "<", 4)
|
||||
->where('users.m_level', "!=", null)
|
||||
->where('users.payment_account', "!=", null);
|
||||
|
||||
// $query = User::with('account')->select('users.*')
|
||||
|
||||
if(Request::get('business_user_filter_active')){
|
||||
if(Request::get('business_user_filter_active') == 1){
|
||||
$query = User::join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.*', 'user_accounts.m_account', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->where('users.deleted_at', '=', null)
|
||||
->where('users.id', '!=', 1)
|
||||
->where('users.admin', "<", 4)
|
||||
->where('users.m_level', "!=", null)
|
||||
->where('users.payment_account', "!=", null);
|
||||
|
||||
// $query = User::with('account')->select('users.*')
|
||||
|
||||
if (Request::get('business_user_filter_active')) {
|
||||
if (Request::get('business_user_filter_active') == 1) {
|
||||
$query->where('users.payment_account', ">=", now());
|
||||
}
|
||||
if(Request::get('business_user_filter_active') == 2){
|
||||
if (Request::get('business_user_filter_active') == 2) {
|
||||
$query->where('users.payment_account', "<", now());
|
||||
}
|
||||
if(Request::get('business_user_filter_active') == 3){
|
||||
if (Request::get('business_user_filter_active') == 3) {
|
||||
//both -> payment_account only not null
|
||||
}
|
||||
}
|
||||
|
|
@ -283,18 +286,18 @@ class BusinessController extends Controller
|
|||
}
|
||||
|
||||
private function userCurrentlyDatatable()
|
||||
{
|
||||
{
|
||||
$query = $this->initCurrentlySearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (User $user) {
|
||||
return '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$user->id.'"
|
||||
data-id="' . $user->id . '"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button>'.
|
||||
(config('app.debug') === true ? '<a href="' . route('admin_business_user_detail', [$user->id]) . '" class="btn icon-btn btn-xs btn-primary"><span class="fa fa-calculator"></span></a>' : '');
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-calculator"></span></button>' .
|
||||
(config('app.debug') === true ? '<a href="' . route('admin_business_user_detail', [$user->id]) . '" class="btn icon-btn btn-xs btn-primary"><span class="fa fa-calculator"></span></a>' : '');
|
||||
})
|
||||
->addColumn('m_account', function (User $user) {
|
||||
return $user->account ? $user->account->m_account : '';
|
||||
|
|
@ -303,21 +306,21 @@ class BusinessController extends Controller
|
|||
return $user->user_level ? $user->user_level->getLang('name') : '';
|
||||
})
|
||||
->addColumn('is_qual_kp', function (User $user) {
|
||||
if($user->user_level){
|
||||
if ($user->user_level) {
|
||||
$qual_kp = $user->user_level->qual_kp;
|
||||
$sales_volume_points_sum = $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_KP_sum');
|
||||
$isQualKP = ($sales_volume_points_sum >= $qual_kp) ? true : false;
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-warning-dark').'"> KU '.$qual_kp.'</span>';
|
||||
return '<span class="badge ' . ($isQualKP ? 'badge-outline-success' : 'badge-outline-warning-dark') . '"> KU ' . $qual_kp . '</span>';
|
||||
}
|
||||
return '-';
|
||||
})
|
||||
->addColumn('sales_volume_KP_points', function (User $user) {
|
||||
return '<div class="no-line-break">'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_KP_sum').'</div>'.
|
||||
'<span class="small no-line-break">E: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_KP_points').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop').'</span>';
|
||||
})
|
||||
->addColumn('sales_volume_KP_points', function (User $user) {
|
||||
return '<div class="no-line-break">' . $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_KP_sum') . '</div>' .
|
||||
'<span class="small no-line-break">E: ' . $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_KP_points') . ' | S: ' . $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop') . '</span>';
|
||||
})
|
||||
->addColumn('sales_volume_total', function (User $user) {
|
||||
return '<div class="no-line-break">'.formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum')).' €</div>'.
|
||||
'<span class="small no-line-break">E: '.formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total')).' | S: '.formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop')).'</span>';
|
||||
return '<div class="no-line-break">' . formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum')) . ' €</div>' .
|
||||
'<span class="small no-line-break">E: ' . formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total')) . ' | S: ' . formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop')) . '</span>';
|
||||
})
|
||||
->addColumn('email', function (User $user) {
|
||||
return $user->email;
|
||||
|
|
@ -329,24 +332,24 @@ class BusinessController extends Controller
|
|||
return $user->account ? $user->account->last_name : '';
|
||||
})
|
||||
->addColumn('sponsor', function (User $user) {
|
||||
if($user->user_sponsor){
|
||||
if ($user->user_sponsor) {
|
||||
$sponsor = "";
|
||||
if($user->user_sponsor->account){
|
||||
$sponsor .= $user->user_sponsor->account->first_name." ".$user->user_sponsor->account->last_name;
|
||||
$sponsor .= " ".'<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$user->user_sponsor->id.'"
|
||||
if ($user->user_sponsor->account) {
|
||||
$sponsor .= $user->user_sponsor->account->first_name . " " . $user->user_sponsor->account->last_name;
|
||||
$sponsor .= " " . '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="' . $user->user_sponsor->id . '"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button><br>';
|
||||
}
|
||||
$sponsor .= '<span class="small no-line-break">'.$user->user_sponsor->email;
|
||||
if($user->user_sponsor->account){
|
||||
$sponsor .= ' | '.$user->user_sponsor->account->m_account;
|
||||
}
|
||||
$sponsor .= '</span>';
|
||||
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-calculator"></span></button><br>';
|
||||
}
|
||||
$sponsor .= '<span class="small no-line-break">' . $user->user_sponsor->email;
|
||||
if ($user->user_sponsor->account) {
|
||||
$sponsor .= ' | ' . $user->user_sponsor->account->m_account;
|
||||
}
|
||||
$sponsor .= '</span>';
|
||||
|
||||
return $sponsor;
|
||||
}
|
||||
return '-';
|
||||
|
|
@ -358,25 +361,25 @@ class BusinessController extends Controller
|
|||
->addColumn('payment_account_date', function (User $user) {
|
||||
return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-";
|
||||
})
|
||||
|
||||
->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', 'm_account $1')
|
||||
|
|
@ -387,5 +390,5 @@ class BusinessController extends Controller
|
|||
->orderColumn('active_account', 'payment_account $1')
|
||||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_KP_points', 'sales_volume_total', 'sponsor', 'active_account'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,13 +12,16 @@ use App\Mail\MailVerifyAccount;
|
|||
use App\Services\PaymentHelper;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class CronController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
// Konstanten für bessere Lesbarkeit
|
||||
private const CRON_KEY = 'CqZHL79FwUCcy9pjvi';
|
||||
private const RUN_CRON_KEY = 'G8ZvEbnP8fEPfnWX4L';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
|
|
@ -28,58 +31,94 @@ class CronController extends Controller
|
|||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->userRepo = $userRepo;
|
||||
|
||||
// $this->middleware('auth');
|
||||
Log::channel('cron')->info('CronController initialisiert');
|
||||
}
|
||||
|
||||
/**
|
||||
* Hauptindex-Methode für Cron-Jobs
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
Log::channel('cron')->info('Cron-Index aufgerufen');
|
||||
//$this->checkConfirmation();
|
||||
//TODO
|
||||
//SEPA Booking
|
||||
//Mail reminder
|
||||
return "Cron-Index ausgeführt";
|
||||
}
|
||||
|
||||
public function action($action = false, $key = false){
|
||||
|
||||
if($key !== 'CqZHL79FwUCcy9pjvi'){
|
||||
/**
|
||||
* Führt eine bestimmte Cron-Aktion aus
|
||||
*
|
||||
* @param string|bool $action Die auszuführende Aktion
|
||||
* @param string|bool $key Sicherheitsschlüssel
|
||||
* @return mixed
|
||||
*/
|
||||
public function action($action = false, $key = false)
|
||||
{
|
||||
Log::channel('cron')->info('Cron-Aktion aufgerufen: ' . $action);
|
||||
|
||||
if($key !== self::CRON_KEY){
|
||||
Log::channel('cron')->warning('Ungültiger Cron-Key verwendet: ' . $key);
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if($action === 'check_payments_account'){
|
||||
$this->checkPaymentsAccounts();
|
||||
Log::channel('cron')->info('Starte Überprüfung der Zahlungskonten');
|
||||
return $this->checkPaymentsAccounts();
|
||||
}
|
||||
|
||||
Log::channel('cron')->warning('Unbekannte Aktion angefordert: ' . $action);
|
||||
return response('Keine gültige Aktion angegeben', 400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
* Überprüft Benutzerbestätigungen und sendet Erinnerungen
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return string
|
||||
*/
|
||||
public function checkConfirmation()
|
||||
{
|
||||
Log::channel('cron')->info('Starte Überprüfung der Benutzerbestätigungen');
|
||||
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$next = date('Y-m-d H:i:s', strtotime('+3 week'));
|
||||
|
||||
$users = User::where('confirmed', '=', 0)->where('confirmation_code_to', '<', $now)->get();
|
||||
Log::channel('cron')->info('Gefundene unbestätigte Benutzer: ' . $users->count());
|
||||
|
||||
foreach ($users as $user) {
|
||||
|
||||
//delete user
|
||||
if ($user->confirmation_code_remider == 1) {
|
||||
Log::channel('cron')->warning('Lösche unbestätigten Benutzer: ' . $user->email);
|
||||
$this->userRepo->deleteUser($user);
|
||||
|
||||
}
|
||||
//send new remider
|
||||
if ($user->confirmation_code_remider == 0) {
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyAccount($user->confirmation_code, $user));
|
||||
$user->confirmation_code_to = $next;
|
||||
$user->confirmation_code_remider = 1;
|
||||
$user->save();
|
||||
if(!Util::isTestSystem()){
|
||||
Log::channel('cron')->info('Sende Bestätigungserinnerung an: ' . $user->email);
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyAccount($user->confirmation_code, $user));
|
||||
$user->confirmation_code_to = $next;
|
||||
$user->confirmation_code_remider = 1;
|
||||
$user->save();
|
||||
} else {
|
||||
Log::channel('cron')->info('Testsystem: Bestätigungserinnerung an: ' . $user->email);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "TOSK";
|
||||
}
|
||||
|
||||
public function checkPaymentsAccounts(){
|
||||
/**
|
||||
* Überprüft Zahlungskonten und sendet Erinnerungen
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function checkPaymentsAccounts()
|
||||
{
|
||||
Log::channel('cron')->info('Starte Überprüfung der Zahlungskonten');
|
||||
|
||||
/*RULES
|
||||
reminders
|
||||
|
|
@ -93,207 +132,289 @@ class CronController extends Controller
|
|||
*/
|
||||
//max Date for reminder
|
||||
$renewalDate = Carbon::now()->modify('+'.(config('mivita.remind_first_days')+1).' days');
|
||||
//dump($renewalDate);
|
||||
Log::channel('cron')->info('Erneuerungsdatum für Zahlungen: ' . $renewalDate->format('Y-m-d H:i:s'));
|
||||
|
||||
$users = User::where('payment_account', '!=', NULL)
|
||||
->where('active', '=', 1)
|
||||
->where('blocked', '!=', 1)
|
||||
->where('payment_account', '<', $renewalDate)
|
||||
->get();
|
||||
|
||||
/* $user = User::find(2);
|
||||
$this->checkReminderPayments($user);
|
||||
dump($user->daysActiveAccount());
|
||||
dump($user->email." | ".$user->getPaymentAccountDateFormat());
|
||||
die();*/
|
||||
Log::channel('cron')->info('Gefundene Benutzer für Zahlungserinnerungen: ' . $users->count());
|
||||
|
||||
foreach ($users as $user){
|
||||
Log::channel('cron')->info('Prüfe Zahlungserinnerungen für Benutzer: ' . $user->email);
|
||||
$this->checkReminderPayments($user);
|
||||
/* Abo Option deaktiviert
|
||||
$this->userInitAboPayment($user);
|
||||
*/
|
||||
}
|
||||
|
||||
return "TOSK";
|
||||
}
|
||||
|
||||
private function userInitAboPayment(User $user){
|
||||
/**
|
||||
* Initiiert Abo-Zahlungen für einen Benutzer
|
||||
* hier geht es um die Mitglieschaft Abos - die sind derzeit deaktiviert
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @return bool
|
||||
*/
|
||||
private function userInitAboPayment(User $user)
|
||||
{
|
||||
if(!$user->isAcountAboPayDate()){
|
||||
Log::channel('cron')->info('Kein Abo-Zahlungsdatum für Benutzer: ' . $user->email);
|
||||
return false;
|
||||
}
|
||||
|
||||
//user has a open Abo Payment
|
||||
if($this->checkIsAboPaymentOpen($user)){
|
||||
Log::channel('cron')->info('Offene Abo-Zahlung für Benutzer: ' . $user->email);
|
||||
return false;
|
||||
}
|
||||
|
||||
if($user->payment_order_product){
|
||||
Log::channel('cron')->info('Starte Abo-Zahlung für Benutzer: ' . $user->email);
|
||||
$this->buyProductAboPayment($user, $user->payment_order_product);
|
||||
}
|
||||
/*dump($user->daysActiveAccount());
|
||||
dump($user->email." | ".$user->getPaymentAccountDateFormat());
|
||||
dump('-------------------');*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function checkIsAboPaymentOpen(User $user){
|
||||
/**
|
||||
* Prüft, ob eine offene Abo-Zahlung existiert
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @return bool
|
||||
*/
|
||||
private function checkIsAboPaymentOpen(User $user)
|
||||
{
|
||||
$isOpen = UserHistory::whereUserId($user->id)
|
||||
->whereAction('abo_open_payment')
|
||||
->whereIdentifier($user->payment_account)
|
||||
->where('status', '>=', 1) //open //error // payment
|
||||
->get()->last();
|
||||
|
||||
if($isOpen){
|
||||
Log::channel('cron')->info('Offene Abo-Zahlung gefunden für: ' . $user->email);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function checkReminderPayments(User $user){
|
||||
|
||||
/* $isSend = $this->checkIsReminderSend($user, 31);
|
||||
$isSend = $this->checkIsReminderSend($user, 32);
|
||||
$isSend = $this->checkIsReminderSend($user, 33);
|
||||
$isSend = $this->checkIsReminderSend($user, 34);
|
||||
$isSend = $this->checkIsReminderSend($user, 35);
|
||||
$isSend = $this->checkIsReminderSend($user, 36);
|
||||
return ;*/
|
||||
|
||||
/**
|
||||
* Prüft und sendet Zahlungserinnerungen basierend auf Benutzerkontostand
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @return bool
|
||||
*/
|
||||
private function checkReminderPayments(User $user)
|
||||
{
|
||||
//35 reminder_deaktiv, 36 reminder_deaktiv_sepa
|
||||
if(!$user->isActiveAccount()){
|
||||
/* Abo Option deaktiviert
|
||||
if($user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 36);
|
||||
return $isSend;
|
||||
}
|
||||
*/
|
||||
Log::channel('cron')->info('Inaktives Konto für Benutzer: ' . $user->email);
|
||||
$isSend = $this->checkIsReminderSend($user, 35);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
//34 reminder_last
|
||||
if($user->daysActiveAccount() <= config('mivita.remind_last_days')){
|
||||
Log::channel('cron')->info('Letzte Erinnerung für Benutzer: ' . $user->email . ' (Tage aktiv: ' . $user->daysActiveAccount() . ')');
|
||||
$isSend = $this->checkIsReminderSend($user, 34);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
//33 reminder_sec
|
||||
if($user->daysActiveAccount() <= config('mivita.remind_sec_days')){
|
||||
/* Abo Option deaktiviert
|
||||
if(!$user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 33);
|
||||
return $isSend;
|
||||
}
|
||||
*/
|
||||
|
||||
Log::channel('cron')->info('Zweite Erinnerung für Benutzer: ' . $user->email . ' (Tage aktiv: ' . $user->daysActiveAccount() . ')');
|
||||
$isSend = $this->checkIsReminderSend($user, 33);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
//31 reminder_first, 32 reminder_first_sepa
|
||||
//31 reminder_first
|
||||
if($user->daysActiveAccount() > config('mivita.remind_sec_days')){
|
||||
/* Abo Option deaktiviert
|
||||
if($user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 32);
|
||||
return $isSend;
|
||||
} */
|
||||
Log::channel('cron')->info('Erste Erinnerung für Benutzer: ' . $user->email . ' (Tage aktiv: ' . $user->daysActiveAccount() . ')');
|
||||
$isSend = $this->checkIsReminderSend($user, 31);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function checkIsReminderSend(User $user, $status){
|
||||
|
||||
/**
|
||||
* Überprüft, ob eine Erinnerung bereits gesendet wurde
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @param int $status Status-Code der Erinnerung
|
||||
* @return bool
|
||||
*/
|
||||
private function checkIsReminderSend(User $user, $status)
|
||||
{
|
||||
$isSend = UserHistory::whereUserId($user->id)
|
||||
->whereAction('reminder_payments')
|
||||
->whereIdentifier($user->payment_account)
|
||||
->whereStatus($status)
|
||||
->get()->last();
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if($isSend){
|
||||
Log::channel('cron')->info('Erinnerung bereits gesendet für Benutzer: ' . $user->email . ' (Status: ' . $status . ')');
|
||||
return true;
|
||||
}
|
||||
|
||||
Log::channel('cron')->info('Sende neue Erinnerung für Benutzer: ' . $user->email . ' (Status: ' . $status . ')');
|
||||
$referenz = $this->sendReminderMail($user, $status);
|
||||
|
||||
//is not sent create
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'reminder_payments', 'referenz'=>$referenz, 'identifier'=>$user->payment_account, 'status'=>$status]);
|
||||
UserHistory::create([
|
||||
'user_id' => $user->id,
|
||||
'action' => 'reminder_payments',
|
||||
'referenz' => $referenz,
|
||||
'identifier' => $user->payment_account,
|
||||
'status' => $status
|
||||
]);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private function sendReminderMail(User $user, $status){
|
||||
|
||||
$days = $user->daysActiveAccount();
|
||||
if($days < 0){
|
||||
$days = $days*-1;
|
||||
}
|
||||
|
||||
//dump($days);
|
||||
//dump($status);
|
||||
$pay_date = Carbon::parse($user->payment_account)->modify('- '.config('mivita.abo_booking_days').' days')->format('d.m.Y');
|
||||
/**
|
||||
* Sendet eine Erinnerungs-E-Mail an den Benutzer
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @param int $status Status-Code der Erinnerung
|
||||
* @return int
|
||||
*/
|
||||
private function sendReminderMail(User $user, $status)
|
||||
{
|
||||
$days = abs($user->daysActiveAccount());
|
||||
|
||||
$pay_date = Carbon::parse($user->payment_account)
|
||||
->modify('- ' . config('mivita.abo_booking_days') . ' days')
|
||||
->format('d.m.Y');
|
||||
|
||||
$datetime = $user->getPaymentAccountDateFormat();
|
||||
$price = "";
|
||||
|
||||
if($user->payment_order_id && isset($user->payment_order_product->price)){
|
||||
$price = 'von '.$user->payment_order_product->getFormattedPrice().' EUR';
|
||||
$price = 'von ' . $user->payment_order_product->getFormattedPrice() . ' EUR';
|
||||
}
|
||||
|
||||
$message = __('reminder.copy_first_'.$status, ['days'=>$days, 'datetime'=>$datetime, 'price' =>$price, 'pay_date'=>$pay_date]);
|
||||
$message_last = __('reminder.copy_last_'.$status, ['days'=>$days, 'datetime'=>$datetime, 'price' =>$price, 'pay_date'=>$pay_date]);
|
||||
$button = __('reminder.button_'.$status);
|
||||
$message = __('reminder.copy_first_' . $status, [
|
||||
'days' => $days,
|
||||
'datetime' => $datetime,
|
||||
'price' => $price,
|
||||
'pay_date' => $pay_date
|
||||
]);
|
||||
|
||||
$message_last = __('reminder.copy_last_' . $status, [
|
||||
'days' => $days,
|
||||
'datetime' => $datetime,
|
||||
'price' => $price,
|
||||
'pay_date' => $pay_date
|
||||
]);
|
||||
|
||||
$button = __('reminder.button_' . $status);
|
||||
|
||||
$message = preg_replace("/[\n\r]/","",$message);
|
||||
$message_last = preg_replace("/[\n\r]/","",$message_last);
|
||||
$message = preg_replace("/[\n\r]/", "", $message);
|
||||
$message_last = preg_replace("/[\n\r]/", "", $message_last);
|
||||
|
||||
$data = [
|
||||
'subject' => __('reminder.subject')." | ID: ".$status,
|
||||
'subject' => __('reminder.subject') . " | ID: " . $status,
|
||||
'message' => $message,
|
||||
'message_last' => $message_last,
|
||||
'url' => route('user_membership'),
|
||||
'button' => $button,
|
||||
];
|
||||
//dump($data);
|
||||
|
||||
$sender = User::find(1);
|
||||
$customer_mail = UserMessage::create([
|
||||
'user_id' => $user->id,
|
||||
'user_id' => $user->id,
|
||||
'send_user_id' => $sender->id,
|
||||
'email' => $user->email,
|
||||
'subject' => $data['subject'],
|
||||
'message' => $data['message']." ".$data['message_last'],
|
||||
'message' => $data['message'] . " " . $data['message_last'],
|
||||
]);
|
||||
try{
|
||||
if($status >= 34){
|
||||
Mail::to($user->email)->locale($user->getLocale())->bcc(config('app.default_mail'))->send(new MailCustomMessage($user, $data, $sender, false));
|
||||
}else{
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailCustomMessage($user, $data, $sender, false));
|
||||
|
||||
try {
|
||||
if(!Util::isTestSystem()){
|
||||
if($status >= 34){
|
||||
Log::channel('cron')->info('Sende kritische Erinnerung mit BCC an: ' . $user->email);
|
||||
Mail::to($user->email)
|
||||
->locale($user->getLocale())
|
||||
->bcc(config('app.default_mail'))
|
||||
->send(new MailCustomMessage($user, $data, $sender, false));
|
||||
} else {
|
||||
Log::channel('cron')->info('Sende normale Erinnerung an: ' . $user->email);
|
||||
Mail::to($user->email)
|
||||
->locale($user->getLocale())
|
||||
->send(new MailCustomMessage($user, $data, $sender, false));
|
||||
}
|
||||
} else {
|
||||
Log::channel('cron')->info('Testsystem: E-Mail-Versand simuliert für: ' . $user->email);
|
||||
}
|
||||
}
|
||||
catch(\Exception $e){
|
||||
\Log::channel('cron')->error('Mail Error: '.$e->getMessage());
|
||||
// Never reached
|
||||
} catch(\Exception $e) {
|
||||
Log::channel('cron')->error('Mail-Fehler für Benutzer ' . $user->email . ': ' . $e->getMessage());
|
||||
|
||||
$customer_mail->fail = true;
|
||||
$customer_mail->error = $e->getMessage();
|
||||
$customer_mail->save();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$customer_mail->send = true;
|
||||
$customer_mail->sent_at = now();
|
||||
$customer_mail->save();
|
||||
|
||||
Log::channel('cron')->info('Erinnerungsmail erfolgreich gesendet an: ' . $user->email);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function buyProductAboPayment($user, $product){
|
||||
/**
|
||||
* Kauft ein Produkt mit Abo-Zahlung
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @param object $product Produkt
|
||||
* @return void
|
||||
*/
|
||||
private function buyProductAboPayment($user, $product)
|
||||
{
|
||||
Log::channel('cron')->info('Starte Abo-Produktkauf für Benutzer: ' . $user->email);
|
||||
$paymentHelper = new PaymentHelper();
|
||||
$paymentHelper->setProduct($product);
|
||||
$paymentHelper->initELVPayment($user);
|
||||
Log::channel('cron')->info('Abo-Produktkauf abgeschlossen für: ' . $user->email);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Führt das Cron-Script aus
|
||||
*
|
||||
* @param string $key Sicherheitsschlüssel
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function runCron($key)
|
||||
{
|
||||
if($key !== 'G8ZvEbnP8fEPfnWX4L'){
|
||||
Log::channel('cron')->info('Cron-Script-Ausführung angefordert');
|
||||
|
||||
if($key !== self::RUN_CRON_KEY){
|
||||
Log::channel('cron')->warning('Ungültiger Cron-Script-Key verwendet: ' . $key);
|
||||
abort(404);
|
||||
}
|
||||
if(Util::isTestSystem()){
|
||||
exec("/bin/bash ../cron_script_local.sh 2>&1", $out, $result);
|
||||
}else{
|
||||
exec("/bin/bash ../cron_script_server.sh 2>&1", $out, $result);
|
||||
}
|
||||
echo "Returncode: " .$result ."<br>";
|
||||
echo "Ausgabe des Scripts: " ."<br>";
|
||||
|
||||
$scriptPath = Util::isTestSystem() ? '../cron_script_local.sh' : '../cron_script_server.sh';
|
||||
Log::channel('cron')->info('Führe Script aus: ' . $scriptPath);
|
||||
|
||||
exec("/bin/bash {$scriptPath} 2>&1", $out, $result);
|
||||
|
||||
Log::channel('cron')->info('Cron-Script-Ausführung abgeschlossen mit Code: ' . $result);
|
||||
|
||||
echo "Returncode: " . $result . "<br>";
|
||||
echo "Ausgabe des Scripts: " . "<br>";
|
||||
echo "<pre>"; print_r($out);
|
||||
|
||||
exit;
|
||||
|
||||
/*return response()->view('cron.result', [
|
||||
'result' => $result,
|
||||
'output' => $out
|
||||
]);*/
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ 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',
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class FileController extends Controller
|
|||
|
||||
|
||||
if(!Storage::disk($disk)->exists($path)){
|
||||
// return Response::make('File no found.', 404);
|
||||
return Response::make('Datei nicht gefunden.', 404);
|
||||
}
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Image;
|
||||
use Request;
|
||||
use Validator;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductImage;
|
||||
use App\Repositories\ProductRepository;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ class ImportProductController extends Controller
|
|||
|
||||
public function import(){
|
||||
|
||||
dd('nicht aktiv, wenn muss geprüft werden, ob die funktion IMAGE existieren');
|
||||
$path = app_path().'/../_static/products/';
|
||||
|
||||
include($path.'_all_products.php');
|
||||
|
|
@ -73,7 +75,7 @@ class ImportProductController extends Controller
|
|||
$name = \App\Services\Slim::sanitizeFileName($image['image']);
|
||||
$name = uniqid() . '_' . $name;
|
||||
|
||||
$img = \Image::make($i_path);
|
||||
$img = Image::make($i_path);
|
||||
$img->resize(600, 800, function ($c) {
|
||||
// $c->aspectRatio();
|
||||
$c->upsize();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use App\Models\Ingredient;
|
|||
use App\Models\IqImage;
|
||||
use App\Models\ProductCategory;
|
||||
use App\Models\ProductIngredient;
|
||||
use\Request;
|
||||
use Request;
|
||||
|
||||
|
||||
class IngredientController extends Controller
|
||||
|
|
|
|||
|
|
@ -198,6 +198,9 @@ class LeadController extends Controller
|
|||
'city' => 'required',
|
||||
'email' => 'required|string|email|max:255|exists:users,email',
|
||||
'email-confirm' => 'required|same:email',
|
||||
'bank_owner' => 'required',
|
||||
'bank_iban' => 'required',
|
||||
'bank_bic' => 'required',
|
||||
);
|
||||
if(!Request::get('same_as_billing')){
|
||||
$rules = array_merge($rules, [
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ namespace App\Http\Controllers;
|
|||
use Request;
|
||||
use App\User;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserAbo;
|
||||
use App\Models\Homeparty;
|
||||
use App\Models\UserLevel;
|
||||
|
||||
use App\Models\UserLevel;
|
||||
use App\Models\UserCredit;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Services\HTMLHelper;
|
||||
|
|
@ -99,7 +100,7 @@ class ModalController extends Controller
|
|||
$homeparty = Homeparty::find($data['id']);
|
||||
$homeparty_user = HomepartyUser::find($data['user_id']);
|
||||
$data['homeparty'] = $homeparty;
|
||||
$ret = view("user.homeparty.modal_show_products", compact( 'data', 'homeparty', 'homeparty_user'))->render();
|
||||
$ret = view("user.homeparty.modal_hp_show_products", compact( 'data', 'homeparty', 'homeparty_user'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-level-edit'){
|
||||
|
|
@ -153,6 +154,20 @@ class ModalController extends Controller
|
|||
$UserCredit = UserCredit::find($data['id']); //current user form order
|
||||
$ret = view("admin.payment.modal_credit_status", compact('UserCredit', 'data'))->render();
|
||||
}
|
||||
if($data['action'] === 'abo_update_settings'){
|
||||
$user_abo = UserAbo::find($data['id']);
|
||||
if($data['view'] === 'admin'){
|
||||
$route = route('admin_abos_update', [$user_abo->id]);
|
||||
}else{
|
||||
$route = route('user_abos_update', [$data['view'], $user_abo->id]);
|
||||
}
|
||||
$ret = view("admin.abo.modal_abo_update", compact('user_abo', 'data', 'route'))->render();
|
||||
}
|
||||
if($data['action'] === 'abo-add-product') {
|
||||
$user_abo = UserAbo::find($data['id']);
|
||||
$ret = view("user.abo.modal_abo_show_products", compact( 'data', 'user_abo'))->render();
|
||||
}
|
||||
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,48 @@ class PayoneController extends Controller
|
|||
public function getShoppingPayment(){
|
||||
return $this->shopping_payment;
|
||||
}
|
||||
public function setAboPayment($user_abo, $amount, $currency){
|
||||
$this->reference = substr(uniqid('m', false), 0, 16);
|
||||
|
||||
$this->method = [
|
||||
"clearingtype" => $user_abo->clearingtype,
|
||||
"wallettype" => $user_abo->wallettype,
|
||||
"pseudocardpan" => isset($user_abo->carddata['pseudocardpan']) ? $user_abo->carddata['pseudocardpan'] : '',
|
||||
"cardexpiredate" => isset($user_abo->carddata['cardexpiredate']) ? $user_abo->carddata['cardexpiredate'] : '',
|
||||
'userid' => $user_abo->payone_userid,
|
||||
'onlinebanktransfertype' => '',
|
||||
"request" => "authorization",
|
||||
];
|
||||
|
||||
|
||||
$this->aboInitPayment = [
|
||||
'recurrence'=>'recurring',
|
||||
'customer_is_present'=>'no',
|
||||
'request' => 'authorization',
|
||||
'amount' => $amount
|
||||
];
|
||||
|
||||
$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,
|
||||
];
|
||||
|
||||
$this->shopping_payment = ShoppingPayment::create([
|
||||
'shopping_order_id' => $this->shopping_order->id,
|
||||
'clearingtype' => $this->method["clearingtype"],
|
||||
'wallettype' => $this->method["wallettype"],
|
||||
'onlinebanktransfertype' => $this->method["onlinebanktransfertype"],
|
||||
'carddata' => $user_abo->carddata,
|
||||
'reference' => $this->reference,
|
||||
'amount' => $amount,
|
||||
'currency' => $currency,
|
||||
'is_abo' => $this->shopping_order->is_abo,
|
||||
'abo_interval' => 0,
|
||||
'mode' => $this->shopping_order->mode,
|
||||
]);
|
||||
}
|
||||
//make Payone payment
|
||||
public function setPrePayment($payment_method, $amount, $currency, $ret = []){
|
||||
|
||||
|
|
@ -87,7 +128,7 @@ class PayoneController extends Controller
|
|||
$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]),
|
||||
];
|
||||
|
|
@ -100,10 +141,30 @@ class PayoneController extends Controller
|
|||
];
|
||||
//init Abo
|
||||
if($this->shopping_order->is_abo){
|
||||
$this->aboInitPayment = [
|
||||
'recurrence'=>'recurring',
|
||||
'customer_is_present'=>'yes'
|
||||
];
|
||||
if($this->method["clearingtype"] === "cc"){
|
||||
$this->aboInitPayment = [
|
||||
'recurrence'=>'recurring',
|
||||
'customer_is_present'=>'yes',
|
||||
'request' => 'authorization',
|
||||
'amount' => $amount,
|
||||
];
|
||||
$this->method['request'] = 'authorization';
|
||||
|
||||
}
|
||||
|
||||
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->shopping_payment = ShoppingPayment::create([
|
||||
|
|
@ -111,11 +172,13 @@ class PayoneController extends Controller
|
|||
'clearingtype' => $this->method["clearingtype"],
|
||||
'wallettype' => $this->method["wallettype"],
|
||||
'onlinebanktransfertype' => $this->method["onlinebanktransfertype"],
|
||||
'carddata' => isset($ret['cc']) ? $ret['cc'] : null,
|
||||
'reference' => $this->reference,
|
||||
'amount' => $amount,
|
||||
'currency' => $currency,
|
||||
'is_abo' => $this->shopping_order->is_abo,
|
||||
'abo_interval' => $this->shopping_order->abo_interval,
|
||||
'identifier' => Util::getUserShopIdentifier(),
|
||||
'mode' => $this->shopping_order->mode,
|
||||
]);
|
||||
|
||||
|
|
@ -163,6 +226,8 @@ class PayoneController extends Controller
|
|||
'onlinebanktransfertype' => "",
|
||||
"request" => "authorization"
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
//Online-Überweisung
|
||||
if($payment_method[0] === 'sb'){
|
||||
|
|
@ -240,17 +305,17 @@ class PayoneController extends Controller
|
|||
}
|
||||
|
||||
public function onlyPaymentResponse(){
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->aboInitPayment, $this->prepayment, $this->urls);
|
||||
$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(){
|
||||
public function ResponseData($is_abo = false){
|
||||
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->aboInitPayment, $this->prepayment, $this->urls);
|
||||
$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'){
|
||||
|
||||
$payt = PaymentTransaction::create([
|
||||
'shopping_payment_id' => $this->shopping_payment->id,
|
||||
'request' => $this->method['request'],
|
||||
|
|
@ -262,6 +327,9 @@ class PayoneController extends Controller
|
|||
'mode' => $this->shopping_payment->mode,
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>5]);
|
||||
if($is_abo){
|
||||
return $this->reference;
|
||||
}
|
||||
return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference]));
|
||||
exit;
|
||||
}
|
||||
|
|
@ -271,6 +339,12 @@ class PayoneController extends Controller
|
|||
* status APPROVED / REDIRECT / ERROR / PENDING
|
||||
*/
|
||||
if($response['status'] === 'ERROR'){
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'PayPal Preauthorization Fehler: ' . $response['errormessage'],
|
||||
$response
|
||||
);
|
||||
PaymentTransaction::create([
|
||||
'shopping_payment_id' => $this->shopping_payment->id,
|
||||
'request' => $this->method['request'],
|
||||
|
|
@ -281,6 +355,9 @@ class PayoneController extends Controller
|
|||
'mode' => $this->shopping_payment->mode,
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>3]);
|
||||
if($is_abo){
|
||||
return $response;
|
||||
}
|
||||
\Session::flash('errormessage', $response['errormessage']);
|
||||
\Session::flash('customermessage', $response['customermessage']);
|
||||
return redirect(route('checkout.checkout_card'));
|
||||
|
|
@ -298,6 +375,9 @@ class PayoneController extends Controller
|
|||
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>4]);
|
||||
if($is_abo){
|
||||
return $response;
|
||||
}
|
||||
return redirect()->away($response["redirecturl"]);
|
||||
exit;
|
||||
|
||||
|
|
@ -316,6 +396,9 @@ class PayoneController extends Controller
|
|||
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>5]);
|
||||
if($is_abo){
|
||||
return $response;
|
||||
}
|
||||
|
||||
if($payt->shopping_payment->clearingtype === "vor"){
|
||||
//vorkasse
|
||||
|
|
@ -335,7 +418,6 @@ class PayoneController extends Controller
|
|||
exit;
|
||||
}
|
||||
|
||||
|
||||
var_dump($response);
|
||||
die();
|
||||
//txid
|
||||
|
|
@ -407,6 +489,27 @@ 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{
|
||||
$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)
|
||||
{
|
||||
|
|
@ -492,17 +595,7 @@ class PayoneController extends Controller
|
|||
|
||||
|
||||
|
||||
public function setDeliverylData($data){
|
||||
$this->deliveryData = [
|
||||
"shipping_company" => "Mr.",
|
||||
"shipping_firstname" => "Henry",
|
||||
"shipping_lastname" => "Tudor",
|
||||
"shipping_street" => "Royal Street 1",
|
||||
"shipping_zip" => "24118",
|
||||
"shipping_city" => "Kiel",
|
||||
"shipping_country" => "DE",
|
||||
];
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -41,24 +41,25 @@ class PaymentCreditController extends Controller
|
|||
}
|
||||
|
||||
|
||||
public function store(){
|
||||
public function store()
|
||||
{
|
||||
$data = Request::all();
|
||||
if(isset($data['action']) && $data['action'] === 'add-user-credit'){
|
||||
if(!isset($data['member_id']) || !$user = User::find($data['member_id'])){
|
||||
if (isset($data['action']) && $data['action'] === 'add-user-credit') {
|
||||
if (!isset($data['member_id']) || !$user = User::find($data['member_id'])) {
|
||||
\Session()->flash('alert-error', 'Vertriebspartner nicht gefunden');
|
||||
return back();
|
||||
}
|
||||
if(!isset($data['credit'])){
|
||||
if (!isset($data['credit'])) {
|
||||
\Session()->flash('alert-error', 'Bitte Betrag eingeben');
|
||||
return back();
|
||||
}
|
||||
if(!isset($data['message'])){
|
||||
if (!isset($data['message'])) {
|
||||
\Session()->flash('alert-error', 'Bitte Betreff eingeben');
|
||||
return back();
|
||||
}
|
||||
|
||||
$credit = Util::reFormatNumber($data['credit']);
|
||||
$credit = number_format($credit, 2, '.', '');
|
||||
$credit = number_format($credit, 2, '.', '');
|
||||
Payment::addUserCreditMargin($user, $credit, 3, $data['message']);
|
||||
\Session()->flash('alert-success', "Guthaben hinzugefügt");
|
||||
}
|
||||
|
|
@ -66,11 +67,12 @@ class PaymentCreditController extends Controller
|
|||
return redirect(route('admin_payments_credit'));
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
$data = Request::all();
|
||||
if(isset($data['action'])){
|
||||
if($data['action'] === 'create_credit'){
|
||||
if(!isset($data['userid'])){
|
||||
if (isset($data['action'])) {
|
||||
if ($data['action'] === 'create_credit') {
|
||||
if (!isset($data['userid'])) {
|
||||
abort(404);
|
||||
}
|
||||
$user = User::findOrFail($data['userid']);
|
||||
|
|
@ -79,7 +81,7 @@ class PaymentCreditController extends Controller
|
|||
\Session()->flash('alert-success', "Gutschrift erstellt");
|
||||
return redirect($data['back']);
|
||||
}
|
||||
if($data['action'] === 'user-credit-status'){
|
||||
if ($data['action'] === 'user-credit-status') {
|
||||
$UserCredit = UserCredit::findOrFail($data['id']);
|
||||
$UserCredit->status = $data['status'];
|
||||
$UserCredit->save();
|
||||
|
|
@ -89,34 +91,38 @@ class PaymentCreditController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
if(!session('credit_filter_month')){
|
||||
private function setFilterVars()
|
||||
{
|
||||
if (!session('credit_filter_month')) {
|
||||
session(['credit_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('credit_filter_year')){
|
||||
if (!session('credit_filter_year')) {
|
||||
session(['credit_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(Request::get('credit_filter_name')){
|
||||
if (Request::get('credit_filter_name')) {
|
||||
session(['credit_filter_name' => Request::get('credit_filter_name')]);
|
||||
} else {
|
||||
session(['credit_filter_name' => '']);
|
||||
}
|
||||
if(Request::get('credit_filter_month')){
|
||||
if (Request::get('credit_filter_month')) {
|
||||
session(['credit_filter_month' => Request::get('credit_filter_month')]);
|
||||
}
|
||||
if(Request::get('credit_filter_year')){
|
||||
if (Request::get('credit_filter_year')) {
|
||||
session(['credit_filter_year' => Request::get('credit_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
||||
private function makeUserCreditItems(){
|
||||
private function makeUserCreditItems()
|
||||
{
|
||||
$ret = [];
|
||||
$UserCreditItems = UserCreditItem::wherePaid(false)->get();
|
||||
foreach($UserCreditItems as $userCreditItem){
|
||||
if(isset($ret[$userCreditItem->user_id])){
|
||||
foreach ($UserCreditItems as $userCreditItem) {
|
||||
if (isset($ret[$userCreditItem->user_id])) {
|
||||
$ret[$userCreditItem->user_id]['sum'] += $userCreditItem->credit;
|
||||
$ret[$userCreditItem->user_id]['entries'][$userCreditItem->id] = $userCreditItem;
|
||||
}else{
|
||||
if(!isset($userCreditItem->user)){
|
||||
/* gelöschte User nicht anzeigen
|
||||
} else {
|
||||
if (!isset($userCreditItem->user)) {
|
||||
/* gelöschte User nicht anzeigen
|
||||
$user = User::withTrashed()->with(['account' => fn($q) => $q->withTrashed()])->where('id', $userCreditItem->user_id)->first();
|
||||
$ret[$userCreditItem->user_id] = [
|
||||
'user_id' => $userCreditItem->user_id,
|
||||
|
|
@ -128,7 +134,7 @@ class PaymentCreditController extends Controller
|
|||
'entries' => [$userCreditItem->id => $userCreditItem],
|
||||
];
|
||||
*/
|
||||
}else{
|
||||
} else {
|
||||
$ret[$userCreditItem->user_id] = [
|
||||
'user_id' => $userCreditItem->user_id,
|
||||
'm_account' => $userCreditItem->user->account->m_account,
|
||||
|
|
@ -138,20 +144,21 @@ class PaymentCreditController extends Controller
|
|||
'sum' => $userCreditItem->credit,
|
||||
'entries' => [$userCreditItem->id => $userCreditItem],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id, $del){
|
||||
public function delete($id, $del)
|
||||
{
|
||||
|
||||
if($del === 'user_credit_item'){
|
||||
if ($del === 'user_credit_item') {
|
||||
$UserCreditItem = UserCreditItem::findOrFail($id);
|
||||
if($deleteTime = $UserCreditItem->deleteTime()){
|
||||
if ($deleteTime = $UserCreditItem->deleteTime()) {
|
||||
$UserCreditItem->delete();
|
||||
\Session()->flash('alert-success', "Guthaben ist gelöscht");
|
||||
}else{
|
||||
} else {
|
||||
\Session()->flash('alert-error', "Guthaben kann nicht gelöscht werden");
|
||||
}
|
||||
}
|
||||
|
|
@ -160,24 +167,25 @@ class PaymentCreditController extends Controller
|
|||
|
||||
private function initSearch($archive = false, $request = true)
|
||||
{
|
||||
|
||||
|
||||
$this->setFilterVars();
|
||||
|
||||
$date_start = Carbon::parse('01.'.Request::get('credit_filter_month').'.'.Request::get('credit_filter_year'))->format('Y-m-d');
|
||||
$date_end = Carbon::parse('01.'.Request::get('credit_filter_month').'.'.Request::get('credit_filter_year'))->endOfMonth()->format('Y-m-d');
|
||||
$date_start = Carbon::parse('01.' . Request::get('credit_filter_month') . '.' . Request::get('credit_filter_year'))->format('Y-m-d');
|
||||
$date_end = Carbon::parse('01.' . Request::get('credit_filter_month') . '.' . Request::get('credit_filter_year'))->endOfMonth()->format('Y-m-d');
|
||||
$query = UserCredit::with('user', 'user.account')->select('user_credits.*')
|
||||
->whereBetween('date', [$date_start, $date_end]);
|
||||
|
||||
if(Request::get('credit_filter_name')){
|
||||
->whereBetween('date', [$date_start, $date_end]);
|
||||
|
||||
if (Request::get('credit_filter_name')) {
|
||||
$query->whereHas('user.account', function ($query) {
|
||||
return $query->where('first_name', 'LIKE', '%'.Request::get('credit_filter_name').'%')
|
||||
->orWhere('last_name', 'LIKE', '%'.Request::get('credit_filter_name').'%');
|
||||
});
|
||||
return $query->where('first_name', 'LIKE', '%' . Request::get('credit_filter_name') . '%')
|
||||
->orWhere('last_name', 'LIKE', '%' . Request::get('credit_filter_name') . '%');
|
||||
});
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = $this->initSearch();
|
||||
|
||||
|
|
@ -194,57 +202,54 @@ class PaymentCreditController extends Controller
|
|||
})
|
||||
->addColumn('view', function (UserCredit $UserCredit) {
|
||||
$ret = "";
|
||||
if($UserCredit->isCredit()){
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a><br>';
|
||||
if ($UserCredit->isCredit()) {
|
||||
$ret .= '<a href="' . route('storage_file', [$UserCredit->id, 'credit', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserCredit->id, 'credit', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a><br>';
|
||||
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'html']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-eye"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'pdf']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-file-pdf" style="min-width:13.5px"></i></a> ';
|
||||
|
||||
|
||||
}else{
|
||||
$ret .= '<a href="' . route('storage_file', [$UserCredit->id, 'credit_detail', 'html']) . '" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-eye"></i></a> ';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserCredit->id, 'credit_detail', 'pdf']) . '" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-file-pdf" style="min-width:13.5px"></i></a> ';
|
||||
} else {
|
||||
$ret = "-";
|
||||
}
|
||||
return $ret;
|
||||
})
|
||||
|
||||
->addColumn('total', function (UserCredit $UserCredit) {
|
||||
return '<span class="no-line-break">'.$UserCredit->getFormattedTotal()." €</span>";
|
||||
return '<span class="no-line-break">' . $UserCredit->getFormattedTotal() . " €</span>";
|
||||
})
|
||||
->addColumn('credits', function (UserCredit $UserCredit) {
|
||||
$ret = "";
|
||||
if($UserCredit->user_credit_items){
|
||||
foreach($UserCredit->user_credit_items as $user_credit_item){
|
||||
$ret .= nl2br($user_credit_item->getTransMessage())." / ".$user_credit_item->created_at->format('d.m.Y')."<br>";
|
||||
|
||||
if ($UserCredit->user_credit_items) {
|
||||
foreach ($UserCredit->user_credit_items as $user_credit_item) {
|
||||
$ret .= nl2br($user_credit_item->getTransMessage()) . " / " . $user_credit_item->created_at->format('d.m.Y') . "<br>";
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
})
|
||||
->addColumn('status', function (UserCredit $UserCredit) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-load-content" data-modal="modal-lg"
|
||||
data-id="'.$UserCredit->id.'" data-route="'.route('modal_load').'" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-'.$UserCredit->getStatusColor().'">'.$UserCredit->getStatusType().' <span class="ion ion-md-cash"></span></span>
|
||||
data-id="' . $UserCredit->id . '" data-route="' . route('modal_load') . '" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-' . $UserCredit->getStatusColor() . '">' . $UserCredit->getStatusType() . ' <span class="ion ion-md-cash"></span></span>
|
||||
</a>';
|
||||
})
|
||||
->filterColumn('user.account.first_name', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
->filterColumn('user.account.first_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('user.account', function ($query) use ($keyword) {
|
||||
return $query->where('first_name', 'LIKE', '%'.$keyword.'%');
|
||||
return $query->where('first_name', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
})
|
||||
->filterColumn('user.account.last_name', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
->filterColumn('user.account.last_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('user.account', function ($query) use ($keyword) {
|
||||
return $query->where('last_name', 'LIKE', '%'.$keyword.'%');
|
||||
return $query->where('last_name', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
})
|
||||
->filterColumn('user.email', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
->filterColumn('user.email', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('user', function ($query) use ($keyword) {
|
||||
return $query->where('email', 'LIKE', '%'.$keyword.'%');
|
||||
return $query->where('email', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
})
|
||||
|
|
@ -254,4 +259,4 @@ class PaymentCreditController extends Controller
|
|||
->rawColumns(['total', 'credits', 'status', 'view'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Services\Payment;
|
||||
|
|
@ -19,7 +20,7 @@ class PaymentInvoiceController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
|
||||
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
|
|
@ -28,21 +29,24 @@ class PaymentInvoiceController extends Controller
|
|||
return view('admin.payment.invoice', $data);
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if(!session('invoice_filter_month')){
|
||||
if (!session('invoice_filter_month')) {
|
||||
session(['invoice_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('invoice_filter_year')){
|
||||
if (!session('invoice_filter_year')) {
|
||||
session(['invoice_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(Request::get('invoice_filter_name')){
|
||||
if (Request::get('invoice_filter_name')) {
|
||||
session(['invoice_filter_name' => Request::get('invoice_filter_name')]);
|
||||
} else {
|
||||
session(['invoice_filter_name' => '']);
|
||||
}
|
||||
if(Request::get('invoice_filter_month')){
|
||||
if (Request::get('invoice_filter_month')) {
|
||||
session(['invoice_filter_month' => Request::get('invoice_filter_month')]);
|
||||
}
|
||||
if(Request::get('invoice_filter_year')){
|
||||
if (Request::get('invoice_filter_year')) {
|
||||
session(['invoice_filter_year' => Request::get('invoice_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
|
@ -50,53 +54,53 @@ class PaymentInvoiceController extends Controller
|
|||
private function initSearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('invoice_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if(Request::get('invoice_filter_name')){
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('invoice_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if (Request::get('invoice_filter_name')) {
|
||||
$query->whereHas('shopping_order.shopping_user', function ($query) {
|
||||
return $query->where('billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%')->orWhere('billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%')->orWhere('billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
return $query->where('billing_firstname', 'LIKE', '%' . Request::get('invoice_filter_name') . '%')->orWhere('billing_lastname', 'LIKE', '%' . Request::get('invoice_filter_name') . '%')->orWhere('billing_email', 'LIKE', '%' . Request::get('invoice_filter_name') . '%');
|
||||
})->get();
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = $this->initSearch();
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order->auth_user_id){
|
||||
if ($UserInvoice->shopping_order->auth_user_id) {
|
||||
return '<a href="' . route('admin_sales_users_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
}
|
||||
return '<a href="' . route('admin_sales_customers_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
|
||||
})
|
||||
->addColumn('total_shipping', function (UserInvoice $UserInvoice) {
|
||||
return '<span class="no-line-break">'.$UserInvoice->shopping_order->getFormattedTotalShipping()." €</span>";
|
||||
return '<span class="no-line-break">' . $UserInvoice->shopping_order->getFormattedTotalShipping() . " €</span>";
|
||||
})
|
||||
->addColumn('created_at', function (UserInvoice $UserInvoice) {
|
||||
return $UserInvoice->created_at->format("d.m.Y");
|
||||
})
|
||||
->addColumn('txaction', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order){
|
||||
if ($UserInvoice->shopping_order) {
|
||||
return Payment::getShoppingOrderBadge($UserInvoice->shopping_order);
|
||||
}
|
||||
return "-";
|
||||
})
|
||||
->addColumn('status', function (UserInvoice $UserInvoice) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-load-content" data-modal="modal-lg"
|
||||
data-id="'.$UserInvoice->id.'" data-route="'.route('modal_load').'" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-'.$UserInvoice->getStatusColor().'">'.$UserInvoice->getStatusType().'</span>
|
||||
data-id="' . $UserInvoice->id . '" data-route="' . route('modal_load') . '" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-' . $UserInvoice->getStatusColor() . '">' . $UserInvoice->getStatusType() . '</span>
|
||||
</a>';
|
||||
})
|
||||
->addColumn('invoice', function (UserInvoice $UserInvoice) {
|
||||
$ret = "";
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
return $ret;
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
|
|
@ -110,4 +114,4 @@ class PaymentInvoiceController extends Controller
|
|||
->rawColumns(['id', 'shipping_order', 'txaction', 'total_shipping', 'status', 'txaction', 'invoice'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Services\Payment;
|
||||
|
|
@ -32,21 +33,24 @@ class PaymentPointsController extends Controller
|
|||
return view('admin.payment.invoice', $data);
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if(!session('invoice_filter_month')){
|
||||
if (!session('invoice_filter_month')) {
|
||||
session(['invoice_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('invoice_filter_year')){
|
||||
if (!session('invoice_filter_year')) {
|
||||
session(['invoice_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(Request::get('invoice_filter_name')){
|
||||
if (Request::get('invoice_filter_name')) {
|
||||
session(['invoice_filter_name' => Request::get('invoice_filter_name')]);
|
||||
} else {
|
||||
session(['invoice_filter_name' => '']);
|
||||
}
|
||||
if(Request::get('invoice_filter_month')){
|
||||
if (Request::get('invoice_filter_month')) {
|
||||
session(['invoice_filter_month' => Request::get('invoice_filter_month')]);
|
||||
}
|
||||
if(Request::get('invoice_filter_year')){
|
||||
if (Request::get('invoice_filter_year')) {
|
||||
session(['invoice_filter_year' => Request::get('invoice_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
|
@ -54,59 +58,59 @@ class PaymentPointsController extends Controller
|
|||
private function initSearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('invoice_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if(Request::get('invoice_filter_name')){
|
||||
$query->where('shopping_order.shopping_user.billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->where('shopping_order.shopping_user.billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->where('shopping_order.shopping_user.billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('invoice_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if (Request::get('invoice_filter_name')) {
|
||||
$query->where('shopping_order.shopping_user.billing_firstname', 'LIKE', '%' . Request::get('invoice_filter_name') . '%');
|
||||
$query->where('shopping_order.shopping_user.billing_lastname', 'LIKE', '%' . Request::get('invoice_filter_name') . '%');
|
||||
$query->where('shopping_order.shopping_user.billing_email', 'LIKE', '%' . Request::get('invoice_filter_name') . '%');
|
||||
}
|
||||
|
||||
//->orderBy('created_at', 'DESC');
|
||||
/* $query = FlexHour::leftJoin("flex_hour_items", function($join) {
|
||||
/* $query = FlexHour::leftJoin("flex_hour_items", function($join) {
|
||||
$join->on("flex_hour_items.flex_hour_id","=","flex_hours.id");
|
||||
$join->where("flex_hour_items.date","=", FlexHourItemBot::$date);
|
||||
})*/
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = $this->initSearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order->auth_user_id){
|
||||
if ($UserInvoice->shopping_order->auth_user_id) {
|
||||
return '<a href="' . route('admin_sales_users_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
}
|
||||
return '<a href="' . route('admin_sales_customers_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
|
||||
})
|
||||
->addColumn('total_shipping', function (UserInvoice $UserInvoice) {
|
||||
return '<span class="no-line-break">'.$UserInvoice->shopping_order->getFormattedTotalShipping()." €</span>";
|
||||
return '<span class="no-line-break">' . $UserInvoice->shopping_order->getFormattedTotalShipping() . " €</span>";
|
||||
})
|
||||
->addColumn('created_at', function (UserInvoice $UserInvoice) {
|
||||
return $UserInvoice->created_at->format("d.m.Y");
|
||||
})
|
||||
->addColumn('txaction', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order){
|
||||
if ($UserInvoice->shopping_order) {
|
||||
return Payment::getShoppingOrderBadge($UserInvoice->shopping_order);
|
||||
}
|
||||
return "-";
|
||||
})
|
||||
->addColumn('status', function (UserInvoice $UserInvoice) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-load-content" data-modal="modal-lg"
|
||||
data-id="'.$UserInvoice->id.'" data-route="'.route('modal_load').'" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-'.$UserInvoice->getStatusColor().'">'.$UserInvoice->getStatusType().'</span>
|
||||
data-id="' . $UserInvoice->id . '" data-route="' . route('modal_load') . '" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-' . $UserInvoice->getStatusColor() . '">' . $UserInvoice->getStatusType() . '</span>
|
||||
</a>';
|
||||
})
|
||||
->addColumn('invoice', function (UserInvoice $UserInvoice) {
|
||||
$ret = "";
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
|
||||
$ret .= '<a href="' . route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
|
||||
return $ret;
|
||||
})
|
||||
|
||||
|
|
@ -118,4 +122,4 @@ class PaymentPointsController extends Controller
|
|||
->rawColumns(['id', 'shipping_order', 'txaction', 'total_shipping', 'status', 'txaction', 'invoice'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class SalesController extends Controller
|
|||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
|
||||
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>
|
||||
|
|
@ -132,9 +132,17 @@ class SalesController extends Controller
|
|||
set_user_attr('filter_member_id', null);
|
||||
return redirect(route('admin_sales_customers'));
|
||||
}
|
||||
$filter_user_shops = ShoppingOrder::join('user_shops', 'user_shop_id', '=', 'user_shops.id')->orderBy('slug')->get()->pluck('slug', 'id')->unique()->toArray();
|
||||
$filter_user_shops = ShoppingOrder::select('user_shops.id', 'user_shops.slug')
|
||||
->join('user_shops', 'shopping_orders.user_shop_id', '=', 'user_shops.id')
|
||||
->orderBy('user_shops.slug')
|
||||
->distinct()
|
||||
->pluck('slug', 'id')
|
||||
->toArray();
|
||||
$filter_members = ShoppingOrder::join('users', 'member_id', '=', 'users.id')->groupBy('member_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get();
|
||||
//->pluck('email', 'id')->unique()->toArray();
|
||||
|
||||
|
||||
|
||||
$data = [
|
||||
'filter_user_shops' => $filter_user_shops,
|
||||
'filter_members' => $filter_members,
|
||||
|
|
@ -270,7 +278,7 @@ class SalesController extends Controller
|
|||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
|
||||
if(($ShoppingOrder->txaction === 'extern' || $ShoppingOrder->txaction === 'extern_paid') && $ShoppingOrder->wp_invoice_path){
|
||||
|
|
@ -365,11 +373,13 @@ class SalesController extends Controller
|
|||
if(isset($data['action'])){
|
||||
if($data['action'] === 'create_invoice'){
|
||||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if($shopping_order->isInvoice()){
|
||||
$invoice_repo->update($data);
|
||||
}else{
|
||||
$invoice_repo->createAndSalesVolume($data);
|
||||
if($shopping_order->mode === 'live'){
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if($shopping_order->isInvoice()){
|
||||
$invoice_repo->update($data);
|
||||
}else{
|
||||
$invoice_repo->createAndSalesVolume($data);
|
||||
}
|
||||
}
|
||||
if(isset($data['view']) && $data['view'] === 'sales_customer'){
|
||||
return redirect(route('admin_sales_customers_detail', [$shopping_order->id]));
|
||||
|
|
|
|||
322
app/Http/Controllers/User/AboController.php
Normal file
322
app/Http/Controllers/User/AboController.php
Normal file
|
|
@ -0,0 +1,322 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserAbo;
|
||||
use App\Models\UserAboItem;
|
||||
use App\Repositories\AboRepository;
|
||||
use App\Services\AboHelper;
|
||||
use App\Services\AboOrderCart;
|
||||
use App\Services\Shop;
|
||||
use App\Services\UserService;
|
||||
use App\User;
|
||||
use Request;
|
||||
use Yard;
|
||||
|
||||
class AboController extends Controller
|
||||
{
|
||||
protected $aboRepository;
|
||||
|
||||
public function __construct(AboRepository $aboRepository)
|
||||
{
|
||||
$this->middleware('active.account');
|
||||
$this->aboRepository = $aboRepository;
|
||||
}
|
||||
|
||||
public function index($view)
|
||||
{
|
||||
|
||||
if ($view === 'me') {
|
||||
// Nur Abos des aktuellen Benutzers
|
||||
$user_abos = UserAbo::where('user_id', \Auth::user()->id)
|
||||
->where('status', '>', 1);
|
||||
|
||||
if ($user_abos->count() > 0) {
|
||||
return redirect(route('user_abos_detail', ['me', $user_abos->first()->id]));
|
||||
}
|
||||
|
||||
return view('user.abo.index', [
|
||||
'user_abos' => [],
|
||||
'view' => 'me',
|
||||
'isAdmin' => false
|
||||
]);
|
||||
}
|
||||
|
||||
if ($view === 'ot') {
|
||||
$user_abos = UserAbo::where('member_id', \Auth::user()->id)
|
||||
->where('status', '>', 1)
|
||||
->where('is_for', 'ot')
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
|
||||
return view('user.abo.index', [
|
||||
'user_abos' => $user_abos,
|
||||
'view' => 'ot',
|
||||
'isAdmin' => false
|
||||
]);
|
||||
}
|
||||
|
||||
// Standardfall, wenn weder 'me' noch 'ot'
|
||||
return view('user.abo.index', [
|
||||
'user_abos' => [],
|
||||
'view' => 'me',
|
||||
'isAdmin' => false
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function detail($view, $id)
|
||||
{
|
||||
$data = Request::all();
|
||||
$user_abo = UserAbo::findOrFail($id);
|
||||
|
||||
|
||||
$this->checkPermissions($view, $user_abo);
|
||||
|
||||
//init Yard
|
||||
AboOrderCart::initYard($user_abo);
|
||||
//holt die aktuellen UserAccount Daten oder die Userdaten des Abo
|
||||
$customer_detail = AboOrderCart::getCustomerDetail();
|
||||
AboOrderCart::makeOrderYard($user_abo);
|
||||
|
||||
$comp_products = [];
|
||||
if ($user_abo->is_for === 'me') {
|
||||
$comp_products = Shop::getCompProducts('abo-me');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_abo' => $user_abo,
|
||||
'isAdmin' => false,
|
||||
'customer_detail' => $customer_detail,
|
||||
'view' => $view,
|
||||
'comp_products' => $comp_products,
|
||||
];
|
||||
return view('user.abo.detail', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function update($view, $id)
|
||||
{
|
||||
$data = Request::all();
|
||||
$user_abo = UserAbo::findOrFail($id);
|
||||
|
||||
$this->checkPermissions($view, $user_abo);
|
||||
if (isset($data['action'])) {
|
||||
if ($data['action'] === 'abo_update_settings') {
|
||||
$user_abo = UserAbo::findOrFail($data['id']);
|
||||
$this->aboRepository->setModel($user_abo);
|
||||
$this->aboRepository->update($data);
|
||||
return redirect(route('user_abos_detail', [$view, $id]));
|
||||
}
|
||||
|
||||
if (Request::ajax()) {
|
||||
$message = false;
|
||||
//addProduct
|
||||
if ($data['action'] === 'addProduct') {
|
||||
if ($product = Product::find($data['product_id'])) {
|
||||
if ($UserAboItem = UserAboItem::where('user_abo_id', $user_abo->id)->where('product_id', $product->id)->where('comp', 0)->first()) {
|
||||
$UserAboItem->qty = $UserAboItem->qty + 1;
|
||||
$UserAboItem->save();
|
||||
} else {
|
||||
UserAboItem::create([
|
||||
'user_abo_id' => $user_abo->id,
|
||||
'product_id' => $product->id,
|
||||
'comp' => 0,
|
||||
'qty' => 1,
|
||||
'status' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//updateCart
|
||||
if ($data['action'] === 'updateCart') {
|
||||
//product_id | order_item_id | cart_order_id | qty
|
||||
if (isset($data['product_id']) && $product = Product::find($data['product_id'])) {
|
||||
if (isset($data['order_item_id']) && $UserAboItem = UserAboItem::find($data['order_item_id'])) {
|
||||
if (isset($data['qty'])) {
|
||||
$qty = (int) $data['qty'];
|
||||
$qty = $qty < 1 ? 1 : $qty;
|
||||
$qty = $qty > 100 ? 100 : $qty;
|
||||
$UserAboItem->qty = $qty;
|
||||
$UserAboItem->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//removeFromCart
|
||||
if ($data['action'] === 'removeFromCart') {
|
||||
if (!isset($data['product_id']) || !($product = Product::find($data['product_id']))) {
|
||||
$message = __('abo.product_not_found');
|
||||
}
|
||||
if (!isset($data['order_item_id']) || !($userAboItem = UserAboItem::find($data['order_item_id']))) {
|
||||
$message = __('abo.abo_item_not_found');
|
||||
}
|
||||
$has_basis_product = $this->check_need_basis_product($user_abo, $product, $data['order_item_id']);
|
||||
if (!$has_basis_product) {
|
||||
$message = __('abo.need_basis_product');
|
||||
}
|
||||
if (!$message) {
|
||||
|
||||
|
||||
$userAboItem->delete();
|
||||
$user_abo->refresh(); // Abo neu laden um die aktualisierten Items zu erhalten
|
||||
}
|
||||
}
|
||||
//updateCompProduct
|
||||
if ($data['action'] === 'updateCompProduct') {
|
||||
if ($UserAboItem = UserAboItem::where('user_abo_id', $user_abo->id)->where('comp', $data['comp_num'])->first()) {
|
||||
$UserAboItem->product_id = $data['comp_product_id'];
|
||||
$UserAboItem->save();
|
||||
} else {
|
||||
UserAboItem::create([
|
||||
'user_abo_id' => $user_abo->id,
|
||||
'product_id' => $data['comp_product_id'],
|
||||
'comp' => $data['comp_num'],
|
||||
'qty' => 1,
|
||||
'status' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AboOrderCart::initYard($user_abo);
|
||||
AboOrderCart::makeOrderYard($user_abo); //reCalculateShippingPrice
|
||||
AboOrderCart::checkNumOfCompProducts($user_abo); //after reCalculateShippingPrice check it and remove or add comp product
|
||||
|
||||
if ($user_abo->is_for === 'me') {
|
||||
$data['comp_products'] = Shop::getCompProducts('abo-me');
|
||||
}
|
||||
$error_message = $message ? $message : false;
|
||||
$html_cart = view("admin.abo._order_abo_show", ['user_abo' => $user_abo, 'error_message' => $error_message])->render();
|
||||
$html_comp = view("user.order.comp_product", $data)->render();
|
||||
|
||||
$amount = $user_abo->getFormattedAmount();
|
||||
|
||||
// $html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
|
||||
return response()->json(['response' => true, 'data' => $data, 'html_cart' => $html_cart, 'html_comp' => $html_comp, 'amount' => $amount]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function check_need_basis_product($user_abo, $product, $order_item_id)
|
||||
{
|
||||
// Wenn das zu entfernende Produkt kein Basis-Produkt ist, keine weitere Prüfung nötig
|
||||
if (AboHelper::getAboShowOn($product) !== 'base') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Prüfe ob noch ein anderes Basis-Produkt vorhanden ist
|
||||
foreach ($user_abo->user_abo_items as $user_abo_item) {
|
||||
if ($user_abo_item->id == $order_item_id) {
|
||||
continue;
|
||||
}
|
||||
if (AboHelper::getAboShowOn($user_abo_item->product) === 'base') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function datatable($user_abo_id)
|
||||
{
|
||||
$user_abo = UserAbo::findOrFail($user_abo_id);
|
||||
if (!$user_abo) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
//$user_abo->is_for === 'me'
|
||||
|
||||
$show_on_ids = ['12', '13'];
|
||||
$query = Product::select('products.*')
|
||||
->where('active', true)
|
||||
->where(function ($q) use ($show_on_ids) {
|
||||
foreach ($show_on_ids as $id) {
|
||||
$q->orWhereJsonContains('show_on', $id);
|
||||
}
|
||||
})
|
||||
->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]]
|
||||
);
|
||||
|
||||
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
->addColumn('add_card', function (Product $product) use ($user_abo) {
|
||||
$ufactor = $user_abo->is_for === 'me' ? true : false;
|
||||
$tax_free = $user_abo->is_for === 'me' ? true : Yard::instance('shopping')->getUserTaxFree();
|
||||
return '<button type="button" class="btn btn-sm btn-md-extra btn-secondary add-product-basket" data-product-id="' . $product->id . '">
|
||||
<strong>€ ' . $product->getFormattedPriceWith($tax_free, $ufactor, Yard::instance('shopping')->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]) . '">';
|
||||
}
|
||||
return "";
|
||||
})
|
||||
->addColumn('name', function (Product $product) use ($user_abo) {
|
||||
return '<strong>' . $product->getLang('name') . '</strong><br>' . get_abo_type_badge_by_product($product);
|
||||
})
|
||||
|
||||
->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>';
|
||||
})
|
||||
->addColumn('price_gross', function (Product $product) use ($user_abo) {
|
||||
$ufactor = $user_abo->is_for === 'me' ? true : false;
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(false, $ufactor, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, true, Yard::instance('shopping')->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-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 . '%');
|
||||
}
|
||||
})
|
||||
->orderColumn('name', 'name $1')
|
||||
->orderColumn('product', 'name $1')
|
||||
->orderColumn('number', 'number $1')
|
||||
->orderColumn('points', 'points $1')
|
||||
->orderColumn('price_net', 'price_net $1')
|
||||
->orderColumn('price_gross', 'price_gross $1')
|
||||
->orderColumn('contents_total', 'contents_total $1')
|
||||
->orderColumn('weight', 'weight $1')
|
||||
|
||||
->rawColumns(['add_card', 'product', 'name', 'quantity', 'picture', 'price_net', 'price_gross', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function checkPermissions($view, $user_abo)
|
||||
{
|
||||
if ($view === 'me' && $user_abo->is_for !== 'me') {
|
||||
abort(403, 'Unauthorized action. Is not for me');
|
||||
}
|
||||
if ($view === 'ot' && $user_abo->is_for !== 'ot') {
|
||||
abort(403, 'Unauthorized action. Is not your customer');
|
||||
}
|
||||
if ($view === 'me' && $user_abo->user_id !== \Auth::user()->id) {
|
||||
abort(403, 'Unauthorized action. Is not my abo');
|
||||
}
|
||||
if ($view === 'ot' && $user_abo->member_id !== \Auth::user()->id) {
|
||||
abort(403, 'Unauthorized action. Is not my customer abo');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,10 +5,13 @@ namespace App\Http\Controllers\User;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Repositories\CustomerRepository;
|
||||
use App\Services\AboHelper;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Services\ShoppingUserService;
|
||||
use App\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
|
@ -227,23 +230,51 @@ class CustomerController extends Controller
|
|||
return redirect(route('user_customer_detail', [$shopping_user->id]));
|
||||
}
|
||||
|
||||
|
||||
private function checkShoppingUsersByEmail(){
|
||||
|
||||
//ist an dieser stelle nicht machbar, zu viele Datenbankzugriffe
|
||||
//siehe App\Console\Commands\SyncShoppingUserData
|
||||
/* $user = User::find(\Auth::user()->id);
|
||||
ShoppingUserService::setFakerMail($user);
|
||||
ShoppingUserService::syncNumbersByEmail($user);
|
||||
ShoppingUserService::syncOrdersByEmail($user); */
|
||||
|
||||
}
|
||||
public function getCustomers()
|
||||
{
|
||||
//$this->checkShoppingUsersByEmail();
|
||||
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
//\Log::info('Current user ID: ' . $user->id);
|
||||
|
||||
$query = ShoppingUser::select(['id', 'billing_company', 'billing_salutation', 'billing_firstname', 'billing_lastname', 'billing_email', 'faker_mail', 'billing_zipcode', 'billing_city', 'billing_country_id', 'orders', 'subscribed', 'created_at', 'number', 'mode', 'is_like', 'wp_order_number'])
|
||||
->where('shopping_users.member_id', '=', $user->id);
|
||||
//->groupBy('shopping_users.number');
|
||||
->with('billing_country')
|
||||
->whereIn('id', function($query) {
|
||||
$query->select(DB::raw('MAX(id)'))
|
||||
->from('shopping_users')
|
||||
->groupBy('billing_email');
|
||||
})->where('shopping_users.member_id', '=', $user->id)->where('shopping_users.auth_user_id', '=', NULL);
|
||||
|
||||
/*set_user_attr('filter_member_id', Request::get('filter_member_id'));
|
||||
if(Request::get('filter_member_id') != ""){
|
||||
$query->where('member_id', '=', Request::get('filter_member_id'));
|
||||
}*/
|
||||
if(Request::get('isfor') === 'ot-member'){ //Bestellung für Kunden
|
||||
}
|
||||
if(Request::get('isfor') === 'ot-customer' || Request::get('isfor') === 'abo-ot-customer'){ //Bestellung für Kunden Zahlungslink
|
||||
$query->where(function($q) {
|
||||
$q->where('shopping_users.faker_mail', '!=', 1)
|
||||
->orWhereNull('shopping_users.faker_mail');
|
||||
});
|
||||
}
|
||||
//\Log::info('SQL Query: ' . $query->toSql());
|
||||
//\Log::info('Query Bindings: ' . print_r($query->getBindings(), true));
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
->addColumn('send_to', function (ShoppingUser $ShoppingUser) {
|
||||
$ot = Request::get('isfor') ? Request::get('isfor') : 'ot-member';
|
||||
if(Request::get('isfor') === 'abo-ot-customer' && AboHelper::memberHasAbo($ShoppingUser)){
|
||||
return '<span class="badge badge-pill badge-success"><i class="fa fa-check-circle"></i> '.__('abo.abo_assigned').'</span>';
|
||||
}
|
||||
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> '.__('customer.under_review').'</span>' : '<a href="' . route('user_order_my_delivery', [$ot, $ShoppingUser->id]) . '" class="btn btn-sm btn-secondary"><span class="fa fa-shopping-cart"></span> '.__('customer.select').'</a>';
|
||||
})
|
||||
->addColumn('billing_email', function (ShoppingUser $ShoppingUser) {
|
||||
|
|
@ -262,7 +293,7 @@ class CustomerController extends Controller
|
|||
return $ShoppingUser->firstEntryByNumber()->created_at->format('d.m.Y');
|
||||
})
|
||||
->addColumn('orders', function (ShoppingUser $ShoppingUser) {
|
||||
return $ShoppingUser->lastEntryByNumber()->orders;
|
||||
return $ShoppingUser->orders;
|
||||
})
|
||||
->addColumn('subscribed', function (ShoppingUser $ShoppingUser) {
|
||||
return get_active_badge($ShoppingUser->subscribed);
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@ use Request;
|
|||
use App\User;
|
||||
use App\Mail\MailInfo;
|
||||
use App\Models\Product;
|
||||
use App\Services\Payment;
|
||||
use App\Models\UserHistory;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\UserService;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingInstance;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class MembershipController extends Controller
|
||||
|
|
@ -39,11 +41,35 @@ class MembershipController extends Controller
|
|||
if($user->payment_account){
|
||||
$diff_months = Carbon::now()->diffInMonths(Carbon::parse($user->payment_account)) +1;
|
||||
}
|
||||
|
||||
$userShoppingOrders = ShoppingOrder::with('shopping_user', 'shopping_payments')->select('shopping_orders.*')
|
||||
->where('auth_user_id', '=', $user->id)
|
||||
->where('txaction', '!=', NULL)
|
||||
->whereIn('payment_for', [1, 2])
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get();
|
||||
|
||||
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_order')->get()->last();
|
||||
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->get()->last();
|
||||
$userHistoryPaymentOrder = null;
|
||||
$userHistoryUpgradeOrder = null;
|
||||
|
||||
/* Bezhalung ist nur 29 Tage vor ablauf möglich */
|
||||
/* isRenewalAccount payment_account date - config('mivita.renewal_days') Vertragsverlängerung */
|
||||
if($user->isRenewalAccount()){
|
||||
//Acount ist noch nicht verlängert / bezahlt
|
||||
if ($user->payment_account) {
|
||||
//Die Order muss größer als das Datum sein.
|
||||
$payment_greaterThan = Carbon::parse($user->payment_account)->modify('-'.(config('mivita.renewal_days')+1).' days');
|
||||
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_order')->where('created_at', '>=', $payment_greaterThan)->get()->last();
|
||||
}
|
||||
}
|
||||
if($user->isActiveAccount() && !$user->isActiveShop()){
|
||||
$payment_greaterThan = Carbon::parse($user->payment_account)->modify('-'.(config('mivita.renewal_days')+1).' days');
|
||||
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->where('created_at', '>=', $payment_greaterThan)->get()->last();
|
||||
|
||||
}
|
||||
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
|
||||
|
||||
|
||||
$shipping_country_id = $this->checkShoppingCountry($user);
|
||||
if(!$shipping_country_id){
|
||||
abort(403, __('validation.custom.shipping_not_found'));
|
||||
|
|
@ -60,6 +86,7 @@ class MembershipController extends Controller
|
|||
'userHistoryUpgradeOrder' => $userHistoryUpgradeOrder,
|
||||
'userHistoryDeleteMembership' => $userHistoryDeleteMembership,
|
||||
'yard_info' => UserService::getYardInfo(),
|
||||
'userShoppingOrders' => $userShoppingOrders,
|
||||
];
|
||||
return view('user.membership.index', $data);
|
||||
|
||||
|
|
@ -131,7 +158,7 @@ class MembershipController extends Controller
|
|||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$qty = Request::get('qty') ? Request::get('qty') : 1;
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
674
app/Http/Controllers/User/OrderController_bak.php
Normal file
674
app/Http/Controllers/User/OrderController_bak.php
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailCustomPaymet;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserHistory;
|
||||
use App\Services\AboHelper;
|
||||
use App\Services\OrderPaymentService;
|
||||
use App\Services\Payment;
|
||||
use App\Services\Shop;
|
||||
use App\Services\UserService;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Request;
|
||||
use Validator;
|
||||
use Yard;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('active.account');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
];
|
||||
return view('user.order.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->auth_user_id !== $user->id){
|
||||
abort(404);
|
||||
}
|
||||
if( $shopping_order->payment_for === 6 || $shopping_order->payment_for === 7){
|
||||
return redirect(route('user_shop_order_detail', [$shopping_order->id]));
|
||||
abort(403, 'Kundenbestellung');
|
||||
}
|
||||
$shopping_order->getLastShoppingPayment();
|
||||
|
||||
$data = [
|
||||
'shopping_order' => $shopping_order,
|
||||
'isAdmin' => false,
|
||||
];
|
||||
return view('user.order.detail', $data);
|
||||
}
|
||||
|
||||
public function ordersDatatable(){
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$query = ShoppingOrder::with('shopping_user', 'shopping_payments')->select('shopping_orders.*')->where('auth_user_id', '=', $user->id)->where('txaction', '!=', NULL);
|
||||
|
||||
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>';
|
||||
})
|
||||
->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->created_at->format("d.m.Y");
|
||||
})
|
||||
->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
|
||||
return Payment::getShoppingOrderBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="no-line-break">'.$ShoppingOrder->getFormattedTotalShipping()." €</span>";
|
||||
})
|
||||
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
|
||||
})
|
||||
->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-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>';
|
||||
}
|
||||
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>' : '-';
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
|
||||
->rawColumns(['id', 'txaction', 'payment_for', 'total_shipping', 'invoice', 'shipped'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
/*
|
||||
$for = me, ot-member, ot-customer, abo-ot-member, abo-ot-customer, abo-me
|
||||
*/
|
||||
|
||||
public function delivery($for, $id=null)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_user = null;
|
||||
$delivery_id = null;
|
||||
if(strpos($for, 'ot') !== false){ //ot-member, ot-customer abo-ot-member, abo-ot-customer,
|
||||
$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'));
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
}
|
||||
if($for === 'abo-ot-customer'){
|
||||
//check if user has an Abo
|
||||
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]));
|
||||
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){
|
||||
$delivery_id = $id;
|
||||
}
|
||||
return redirect(route('user_order_my_list', [Request::get('switchers-radio-is-for'), $delivery_id]));
|
||||
}
|
||||
$data = [
|
||||
'shopping_user' => $shopping_user,
|
||||
'isAdmin' => false,
|
||||
'isView' => 'customer',
|
||||
'for' => $for,
|
||||
'delivery_id' => $delivery_id,
|
||||
];
|
||||
return view('user.order.delivery', $data);
|
||||
}
|
||||
|
||||
public function list($for, $id=null)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if($for === 'abo-me' && AboHelper::userHasAbo($user)){
|
||||
abort(403, 'User has an Abo. Cannot order.');
|
||||
}
|
||||
$shopping_user = null;
|
||||
$delivery_id = null;
|
||||
if(strpos($for, 'ot') !== false){ //ot-member, ot-customer abo-ot-member, abo-ot-customer,
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
$delivery_id = $shopping_user->id;
|
||||
}
|
||||
if($for === 'ot-customer' || $for === 'abo-ot-customer'){
|
||||
//Liederung an (abo-) ot-customer (Kunden) Zahlung und Rechnung geht an Kunden
|
||||
UserService::initCustomerYard($shopping_user, $for);
|
||||
}else{
|
||||
//Lieferung an user oder (abo-) ot-member (Kunden) rechnung geht an User
|
||||
//lieferland und rechnungsland prüfen
|
||||
$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'));
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
}
|
||||
UserService::initUserYard($user, $shipping_country_id, $for);
|
||||
}
|
||||
$data = [
|
||||
'shopping_user' => $shopping_user,
|
||||
'user' => $user,
|
||||
'isAdmin' => false,
|
||||
'isView' => 'customer',
|
||||
'for' => $for,
|
||||
'template' => str_replace('abo-', '', $for),
|
||||
'delivery_id' => $delivery_id,
|
||||
'is_abo' => strpos($for, 'abo') !== false,
|
||||
'comp_products' => Shop::getCompProducts($for),
|
||||
];
|
||||
return view('user.order.list', $data);
|
||||
}
|
||||
|
||||
public function payment($for, $id=null){
|
||||
$data = Request::all();
|
||||
$user = User::find(Auth::user()->id);
|
||||
$rules = array(
|
||||
'shipping_salutation' => 'required',
|
||||
'shipping_firstname'=>'required',
|
||||
'shipping_lastname'=>'required',
|
||||
'shipping_address'=>'required',
|
||||
'shipping_zipcode'=>'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_state' => 'required',
|
||||
);
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
//hier prüfen, ob versand etc richtig berechnet wurde
|
||||
$this->checkSendYardForPayment($data, $id);
|
||||
|
||||
if(Yard::instance('shopping')->getNumComp() > 0){
|
||||
if(!isset($data['switchers-comp-product'])){
|
||||
$validator->errors()->add('switchers-comp-product', __('msg.please_select_compensation_product'));
|
||||
}else{
|
||||
if(!is_array($data['switchers-comp-product'])){
|
||||
$validator->errors()->add('switchers-comp-product', __('msg.please_select_compensation_product'));
|
||||
}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()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($validator->errors()->count()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
}
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
$data['is_from'] = 'user_order';
|
||||
$data['is_for'] = $for;
|
||||
$data['is_abo'] = $data['is_abo'] ?? 0;
|
||||
$data['abo_interval'] = $data['abo_interval'] ?? 0;
|
||||
$data['shopping_user_id'] = $id;
|
||||
$data['user_price_infos'] = Yard::instance('shopping')->getUserPriceInfos();
|
||||
unset($data['quantity']);
|
||||
unset($data['_token']);
|
||||
$data['mode'] = config('app.mode') === 'test' ? 'test' : 'live';
|
||||
if($for === 'ot-customer' || $for === 'abo-ot-customer'){
|
||||
$shopping_instance = ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => $user->shop->id,
|
||||
'payment' => 6, //Berater Shop to Customer Shop
|
||||
'subdomain' => $user->shop->getSubdomain(),
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'amount' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'status' => 0,
|
||||
'shopping_user_id' => $id,
|
||||
'shopping_data' => $data,
|
||||
'back' => url()->previous(),
|
||||
|
||||
]);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$yard_shopping_items = OrderPaymentService::getRestoredYardShoppingItems($shopping_instance);
|
||||
|
||||
// send Mail to Customer
|
||||
$this->customPaymentSendMail($user, $identifier, $yard_shopping_items, $data);
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'user_order_customer', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier, 'is_abo'=>$data['is_abo']]);
|
||||
|
||||
//eine Abschließen bestellseite für den User + Link zum Kunden Shop + Mail an den Kunden / Berater
|
||||
return redirect(route('user_order_my_custom_payment', ['identifier'=>$identifier]));
|
||||
}else{
|
||||
ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => 1, //is first faker shop for buy intern
|
||||
'auth_user_id' => Auth::user()->id,
|
||||
'payment' => 2, //Berater Shop
|
||||
'subdomain' => url('/'),
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'amount' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'status' => 0,
|
||||
'shopping_user_id' => $id,
|
||||
'shopping_data' => $data,
|
||||
'back' => url()->previous(),
|
||||
|
||||
]);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'user_order_payment', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier, 'is_abo'=>$data['is_abo']]);
|
||||
//$path = str_replace('http', 'https', $path);
|
||||
return redirect()->secure($path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function checkSendYardForPayment($data, $id){
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_user = null;
|
||||
if(strpos($data['shipping_is_for'], 'ot') !== false){
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
}
|
||||
|
||||
$shipping_country_id = Shop::checkShoppingCountry($data['shipping_is_for'], $id);
|
||||
if(!$shipping_country_id){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'no shipping_country_id found | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('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);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'shipping_country_id is not the same from Yard | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shipping_country_was_not_correctly'));
|
||||
}
|
||||
|
||||
if($data['shipping_is_for'] !== 'ot-customer'){
|
||||
if(Yard::instance('shopping')->shipping_free){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard can by not shipping_free | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shopping_cart_was_shipping_free'));
|
||||
}
|
||||
}
|
||||
|
||||
if($data['shipping_is_for'] === 'ot-customer'){
|
||||
if(!$user->shop){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'User has no Shop for an User to Customer order| Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shopping_cart_was_not_user_shop'));
|
||||
}
|
||||
}
|
||||
|
||||
$shipping_price = Shop::getShippingPriceByShippingCountryId($shipping_country_id, Yard::instance('shopping')->weight());
|
||||
dump($shipping_price);
|
||||
//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){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard OT shipping_price is 0 or | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('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);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard OT shipping_price is not the same from shipping_price | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('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);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is 0 or | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shipping_cost_cannot_be_0'));
|
||||
}
|
||||
dump(Yard::instance('shopping')->getShippingPrice());
|
||||
dump($shipping_price->price_comp);
|
||||
dump(Yard::instance('shopping')->getNumComp());
|
||||
dump($shipping_price->num_comp);
|
||||
dd($data) ;
|
||||
|
||||
if(Yard::instance('shopping')->getShippingPrice() != $shipping_price->price_comp){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is not the same from shipping_price | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('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);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard num_comp is 0 | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.compensation_products_cannot_be_0'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
|
||||
if(Request::get('shipping_is_for') === 'me' || Request::get('shipping_is_for') === 'abo-me'){
|
||||
$show_on_ids = Request::get('is_abo') ? ['12', '13'] : ['2'];
|
||||
$query = Product::with('product_buyings')
|
||||
->select('products.*')->where('products.active', true)
|
||||
->where(function($q) use ($show_on_ids) {
|
||||
foreach($show_on_ids as $id) {
|
||||
$q->orWhereJsonContains('show_on', $id);
|
||||
}
|
||||
})
|
||||
->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{
|
||||
$show_on_ids = Request::get('is_abo') ? ['12', '13'] : ['3'];
|
||||
$query = Product::select('products.*')
|
||||
->where('active', true)
|
||||
->where(function($q) use ($show_on_ids) {
|
||||
foreach($show_on_ids as $id) {
|
||||
$q->orWhereJsonContains('show_on', $id);
|
||||
}
|
||||
})
|
||||
->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]]);
|
||||
}
|
||||
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>
|
||||
<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>
|
||||
</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.'">
|
||||
<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>
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
})
|
||||
->addColumn('abo', function (Product $product) {
|
||||
return AboHelper::getAboTypeBadge(AboHelper::getAboShowOn($product));
|
||||
})
|
||||
/*
|
||||
->addColumn('add_card', function (Product $product) {
|
||||
return '<button type="button" class="btn btn-sm btn-md-extra btn-secondary add-product-basket" data-product-id="'.$product->id.'">
|
||||
<strong>€ '.$product->getFormattedPriceWith().'</strong> +<span class="ion ion-md-cart"></span>
|
||||
</button>';
|
||||
})
|
||||
->addColumn('quantity', function (Product $product) {
|
||||
$cartItem = Yard::instance('shopping')->getCartItemByProduct($product->id);
|
||||
$qty = isset($cartItem->qty) ? $cartItem->qty : 0;
|
||||
$rowId = isset($cartItem->rowId) ? $cartItem->rowId : '';
|
||||
return '<div class="no-line-break input-group-min-w">
|
||||
<div class="input-group d-inline-flex w-auto">
|
||||
<span class="input-group-prepend">
|
||||
<button 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.'">
|
||||
<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>
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
})*/
|
||||
->addColumn('picture', function (Product $product) {
|
||||
if(count($product->images)){
|
||||
return '<img class="img-fluid img-extra" alt="" src="'.route('product_image', [$product->images->first()->slug]).'">';
|
||||
}
|
||||
return "";
|
||||
})
|
||||
->addColumn('price_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>';
|
||||
})
|
||||
->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>';
|
||||
})
|
||||
->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>';
|
||||
})
|
||||
->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>';
|
||||
})
|
||||
->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>';
|
||||
})
|
||||
->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>';
|
||||
})
|
||||
->addColumn('action', function (Product $product) {
|
||||
return '<button class="btn btn-default btn-sm icon-btn md-btn-flat product-tooltip" title="details" data-modal="modal-lg"
|
||||
data-toggle="modal" data-target="#modals-load-content" data-id="'.$product->id.'" data-route="'.route('modal_load').'"
|
||||
data-action="user-order-show-product" data-view="customer"><i class="ion ion-md-eye"></i></button>';
|
||||
})
|
||||
->filterColumn('product', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('name', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->orderColumn('name', 'name $1')
|
||||
->orderColumn('product', 'name $1')
|
||||
->orderColumn('number', 'number $1')
|
||||
->orderColumn('points', 'points $1')
|
||||
->orderColumn('price_net', 'price_net $1')
|
||||
->orderColumn('price_gross', 'price_gross $1')
|
||||
->orderColumn('price_vk_gross', 'price $1')
|
||||
->orderColumn('customer_price_net', 'price $1')
|
||||
->orderColumn('customer_price_gross', 'price $1')
|
||||
->orderColumn('my_commission_net', 'price $1')
|
||||
->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'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
public function performRequest(){
|
||||
|
||||
if(Request::ajax()) {
|
||||
$data = Request::all();
|
||||
|
||||
$is_for = isset($data['shipping_is_for']) ? $data['shipping_is_for'] : 'ot-member';
|
||||
$data['for'] = $is_for;
|
||||
$data['comp_products'] = Shop::getCompProducts($is_for);
|
||||
|
||||
if($data['action'] === 'updateCart' && isset($data['product_id'])){
|
||||
if($product = Product::find($data['product_id'])){
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
|
||||
//get the card 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]);
|
||||
}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]);
|
||||
}
|
||||
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']);
|
||||
}else{
|
||||
//if 0 get the item by qty:1 and remove it
|
||||
Yard::instance('shopping')->remove($cartItem->rowId);
|
||||
}
|
||||
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();
|
||||
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
|
||||
}
|
||||
}
|
||||
if($data['action'] === 'clearCart') {
|
||||
Yard::instance('shopping')->destroy();
|
||||
return response()->json(['response' => true, 'data'=>Yard::instance('shopping')->count(), 'html_card'=>'', 'html_comp'=>'']);
|
||||
|
||||
}
|
||||
|
||||
if($data['action'] === 'updateShippingCountry') {
|
||||
if(isset($data['shipping_country_id'])){
|
||||
if($shipping_country = ShippingCountry::find($data['shipping_country_id'])){
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country->id, $is_for);
|
||||
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
|
||||
}
|
||||
}
|
||||
$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]);
|
||||
|
||||
}
|
||||
if($data['action'] === 'updateCompProduct'){
|
||||
// $data['comp_product_id']
|
||||
// $data['comp_num']
|
||||
//count_comp_products
|
||||
$this->updateCompProduct($data);
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
$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]);
|
||||
|
||||
}
|
||||
return response()->json(['response' => false, 'data'=>$data]);
|
||||
}
|
||||
}
|
||||
|
||||
private function checkCompProduct($count_comp_products){
|
||||
foreach (Yard::instance('shopping')->content() as $row) {
|
||||
//wenn gleich löschen, da neue Versandkosten
|
||||
if($row->options->comp > $count_comp_products) {
|
||||
Yard::instance('shopping')->remove($row->rowId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function updateCompProduct($data){
|
||||
//clear old
|
||||
foreach (Yard::instance('shopping')->content() as $row) {
|
||||
//wenn kleiner wurde ein produkt entfernt aufgrund der Anzahl
|
||||
//wenn gleich löschen, da neue Versandkosten
|
||||
if($row->options->comp === $data['comp_num'] || $row->options->comp > $data['count_comp_products']) {
|
||||
Yard::instance('shopping')->remove($row->rowId);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['comp_product_id'])) {
|
||||
if ($product = Product::find($data['comp_product_id'])) {
|
||||
$image = "";
|
||||
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, 'points' => 0,
|
||||
'comp' => $data['comp_num'], 'product_id' => $product->id]);
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function customPayment($identifier){
|
||||
|
||||
$data = OrderPaymentService::getCustomPayment($identifier);
|
||||
return view('user.order.payment.custom_payment', $data);
|
||||
}
|
||||
|
||||
|
||||
private static function customPaymentSendMail($user, $identifier, $yard_shopping_items, $data){
|
||||
$bcc = [];
|
||||
$shopping_instance = ShoppingInstance::where('identifier', $identifier)->first();
|
||||
if(!$shopping_instance){
|
||||
abort(403, __('msg.shopping_instance_not_found'));
|
||||
}
|
||||
$shopping_user = $data['shopping_user_id'] ? ShoppingUser::find($data['shopping_user_id']) : null;
|
||||
if(!$shopping_user){
|
||||
abort(403, __('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;
|
||||
|
||||
Mail::to($billing_email)->bcc($bcc)->locale(\App::getLocale())
|
||||
->send(new MailCustomPaymet($route, $shopping_user, $shopping_instance, $yard_shopping_items, $data['mode']));
|
||||
}
|
||||
}
|
||||
97
app/Http/Controllers/User/OrderPaymentController.php
Normal file
97
app/Http/Controllers/User/OrderPaymentController.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\OrderPaymentService;
|
||||
|
||||
class OrderPaymentController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('active.account');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
];
|
||||
return view('user.order.payment.index', $data);
|
||||
}
|
||||
|
||||
public function detail($identifier)
|
||||
{
|
||||
$data = OrderPaymentService::getCustomPayment($identifier);
|
||||
$data['backlink'] = route('user_order_payment_links');
|
||||
return view('user.order.payment.custom_payment', $data);
|
||||
}
|
||||
|
||||
public function delete($identifier){
|
||||
OrderPaymentService::deleteInstance($identifier);
|
||||
return redirect(route('user_order_payment_links'));
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$user_shop_id = $user->shop ? $user->shop->id : null;
|
||||
$query = ShoppingInstance::select('*')
|
||||
->where('user_shop_id', '=', $user_shop_id)
|
||||
->where('payment', 6);
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (ShoppingInstance $shoppingInstance) {
|
||||
return '<a href="'.route('user_order_payment_links_detail', [$shoppingInstance->identifier]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('created_at', function (ShoppingInstance $shoppingInstance) {
|
||||
return $shoppingInstance->created_at->format("d.m.Y");
|
||||
})
|
||||
->addColumn('status', function (ShoppingInstance $shoppingInstance) {
|
||||
return OrderPaymentService::getStatusBadge($shoppingInstance);
|
||||
})
|
||||
->addColumn('payment_method', function (ShoppingInstance $shoppingInstance) {
|
||||
return $shoppingInstance->payment_method ? $shoppingInstance->payment_method->name : '-';
|
||||
})
|
||||
->addColumn('total', function (ShoppingInstance $shoppingInstance) {
|
||||
if($shoppingInstance->amount > 0){
|
||||
return '<span class="no-line-break">'.$shoppingInstance->getAmountFormatted()." €</span>";
|
||||
}else{
|
||||
return '-';
|
||||
}
|
||||
})
|
||||
->addColumn('type', function (ShoppingInstance $shoppingInstance) {
|
||||
return OrderPaymentService::getTypeBadge($shoppingInstance);
|
||||
})
|
||||
->addColumn('billing_firstname', function (ShoppingInstance $shoppingInstance) {
|
||||
return $shoppingInstance->shopping_data['billing_firstname'] ?? '-';
|
||||
})
|
||||
->addColumn('billing_lastname', function (ShoppingInstance $shoppingInstance) {
|
||||
return $shoppingInstance->shopping_data['billing_lastname'] ?? '-';
|
||||
})
|
||||
->addColumn('billing_email', function (ShoppingInstance $shoppingInstance) {
|
||||
return $shoppingInstance->shopping_data['billing_email'] ?? '-';
|
||||
})
|
||||
->addColumn('delete', function (ShoppingInstance $shoppingInstance) {
|
||||
return '<a onclick="return confirm(\''.__('confirm_delete').'\');" href="'.route('user_order_payment_links_delete', [$shoppingInstance->identifier]).'" class="btn icon-btn btn-sm btn-danger"><span class="fa fa-trash"></span></a>';
|
||||
})
|
||||
|
||||
->orderColumn('id', 'identifier $1')
|
||||
->orderColumn('created_at', 'created_at $1')
|
||||
->orderColumn('status', 'status $1')
|
||||
->orderColumn('total', 'total $1')
|
||||
->orderColumn('type', 'type $1')
|
||||
->orderColumn('billing_firstname', 'billing_firstname $1')
|
||||
->orderColumn('billing_lastname', 'billing_lastname $1')
|
||||
->orderColumn('billing_email', 'billing_email $1')
|
||||
->rawColumns(['id', 'status', 'type', 'total', 'invoice', 'delete'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -50,10 +50,9 @@ class PaymentController extends Controller
|
|||
if(Credit::isCredit($UserCredit)){
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a><br>';
|
||||
if(Auth::user()->isVIP()){
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'html']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-eye"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'pdf']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-file-pdf" style="min-width:13.5px"></i></a> ';
|
||||
}
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'html']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-eye"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'pdf']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-file-pdf" style="min-width:13.5px"></i></a> ';
|
||||
|
||||
}else{
|
||||
$ret = "-";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class ShopApiController extends Controller
|
|||
return $ShoppingOrder->user_shop ? '<a href="'.$ShoppingOrder->user_shop->getSubdomain(false).'" target="_blank">'.$ShoppingOrder->user_shop->getSubdomain(false).'</span>' : '';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class ShopSalesController extends Controller
|
|||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->member_id !== $user->id){
|
||||
abort(404);
|
||||
abort(403, 'Unauthorized action. User ID does not match.');
|
||||
}
|
||||
if( $shopping_order->payment_for !== 6 && $shopping_order->payment_for !== 7){
|
||||
return redirect(route('user_order_detail', [$shopping_order->id]));
|
||||
|
|
@ -67,7 +67,7 @@ class ShopSalesController extends Controller
|
|||
return $ShoppingOrder->user_shop ? '<a href="'.$ShoppingOrder->user_shop->getSubdomain(false).'" target="_blank">'.$ShoppingOrder->user_shop->getSubdomain(false).'</span>' : '';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use Auth;
|
||||
use Request;
|
||||
use App\User;
|
||||
|
|
@ -26,11 +27,11 @@ class TeamController extends Controller
|
|||
public function members()
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if($user->isActiveShop() && $user->shop){
|
||||
$shop_register_link = $user->shop->getSubdomain(false)."/reg";
|
||||
}else{
|
||||
$member_id = 'm'.($user->id + config('mivita.add_number_id'));
|
||||
$shop_register_link = config('app.protocol').config('app.domain').config('app.tld_care').'/reg/'.$member_id;
|
||||
if ($user->isActiveShop() && $user->shop) {
|
||||
$shop_register_link = $user->shop->getSubdomain(false) . "/reg";
|
||||
} else {
|
||||
$member_id = 'm' . ($user->id + config('mivita.add_number_id'));
|
||||
$shop_register_link = config('app.protocol') . config('app.domain') . config('app.tld_care') . '/reg/' . $member_id;
|
||||
}
|
||||
$data = [
|
||||
'shop_register_link' => $shop_register_link
|
||||
|
|
@ -71,7 +72,7 @@ class TeamController extends Controller
|
|||
{
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if(!$user->isVIP()){
|
||||
if (!$user->isVIP()) {
|
||||
abort(404);
|
||||
}
|
||||
$ExportBot = new ExportBot('member');
|
||||
|
|
@ -82,14 +83,15 @@ class TeamController extends Controller
|
|||
return view('user.team.export', $data);
|
||||
}
|
||||
|
||||
public function userTeamExport(){
|
||||
public function userTeamExport()
|
||||
{
|
||||
|
||||
if(Request::get('action') === "export"){
|
||||
if (Request::get('action') === "export") {
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$ExportBot = new ExportBot('member');
|
||||
$ExportBot->initStructureUser($user, 'list'); //tree or list
|
||||
$columns = [];
|
||||
$filename = __('team.filename_export').date('Y-m-d-H-i-s');
|
||||
$filename = __('team.filename_export') . date('Y-m-d-H-i-s');
|
||||
$headers = array(
|
||||
__('tables.line'),
|
||||
__('tables.level'),
|
||||
|
|
@ -104,12 +106,13 @@ class TeamController extends Controller
|
|||
__('tables.phone'),
|
||||
__('tables.mobil'),
|
||||
__('tables.birthday'),
|
||||
__('tables.partner_since'),
|
||||
__('tables.account'),
|
||||
__('tables.account_to'),
|
||||
__('tables.sponsor'),
|
||||
);
|
||||
if(isset($ExportBot->user_list->childs)){
|
||||
foreach ($ExportBot->user_list->childs as $child){
|
||||
if (isset($ExportBot->user_list->childs)) {
|
||||
foreach ($ExportBot->user_list->childs as $child) {
|
||||
$columns[] = array(
|
||||
__('tables.line') => $child->line,
|
||||
__('tables.level') => $child->level_name,
|
||||
|
|
@ -124,42 +127,44 @@ class TeamController extends Controller
|
|||
__('tables.phone') => $child->phone,
|
||||
__('tables.mobil') => $child->mobil,
|
||||
__('tables.birthday') => $child->birthday,
|
||||
__('tables.partner_since') => $child->partner_since,
|
||||
__('tables.account') => ($child->active_account == 1 ? __('yes') : __('no')),
|
||||
__('tables.account_to') => $child->payment_account_date,
|
||||
__('tables.sponsor') => $child->sponsor_name,
|
||||
);
|
||||
}
|
||||
}
|
||||
return Excel::download(new UserTeamExport($columns, $headers), $filename.'.xls');
|
||||
return Excel::download(new UserTeamExport($columns, $headers), $filename . '.xls');
|
||||
}
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if(!session('team_user_filter_month')){
|
||||
if (!session('team_user_filter_month')) {
|
||||
session(['team_user_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('team_user_filter_year')){
|
||||
if (!session('team_user_filter_year')) {
|
||||
session(['team_user_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(!session('team_user_points_filter_month')){
|
||||
if (!session('team_user_points_filter_month')) {
|
||||
session(['team_user_points_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('team_user_points_filter_year')){
|
||||
if (!session('team_user_points_filter_year')) {
|
||||
session(['team_user_points_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
|
||||
if(Request::get('team_user_filter_month')){
|
||||
|
||||
if (Request::get('team_user_filter_month')) {
|
||||
session(['team_user_filter_month' => Request::get('team_user_filter_month')]);
|
||||
}
|
||||
if(Request::get('team_user_filter_year')){
|
||||
if (Request::get('team_user_filter_year')) {
|
||||
session(['team_user_filter_year' => Request::get('team_user_filter_year')]);
|
||||
}
|
||||
|
||||
if(Request::get('team_user_points_filter_month')){
|
||||
if (Request::get('team_user_points_filter_month')) {
|
||||
session(['team_user_points_filter_month' => Request::get('team_user_points_filter_month')]);
|
||||
}
|
||||
if(Request::get('team_user_points_filter_year')){
|
||||
if (Request::get('team_user_points_filter_year')) {
|
||||
session(['team_user_points_filter_year' => Request::get('team_user_points_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
|
@ -170,46 +175,47 @@ class TeamController extends Controller
|
|||
|
||||
$user_id = \Auth::user()->id;
|
||||
$query = UserSalesVolume::with('user', 'user.account')->with('shopping_order')->select('user_sales_volumes.*')
|
||||
->where('user_sales_volumes.user_id', '=', $user_id)
|
||||
->where('user_sales_volumes.month', '=', Request::get('team_user_points_filter_month'))
|
||||
->where('user_sales_volumes.year', '=', Request::get('team_user_points_filter_year'));
|
||||
->where('user_sales_volumes.user_id', '=', $user_id)
|
||||
->where('user_sales_volumes.month', '=', Request::get('team_user_points_filter_month'))
|
||||
->where('user_sales_volumes.year', '=', Request::get('team_user_points_filter_year'));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
public function datatablePoints(){
|
||||
public function datatablePoints()
|
||||
{
|
||||
|
||||
$query = $this->initSearchPoints();
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
|
||||
->addColumn('order', function (UserSalesVolume $UserSalesVolume) {
|
||||
if($UserSalesVolume->shopping_order){
|
||||
if($UserSalesVolume->status === 1 && $UserSalesVolume->shopping_order->auth_user_id === $UserSalesVolume->user_id){
|
||||
return '<a href="' . route('user_order_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-primary">'.$UserSalesVolume->shopping_order->id.'</a>';
|
||||
if ($UserSalesVolume->shopping_order) {
|
||||
if ($UserSalesVolume->status === 1 && $UserSalesVolume->shopping_order->auth_user_id === $UserSalesVolume->user_id) {
|
||||
return '<a href="' . route('user_order_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-primary">' . $UserSalesVolume->shopping_order->id . '</a>';
|
||||
}
|
||||
if(($UserSalesVolume->status === 2 || $UserSalesVolume->status === 3) && $UserSalesVolume->shopping_order->member_id === $UserSalesVolume->user_id){
|
||||
return '<a href="' . route('user_shop_order_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-secondary">'.$UserSalesVolume->shopping_order->id.'</a>';
|
||||
if (($UserSalesVolume->status === 2 || $UserSalesVolume->status === 3) && $UserSalesVolume->shopping_order->member_id === $UserSalesVolume->user_id) {
|
||||
return '<a href="' . route('user_shop_order_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-secondary">' . $UserSalesVolume->shopping_order->id . '</a>';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
})
|
||||
->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('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>';
|
||||
})
|
||||
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('order', 'order $1')
|
||||
->orderColumn('status', 'status $1')
|
||||
|
|
@ -220,7 +226,8 @@ class TeamController extends Controller
|
|||
->make(true);
|
||||
}
|
||||
|
||||
public function load(){
|
||||
public function load()
|
||||
{
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$userSalesVolume = $user->getUserSalesVolume(intval(session('team_user_points_filter_month')), intval(session('team_user_points_filter_year')), 'first');
|
||||
|
|
@ -229,9 +236,6 @@ class TeamController extends Controller
|
|||
'userSalesVolume' => $userSalesVolume,
|
||||
];
|
||||
$html = view('user.team._points_sum', $data)->render();
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html'=>$html]);
|
||||
|
||||
return response()->json(['response' => true, 'data' => $data, 'html' => $html]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ class UserDataController extends Controller
|
|||
'city' => 'required',
|
||||
'email' => 'required|string|email|max:255|exists:users,email',
|
||||
'email-confirm' => 'required|same:email',
|
||||
'bank_owner' => 'required',
|
||||
'bank_iban' => 'required',
|
||||
'bank_bic' => 'required',
|
||||
);
|
||||
if(!Request::get('same_as_billing')){
|
||||
$rules = array_merge($rules, [
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class CardController extends Controller
|
|||
$cartItem = Yard::instance('shopping')
|
||||
->add($product->id, $product->getLang('name'), $quantity,
|
||||
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping]);
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping, 'show_on' => $product->show_on]);
|
||||
if(Yard::instance('shopping')->getUserTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
@ -65,7 +65,7 @@ class CardController extends Controller
|
|||
$cartItem = Yard::instance('shopping')
|
||||
->add($product->id, $product->getLang('name'), $quantity,
|
||||
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping]);
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping, 'show_on' => $product->show_on]);
|
||||
if(Yard::instance('shopping')->getUserTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -252,6 +252,9 @@ class WizardController extends Controller
|
|||
'mobil' => 'required_without:phone',
|
||||
'country_id' => 'required|integer|min:1',
|
||||
'birthday' => 'required',
|
||||
'bank_owner' => 'required',
|
||||
'bank_iban' => 'required',
|
||||
'bank_bic' => 'required',
|
||||
);
|
||||
|
||||
if (!Request::get('same_as_billing')) {
|
||||
|
|
@ -572,7 +575,7 @@ class WizardController extends Controller
|
|||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
@ -587,7 +590,7 @@ class WizardController extends Controller
|
|||
if($product_on_board->images->count()){
|
||||
$image = $product_on_board->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight, 'points' => $product_on_board->points, 'no_commission' => $product_on_board->no_commission]);
|
||||
$cartItem = Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight, 'points' => $product_on_board->points, 'no_commission' => $product_on_board->no_commission, 'show_on' => $product_on_board->show_on]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue