Updates to 03-2025
This commit is contained in:
parent
6167273a48
commit
9b54eb0512
348 changed files with 34535 additions and 5774 deletions
|
|
@ -595,7 +595,9 @@ class ShoppingUserController extends Controller
|
|||
if ($order->price != ($product->price * 100)) {
|
||||
$error[] = "different price: " . ($product->price * 100);
|
||||
}
|
||||
Yard::instance('shopping')->add($product->id, $product->name, (int) $order->qty, $product->price, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
|
||||
|
||||
Yard::instance('shopping')->add($product->id, $product->name, (int) $order->qty, $product->price, $product->tax, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
}
|
||||
}
|
||||
$order->message = $error;
|
||||
|
|
@ -604,7 +606,7 @@ class ShoppingUserController extends Controller
|
|||
|
||||
$ShippingCountry = ShippingCountry::whereCountryId($shopping_user->shipping_country_id)->first();
|
||||
if($ShippingCountry){
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($ShippingCountry->id);
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($ShippingCountry->id, 'ot');
|
||||
}
|
||||
$shopping_order = $this->makeShoppingOrder($shopping_user, $wp_invoice_path, $wp_notice);
|
||||
$this->orderStatusSendMail($shopping_order);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Models\Attribute;
|
||||
use App\Models\ProductAttribute;
|
||||
use Request;
|
||||
use App\Models\Attribute;
|
||||
use App\Models\AttributeType;
|
||||
use App\Models\ProductAttribute;
|
||||
|
||||
|
||||
class AttributeController extends Controller
|
||||
|
|
@ -20,33 +21,64 @@ class AttributeController extends Controller
|
|||
{
|
||||
|
||||
$data = [
|
||||
'values' => Attribute::all(),
|
||||
'attribute_types' => AttributeType::all(),
|
||||
'attributes' => Attribute::all(),
|
||||
'trans' => array_keys(config('localization.supportedLocales')),
|
||||
];
|
||||
return view('admin.attribute.index', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
if($data['id'] == "new"){
|
||||
$model = Attribute::create([
|
||||
'parent_id' => null,
|
||||
'name' => $data['name'],
|
||||
'pos' => $data['pos'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = Attribute::find($data['id']);
|
||||
$model->parent_id = null;
|
||||
$model->name = $data['name'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
if(isset($data['action'])){
|
||||
|
||||
if(!empty($data['trans'])){
|
||||
if( $data['action'] === "attribute-type"){
|
||||
if($data['id'] == "new"){
|
||||
$model = AttributeType::create([
|
||||
'parent_id' => null,
|
||||
'name' => $data['name'],
|
||||
'description' => $data['description'],
|
||||
'pos' => $data['pos'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = AttributeType::find($data['id']);
|
||||
$model->parent_id = null;
|
||||
$model->name = $data['name'];
|
||||
$model->description = $data['description'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
if($data['action'] === "attribute"){
|
||||
if($data['id'] == "new"){
|
||||
$model = Attribute::create([
|
||||
'parent_id' => null,
|
||||
'attribute_type_id' => $data['attribute_type_id'],
|
||||
'name' => $data['name'],
|
||||
'value' => $data['value'],
|
||||
'pos' => $data['pos'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = Attribute::find($data['id']);
|
||||
$model->parent_id = null;
|
||||
$model->name = $data['name'];
|
||||
$model->value = $data['value'];
|
||||
$model->attribute_type_id = $data['attribute_type_id'];
|
||||
$model->pos = $data['pos'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if(!empty($data['trans'])){
|
||||
$trans = [];
|
||||
foreach ($data['trans'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
|
|
@ -57,7 +89,7 @@ class AttributeController extends Controller
|
|||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
|
|
@ -66,21 +98,41 @@ class AttributeController extends Controller
|
|||
}
|
||||
|
||||
|
||||
public function delete($id){
|
||||
public function delete($attr, $id){
|
||||
|
||||
if(ProductAttribute::where('attribute_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Produktattribute verwendet');
|
||||
if($attr === 'type'){
|
||||
if(Attribute::where('attribute_type_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Attribute Type wird bei den Attributen verwendet');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
/* if(AttributeType::where('parent_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Main Attribute verwendet');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
*/
|
||||
$model = AttributeType::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Attribute Type gelöscht');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
/* if(Attribute::where('parent_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Main Attribute verwendet');
|
||||
return redirect(route('admin_industry_sectors'));
|
||||
|
||||
if($attr === 'attr'){
|
||||
if(ProductAttribute::where('attribute_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Attribute wird bei den Produkten verwendet');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
/* if(Attribute::where('parent_id', $id)->count()){
|
||||
\Session()->flash('alert-error', 'Eintrag wird als Main Attribute verwendet');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
*/
|
||||
$model = Attribute::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
}
|
||||
*/
|
||||
$model = Attribute::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_product_attributes'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -52,6 +52,8 @@ class CountryController extends Controller
|
|||
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$data['switch'] = isset($data['switch']) ? true : false;
|
||||
$data['translate'] = isset($data['translate']) ? true : false;
|
||||
$data['eu_country'] = isset($data['eu_country']) ? true : false;
|
||||
$data['own_eur'] = isset($data['own_eur']) ? true : false;
|
||||
$data['currency'] = isset($data['currency']) ? true : false;
|
||||
$data['currency_faktor'] = $data['currency_faktor'] == "" ? null : reFormatNumber($data['currency_faktor']);
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class CronController extends Controller
|
|||
if($key !== 'key'){
|
||||
abort(404);
|
||||
}
|
||||
die('not in use');
|
||||
if($action === 'check_payments_account'){
|
||||
$this->checkPaymentsAccounts();
|
||||
}
|
||||
|
|
@ -54,6 +55,8 @@ class CronController extends Controller
|
|||
*/
|
||||
public function checkConfirmation()
|
||||
{
|
||||
/*
|
||||
User Register sind in der DB UserRegister, erst bei bestätigung wird es in die User DB übertragen
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$next = date('Y-m-d H:i:s', strtotime('+3 week'));
|
||||
|
||||
|
|
@ -73,7 +76,7 @@ class CronController extends Controller
|
|||
$user->confirmation_code_remider = 1;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
return "TOSK";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ class DataTableController extends Controller
|
|||
->addColumn('admin', function (User $user) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-admin" data-id="'.$user->id.'" data-email="'.$user->email.'" data-admin="'.$user->admin.'">'.HTMLHelper::getRoleLabel($user->admin).'</a>';
|
||||
})
|
||||
->addColumn('role', function (User $user) {
|
||||
return $user->user_level ? $user->user_level->name : '';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
$date = $user->getConfirmationDateFormat();
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-confirmed" data-id="'.$user->id.'" data-email="'.$user->email.'" data-confirmed="'.$user->confirmed.'" data-confirmation_date="'.$date.'">';
|
||||
|
|
@ -71,6 +74,9 @@ class DataTableController extends Controller
|
|||
}
|
||||
return "-";
|
||||
})*/
|
||||
->addColumn('country', function (User $user) {
|
||||
return ($user->account && $user->account->country) ? $user->account->country->de : '';
|
||||
})
|
||||
->addColumn('my_payment_methods', function (User $user) {
|
||||
$payment_methods = json_encode($user->payment_methods);
|
||||
$link = '<a href="#" data-toggle="modal" data-target="#modals-payment_methods" data-id="'.$user->id.'" data-email="'.$user->email.'" data-payment_methods="'.htmlspecialchars($payment_methods).'">';
|
||||
|
|
|
|||
200
app/Http/Controllers/Evo/SalesController.php
Executable file
200
app/Http/Controllers/Evo/SalesController.php
Executable file
|
|
@ -0,0 +1,200 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Evo;
|
||||
use Auth;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Exports\UserTeamExport;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Services\BusinessPlan\ExportBot;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class SalesController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(2022),
|
||||
];
|
||||
return view('admin.evaluation.salesvolume', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function download(){
|
||||
|
||||
if(Request::get('action') === "export"){
|
||||
$objects = $this->initSearch(false);
|
||||
$columns = [];
|
||||
$filename = "gs-absatzmengen-".session('product_sales_vol_filter_month').'_'.session('product_sales_vol_filter_year')."-export";
|
||||
$headers = array(
|
||||
'#',
|
||||
'Produkt',
|
||||
'Artikelnummer',
|
||||
'Menge',
|
||||
|
||||
);
|
||||
if($objects){
|
||||
foreach ($objects as $key => $obj){
|
||||
$columns[] = array(
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'value' => $obj['value'],
|
||||
);
|
||||
}
|
||||
}
|
||||
return Excel::download(new UserTeamExport($columns, $headers), $filename.'.xls');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function setFilterVars(){
|
||||
|
||||
if(!session('product_sales_vol_filter_month')){
|
||||
session(['product_sales_vol_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('product_sales_vol_filter_year')){
|
||||
session(['product_sales_vol_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
|
||||
if(Request::get('product_sales_vol_filter_month')){
|
||||
session(['product_sales_vol_filter_month' => Request::get('product_sales_vol_filter_month')]);
|
||||
}
|
||||
if(Request::get('product_sales_vol_filter_year')){
|
||||
session(['product_sales_vol_filter_year' => Request::get('product_sales_vol_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function initSearch($returnColl = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$date_start = Carbon::parse('01.'.session('product_sales_vol_filter_month').'.'.session('product_sales_vol_filter_year'))->format('Y-m-d H:i:s');
|
||||
$date_end = Carbon::parse('01.'.session('product_sales_vol_filter_month').'.'.session('product_sales_vol_filter_year'))->endOfMonth()->format('Y-m-d H:i:s');
|
||||
|
||||
$ShoppingOrders = ShoppingOrder::where('paid', 1)->where('mode', 'live')->whereBetween('created_at', [$date_start, $date_end])->get();
|
||||
|
||||
$objects = [];
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){
|
||||
|
||||
if($shopping_order_item->product){
|
||||
if(isset($objects[$shopping_order_item->product->id])){
|
||||
$value = intval($objects[$shopping_order_item->product->id]['value'] + $shopping_order_item->qty);
|
||||
$objects[$shopping_order_item->product->id]['value'] = $value;
|
||||
}else{
|
||||
$objects[$shopping_order_item->product->id] = [
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'value' => $shopping_order_item->qty
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($returnColl){
|
||||
$collection = collect();
|
||||
|
||||
foreach($objects as $key => $obj){
|
||||
$collection->push([
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'value' => $obj['value'],
|
||||
]);
|
||||
}
|
||||
return $collection;
|
||||
}
|
||||
return $objects;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$collection = $this->initSearch(true);
|
||||
|
||||
$collect = collect([
|
||||
['id' => 1, 'name' => 'John', 'number'=>92012, 'value'=>123],
|
||||
['id' => 2, 'name' => 'Jane', 'number'=>92012, 'value'=>123],
|
||||
['id' => 3, 'name' => 'James', 'number'=>92012, 'value'=>123],
|
||||
]);
|
||||
|
||||
return \DataTables::of($collection)->toJson();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*private function testCheckFunction(){
|
||||
|
||||
//$date_start = Carbon::parse('01.'.session('product_sales_vol_filter_month').'.'.session('product_sales_vol_filter_year'))->format('Y-m-d');
|
||||
//$date_end = Carbon::parse('01.'.session('product_sales_vol_filter_month').'.'.session('product_sales_vol_filter_year'))->endOfMonth()->format('Y-m-d');
|
||||
|
||||
$date_start = Carbon::parse('01.01.2024')->format('Y-m-d H:i:s');
|
||||
$date_end = Carbon::parse('01.01.2024')->endOfMonth()->format('Y-m-d H:i:s');
|
||||
dump($date_start);
|
||||
dump($date_end);
|
||||
|
||||
$ShoppingOrders = ShoppingOrder::where('mode', 'live')->whereBetween('created_at', [$date_start, $date_end])->get();
|
||||
|
||||
$objects = [];
|
||||
$counter = 0;
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){
|
||||
|
||||
if($shopping_order_item->product){
|
||||
if($shopping_order_item->product->id === 122){
|
||||
//dump($shopping_order_item->qty);
|
||||
//$counter += $shopping_order_item->qty;
|
||||
if(isset($objects[$shopping_order_item->product->id])){
|
||||
$value = intval($objects[$shopping_order_item->product->id]['value'] + $shopping_order_item->qty);
|
||||
$objects[$shopping_order_item->product->id]['value'] = $value;
|
||||
}else{
|
||||
$objects[$shopping_order_item->product->id] = [
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'value' => $shopping_order_item->qty
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$ShoppingOrderItems = ShoppingOrderItem::whereProductId(122)->whereBetween('created_at', [$date_start, $date_end])->get();
|
||||
$counter = 0;
|
||||
foreach($ShoppingOrderItems as $ShoppingOrderItem){
|
||||
$counter += $ShoppingOrderItem->qty;
|
||||
dump($ShoppingOrderItem->id);
|
||||
}
|
||||
// dump($objects);
|
||||
dump($counter);
|
||||
dd("OKAY");
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -47,61 +47,89 @@ class FileController extends Controller
|
|||
$this->isPermission($shopping_order->auth_user_id);
|
||||
$filename = Invoice::getFilename($shopping_order);
|
||||
$path = Invoice::getDownloadPath($shopping_order);
|
||||
if (!Storage::disk('public')->exists($path)) {
|
||||
return Response::make('File no found.', 404);
|
||||
}
|
||||
$file = Storage::disk('public')->get($path);
|
||||
$type = Storage::disk('public')->mimeType($path);
|
||||
|
||||
if($do === 'download'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $type)
|
||||
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
|
||||
/* $full_path = Invoice::getDownloadPath($shopping_order, true);
|
||||
$he
|
||||
if (file_exists($full_path)) {
|
||||
return Response::download($full_path, $filename);
|
||||
}*/
|
||||
}
|
||||
if($do === 'stream'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $type)
|
||||
->header('Content-disposition','filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ($disk === 'delivery'){
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
$this->isPermission($shopping_order->auth_user_id);
|
||||
$filename = Invoice::getDeliveryFilename($shopping_order);
|
||||
$path = Invoice::getDownloadPathDelivery($shopping_order);
|
||||
}
|
||||
|
||||
if ($disk === 'invoice_delivery'){
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
$this->isPermission($shopping_order->auth_user_id);
|
||||
|
||||
$ifilename = Invoice::getFilename($shopping_order);
|
||||
$ipath = Invoice::getDownloadPath($shopping_order, true);
|
||||
$dfilename = Invoice::getDeliveryFilename($shopping_order);
|
||||
$dpath = Invoice::getDownloadPathDelivery($shopping_order, true);
|
||||
|
||||
$oMerger = new \App\Services\PDFMerger();
|
||||
$oMerger->init();
|
||||
|
||||
$oMerger->addPDF($ipath);
|
||||
$oMerger->addPDF($dpath);
|
||||
$filename = str_replace('Rechnung-', 'Rechnung-Lieferschein-', $ifilename);
|
||||
$oMerger->setFileName($filename);
|
||||
$oMerger->merge();
|
||||
$file = $oMerger->output();
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", 'application/pdf')
|
||||
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
if ($disk === 'credit'){
|
||||
$UserCredit = \App\Models\UserCredit::findOrFail($id);
|
||||
$this->isPermission($UserCredit->auth_user_id);
|
||||
|
||||
$filename = Credit::getFilename($UserCredit);
|
||||
$path = Credit::getDownloadPath($UserCredit);
|
||||
|
||||
if (!Storage::disk('public')->exists($path)) {
|
||||
return Response::make('File no found.', 404);
|
||||
}
|
||||
$file = Storage::disk('public')->get($path);
|
||||
$type = Storage::disk('public')->mimeType($path);
|
||||
|
||||
if($do === 'download'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $type)
|
||||
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
|
||||
/* $full_path = Invoice::getDownloadPath($shopping_order, true);
|
||||
$he
|
||||
if (file_exists($full_path)) {
|
||||
return Response::download($full_path, $filename);
|
||||
}*/
|
||||
}
|
||||
if($do === 'stream'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $type)
|
||||
->header('Content-disposition','filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!Storage::disk('public')->exists($path)) {
|
||||
return Response::make('File no found.', 404);
|
||||
}
|
||||
|
||||
$file = Storage::disk('public')->get($path);
|
||||
$mime = Storage::disk('public')->mimeType($path);
|
||||
|
||||
if($do === 'download'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
|
||||
/* $full_path = Invoice::getDownloadPath($shopping_order, true);
|
||||
$he
|
||||
if (file_exists($full_path)) {
|
||||
return Response::download($full_path, $filename);
|
||||
}*/
|
||||
}
|
||||
if($do === 'stream'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition','filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
if($do === 'file'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition', 'filename="'.$filename.'"');
|
||||
}
|
||||
if($do === 'image'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime);
|
||||
}
|
||||
if($do === 'pdf'){
|
||||
$path = storage_path().'/app/public/' . $path;
|
||||
$headers = array(
|
||||
'Content-Type:'. $mime,
|
||||
// 'Content-Length: ' . $file->size
|
||||
// 'Content-Disposition: ' . $stream . '; filename=' . $file->original_name
|
||||
);
|
||||
return Response::download($path, $filename, $headers);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -90,34 +90,7 @@ class HomeController extends Controller
|
|||
}
|
||||
|
||||
|
||||
public function verify($confirmation_code){
|
||||
if( ! $confirmation_code)
|
||||
{
|
||||
return redirect('/status/error');
|
||||
}
|
||||
|
||||
$user = User::whereConfirmationCode($confirmation_code)->first();
|
||||
|
||||
if ( ! $user)
|
||||
{
|
||||
return redirect('/status/not/found');
|
||||
}
|
||||
if($user->confirmed === 0){
|
||||
$user->confirmed = 1;
|
||||
//kill after wizzard!
|
||||
// $user->confirmation_code = null;
|
||||
// $user->confirmation_code_to = null;
|
||||
// $user->confirmation_code_remider = 0;
|
||||
$user->confirmation_date = now();
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
||||
//Login!
|
||||
Auth::login($user);
|
||||
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
|
||||
public function statusRegister(){
|
||||
return view('status.status_register');
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ class ImportProductController extends Controller
|
|||
|
||||
ProductImage::create([
|
||||
'product_id' => $product->id,
|
||||
'type' => 'product', // 'product',
|
||||
'filename' => $name,
|
||||
'original_name' => $original_name,
|
||||
'ext' => $ext,
|
||||
|
|
|
|||
|
|
@ -2,20 +2,23 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Exports\ExcelExport;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use App\Services\SysLog;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\UserHistory;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Services\UserService;
|
||||
use App\Mail\MailAccountActive;
|
||||
use App\Mail\MailCustomMessage;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Mail\MailVerifyContact;
|
||||
use App\Mail\MailAccountActive;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\UserHistory;
|
||||
use App\Repositories\ContractPDFRepository;
|
||||
use App\Models\UserWhitelabelProduct;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\SysLog;
|
||||
use App\Services\UserService;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Request;
|
||||
use Validator;
|
||||
use App\Repositories\ContractPDFRepository;
|
||||
|
||||
class LeadController extends Controller
|
||||
{
|
||||
|
|
@ -33,13 +36,14 @@ class LeadController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'values' => User::where('admin', '=', 0)->where('confirmation_code_remider', '!=', 2)->get(),
|
||||
|
||||
];
|
||||
return view('admin.lead.index', $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
|
|
@ -122,6 +126,17 @@ class LeadController extends Controller
|
|||
|
||||
$data = Request::all();
|
||||
$show = Request::get('show');
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_validate" && isset($data['user_id'])){
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
return $this->userRepo->reverse_charge_validate($data, $user, route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete" && isset($data['user_id'])){
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
return $this->userRepo->reverse_charge_delete($data, $user, route('admin_lead_edit', [$user->id]));
|
||||
}
|
||||
|
||||
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
|
|
@ -187,6 +202,7 @@ class LeadController extends Controller
|
|||
if(isset($data['m_data_edit']) && $data['m_data_edit'] === "TSOK"){
|
||||
$user = $this->userRepo->getModel();
|
||||
$user->m_level = isset($data['m_level']) ? $data['m_level'] : NULL;
|
||||
$user->lead_type_id = isset($data['lead_type_id']) ? $data['lead_type_id'] : NULL;
|
||||
$user->m_sponsor = isset($data['m_sponsor']) ? $data['m_sponsor'] : NULL;
|
||||
$user->save();
|
||||
}
|
||||
|
|
@ -215,8 +231,229 @@ class LeadController extends Controller
|
|||
|
||||
|
||||
}
|
||||
//user released when register is complete
|
||||
public function released($action, $id){
|
||||
|
||||
|
||||
public function update()
|
||||
{
|
||||
$data = Request::all();
|
||||
$show = Request::get('show');
|
||||
if(!isset($data['user_id']) || $data['user_id'] === "new" || $data['user_id'] == 0){
|
||||
abort(404, 'User not found');
|
||||
}
|
||||
$user = User::findOrFail($data['user_id']);
|
||||
|
||||
if(isset($data['action'])){
|
||||
|
||||
//add whitelabel products
|
||||
if($data['action'] === 'add_whitelabel_products'){
|
||||
if(isset($data['whitelabel_products']) && is_array($data['whitelabel_products'])){
|
||||
foreach ($data['whitelabel_products'] as $product_id){
|
||||
$user->whitelabel_products()->create(['product_id' => $product_id]);
|
||||
}
|
||||
}
|
||||
\Session()->flash('alert-save', true);
|
||||
}
|
||||
//remove whitelabel products
|
||||
if($data['action'] === 'remove_whitelabel_products'){
|
||||
if(isset($data['whitelabel_products']) && is_array($data['whitelabel_products'])){
|
||||
$user->whitelabel_products()->whereIn('product_id', $data['whitelabel_products'])->delete();
|
||||
}
|
||||
\Session()->flash('alert-success', "Produkt gelöscht");
|
||||
}
|
||||
if($data['action'] === 'upload_white_label_image'){
|
||||
//id == user_whitelabel_product_id
|
||||
$whitelabel_product = UserWhitelabelProduct::findOrFail($data['id']);
|
||||
if($whitelabel_product && $user->id == $whitelabel_product->user_id){
|
||||
return \App\Services\ProductImage::imageUpload('user_wl_product', $whitelabel_product, Request::get('upload_type'));
|
||||
}
|
||||
}
|
||||
//update whitelabel products
|
||||
if($data['action'] === 'update_whitelabel_products'){
|
||||
if(isset($data['image_wl_attributes']) && is_array($data['image_wl_attributes'])){
|
||||
foreach ( $user->whitelabel_products as $wl_product){
|
||||
foreach ($wl_product->whitelabel_images as $wl_image) {
|
||||
$wl_image->update([
|
||||
'attributes' => isset($data['image_wl_attributes'][$wl_image->id]) ? $data['image_wl_attributes'][$wl_image->id] : NULL,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
\Session()->flash('alert-save', true);
|
||||
}
|
||||
}
|
||||
return redirect(route('admin_lead_edit', [$user->id])."?show=".$show);
|
||||
}
|
||||
|
||||
public function remove($action, $user_id, $id, $mid=null){
|
||||
$show = Request::get('show');
|
||||
$user = User::findOrFail($user_id);
|
||||
|
||||
if($action === 'remove_whitelabel_label'){
|
||||
$model = $user->whitelabel_products()->where('id', $id)->first();
|
||||
return \App\Services\ProductImage::imageDelete('user_wl_image', $model, $mid);
|
||||
}
|
||||
|
||||
if($action === 'remove_whitelabel_product'){
|
||||
|
||||
$model = $user->whitelabel_products()->where('id', $id)->first();
|
||||
//remove images
|
||||
foreach ($model->whitelabel_images as $image){
|
||||
\App\Services\ProductImage::imageDelete('user_wl_image', $model, $image->id);
|
||||
|
||||
}
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', "White Label Produkt entfernt");
|
||||
return redirect(route('admin_lead_edit', [$user->id])."?show=$show");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function download(){
|
||||
|
||||
if(Request::get('action') === "export"){
|
||||
$query = $this->initSearch();
|
||||
$columns = [];
|
||||
$filename = "GS-VP-export-".date("d-m-Y");
|
||||
$headers = array(
|
||||
'ID',
|
||||
'Email',
|
||||
'Firma',
|
||||
'Anrede',
|
||||
'Vorname',
|
||||
'Nachname',
|
||||
'Mitglied',
|
||||
'Bis',
|
||||
'Art',
|
||||
|
||||
);
|
||||
$objects = $query->get();
|
||||
if($objects){
|
||||
foreach ($objects as $obj){
|
||||
$columns[] = array(
|
||||
'ID' => $obj->id,
|
||||
'Email' => $obj->email,
|
||||
'Firma' => $obj->account ? $obj->account->company : '',
|
||||
'Anrede' => $obj->account ? ($obj->account->salutation == 'mr' ? 'Herr' : 'Frau') : '-',
|
||||
'Vorname' => $obj->account ? $obj->account->first_name : '',
|
||||
'Nachname' => $obj->account ? $obj->account->last_name : '',
|
||||
'Mitglied' => $obj->payment_account ? ($obj->isActiveAccount() ? 'JA' : 'Abgelaufen') : "Nein",
|
||||
'Bis' => $obj->payment_account ? $obj->getPaymentAccountDateFormat(false) : '-',
|
||||
'Art' => $obj->lead_type ? $obj->lead_type->name : '-',
|
||||
);
|
||||
}
|
||||
}
|
||||
return Excel::download(new ExcelExport($columns, $headers), $filename.'.xls');
|
||||
}
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
if(!session('filter_lead_type_id')){
|
||||
session(['filter_lead_type_id' => 'all']);
|
||||
}
|
||||
if(Request::get('filter_lead_type_id')){
|
||||
session(['filter_lead_type_id' => Request::get('filter_lead_type_id')]);
|
||||
}
|
||||
}
|
||||
|
||||
private function initSearch(){
|
||||
$this->setFilterVars();
|
||||
$query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)->where('users.admin', "<", 4);
|
||||
if(session('filter_lead_type_id') && session('filter_lead_type_id') !== null && session('filter_lead_type_id') !== "all"){
|
||||
$query->where('lead_type_id', session('filter_lead_type_id'));
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getLeads()
|
||||
{
|
||||
$query = $this->initSearch();
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('first_name', function (User $user) {
|
||||
return $user->account ? $user->account->first_name : '';
|
||||
})
|
||||
->addColumn('company', function (User $user) {
|
||||
return $user->account ? $user->account->company : '';
|
||||
})
|
||||
->addColumn('last_name', function (User $user) {
|
||||
return $user->account ? $user->account->last_name : '';
|
||||
})
|
||||
->addColumn('user_level', function (User $user) {
|
||||
return $user->user_level ? $user->user_level->name : '';
|
||||
})
|
||||
->addColumn('lead_type', function (User $user) {
|
||||
return $user->lead_type ? $user->lead_type->name : '';
|
||||
})
|
||||
->addColumn('id', function (User $user) {
|
||||
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('active', function (User $user) {
|
||||
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('agreement', function (User $user) {
|
||||
return $user->agreement ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('payment_account', function (User $user) {
|
||||
return $user->payment_account ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('payment_account_date', function (User $user) {
|
||||
return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-";
|
||||
})
|
||||
/*->addColumn('payment_shop', function (User $user) {
|
||||
return $user->payment_shop ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('payment_shop_date', function (User $user) {
|
||||
return $user->payment_shop ? $user->getPaymentShopDateFormat(false) : "-";
|
||||
})*/
|
||||
->addColumn('turnover', function (User $user) {
|
||||
return "-";
|
||||
})
|
||||
->addColumn('sales_total', function (User $user) {
|
||||
return "-";
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('confirmed', 'confirmed $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
->orderColumn('lead_type', 'lead_type_id $1')
|
||||
->orderColumn('agreement', 'agreement $1')
|
||||
->orderColumn('payment_account', 'payment_account $1')
|
||||
//->orderColumn('payment_shop', 'payment_shop $1')
|
||||
->rawColumns(['id', 'confirmed', 'active', 'agreement', 'payment_account'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
private function activeAccountPayment($user){
|
||||
|
||||
if($user->user_level){
|
||||
if($user->user_level->payment_year){
|
||||
//if true = payments
|
||||
$user->wizard = 20;
|
||||
$user->active = 1;
|
||||
$user->active_date = now();
|
||||
$user->confirmation_code = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
}else{
|
||||
//if false = no payments for 1 year
|
||||
$user->wizard = 100;
|
||||
$user->payment_account = \Carbon::now()->modify('1 year');
|
||||
$user->active = 1;
|
||||
$user->active_date = now();
|
||||
$user->confirmation_code = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//user released when register is complete
|
||||
public function released($action, $id){
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
if($action === 'completed'){
|
||||
|
|
@ -299,7 +536,7 @@ class LeadController extends Controller
|
|||
\Session()->flash('alert-success', "E-Mail an Vertriebspartner gesendet.");
|
||||
}
|
||||
if($action === 'reset_switch'){
|
||||
$user->wizard = 4;
|
||||
$user->wizard = 3;
|
||||
$user->save();
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'reset_switch', 'status'=>0]);
|
||||
\Session()->flash('alert-success', "Vertriebspartner zurückgesetzt!");
|
||||
|
|
@ -353,7 +590,9 @@ class LeadController extends Controller
|
|||
|
||||
|
||||
//send new verfified mail to user
|
||||
public function newMailVerified($id){
|
||||
/* public function newMailVerified($id){
|
||||
|
||||
User Register sind in der DB UserRegister, erst bei bestätigung wird es in die User DB übertragen
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
|
|
@ -378,7 +617,7 @@ class LeadController extends Controller
|
|||
\Session()->flash('alert-success', "E-Mail erneut gesendet");
|
||||
return redirect(route('admin_lead_edit', [$user->id]));
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
public function deleteFile($user_id, $file_id, $relation){
|
||||
|
||||
|
|
@ -392,89 +631,4 @@ class LeadController extends Controller
|
|||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
public function getLeads()
|
||||
{
|
||||
|
||||
$query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)->where('users.admin', "<", 4);
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('first_name', function (User $user) {
|
||||
return $user->account ? $user->account->first_name : '';
|
||||
})
|
||||
->addColumn('company', function (User $user) {
|
||||
return $user->account ? $user->account->company : '';
|
||||
})
|
||||
->addColumn('last_name', function (User $user) {
|
||||
return $user->account ? $user->account->last_name : '';
|
||||
})
|
||||
->addColumn('user_level', function (User $user) {
|
||||
return $user->user_level ? $user->user_level->name : '';
|
||||
})
|
||||
->addColumn('id', function (User $user) {
|
||||
return '<a href="' . route('admin_lead_edit', [$user->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('confirmed', function (User $user) {
|
||||
return $user->confirmed ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('active', function (User $user) {
|
||||
return $user->active ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('agreement', function (User $user) {
|
||||
return $user->agreement ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('payment_account', function (User $user) {
|
||||
return $user->payment_account ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('payment_account_date', function (User $user) {
|
||||
return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-";
|
||||
})
|
||||
/*->addColumn('payment_shop', function (User $user) {
|
||||
return $user->payment_shop ? ' <span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('payment_shop_date', function (User $user) {
|
||||
return $user->payment_shop ? $user->getPaymentShopDateFormat(false) : "-";
|
||||
})*/
|
||||
->addColumn('turnover', function (User $user) {
|
||||
return "-";
|
||||
})
|
||||
->addColumn('sales_total', function (User $user) {
|
||||
return "-";
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('confirmed', 'confirmed $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
->orderColumn('agreement', 'agreement $1')
|
||||
->orderColumn('payment_account', 'payment_account $1')
|
||||
//->orderColumn('payment_shop', 'payment_shop $1')
|
||||
->rawColumns(['id', 'confirmed', 'active', 'agreement', 'payment_account'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
private function activeAccountPayment($user){
|
||||
|
||||
if($user->user_level){
|
||||
if($user->user_level->payment_year){
|
||||
//if true = payments
|
||||
$user->wizard = 20;
|
||||
$user->active = 1;
|
||||
$user->active_date = now();
|
||||
$user->confirmation_code = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
}else{
|
||||
//if false = no payments for 1 year
|
||||
$user->wizard = 100;
|
||||
$user->payment_account = \Carbon::now()->modify('1 year');
|
||||
$user->active = 1;
|
||||
$user->active_date = now();
|
||||
$user->confirmation_code = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
47
app/Http/Controllers/LeadTypeController.php
Normal file
47
app/Http/Controllers/LeadTypeController.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use App\Models\LeadType;
|
||||
use Request;
|
||||
|
||||
|
||||
class LeadTypeController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'values' => LeadType::all(),
|
||||
];
|
||||
return view('admin.lead.types', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
if($data['id'] === "new"){
|
||||
$model = LeadType::create([
|
||||
'name' => $data['name'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
]);
|
||||
}else{
|
||||
$model = LeadType::find($data['id']);
|
||||
$model->name = $data['name'];
|
||||
$model->active = isset($data['active']) ? true : false;
|
||||
$model->save();
|
||||
}
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_lead_types'));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -99,6 +99,17 @@ class MembershipController extends Controller
|
|||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$qty = Request::get('qty') ? Request::get('qty') : 1;
|
||||
|
||||
/* //need setGlobalTaxRate
|
||||
|
||||
$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]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||
}
|
||||
*/
|
||||
//Keine steuer
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
Yard::instance('shopping')->setGlobalTaxRate(0);
|
||||
/*
|
||||
|
|
@ -161,6 +172,8 @@ class MembershipController extends Controller
|
|||
if($action === "change_level"){
|
||||
if(Request::get('switchers-package-level')){
|
||||
$user = User::find(Auth::user()->id);
|
||||
//hier wird die nächste Mitgliedschaftsstufe gesetzt
|
||||
//wird im Cronjob UserCheckPaymentsAccounts.php verwendet und gesetzt
|
||||
$user->next_m_level = Request::get('switchers-package-level');
|
||||
$user->save();
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>10, 'referenz'=>Request::get('switchers-package-level')]);
|
||||
|
|
|
|||
|
|
@ -177,11 +177,18 @@ class PayController extends Controller
|
|||
]);
|
||||
//paypal
|
||||
if($this->payment_method === 'pp'){
|
||||
$paypal = new PayPalController;
|
||||
$redirect = $paypal->payment($this->shopping_payment, $payt, $identifier, $this->shopping_order->promotion_user_id);
|
||||
Util::setUserHistoryValue(['status'=>4], $identifier);
|
||||
return $redirect;
|
||||
|
||||
switch ($payment_for) {
|
||||
case 7: //promotion
|
||||
$paypal = new PayPalController;
|
||||
$redirect = $paypal->payment($this->shopping_payment, $payt, $identifier, $payment_for, $this->shopping_order->promotion_user_id);
|
||||
Util::setUserHistoryValue(['status'=>4], $identifier);
|
||||
return $redirect;
|
||||
case 8: //shop
|
||||
$paypal = new PayPalController;
|
||||
$redirect = $paypal->payment($this->shopping_payment, $payt, $identifier, $payment_for, $this->shopping_order->user_shop_id);
|
||||
Util::setUserHistoryValue(['status'=>4], $identifier);
|
||||
return $redirect;
|
||||
}
|
||||
}
|
||||
|
||||
Util::setUserHistoryValue(['status'=>5], $identifier);
|
||||
|
|
@ -189,7 +196,10 @@ class PayController extends Controller
|
|||
case 7: //promotion
|
||||
return redirect(route('web_promotion_goto', ['thanksorder', $this->shopping_order->promotion_user_id, $payt->id, $this->reference, $identifier]));
|
||||
break;
|
||||
|
||||
case 8: //shop
|
||||
return redirect(route('web_shop_goto', ['thanksorder', $this->shopping_order->user_shop_id, $payt->id, $this->reference, $identifier]));
|
||||
break;
|
||||
|
||||
default:
|
||||
return redirect(route('user_checkout_final', [$payt->id, $this->reference, $identifier]));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace App\Http\Controllers\Pay;
|
||||
use Request;
|
||||
use App\Models\UserShop;
|
||||
use App\Models\PromotionUser;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
|
@ -12,7 +13,7 @@ use Srmklive\PayPal\Services\PayPal as PayPalClient;
|
|||
class PayPalController extends Controller
|
||||
{
|
||||
|
||||
public function payment($shopping_payment, $payt, $identifier, $promotion_user_id)
|
||||
public function payment($shopping_payment, $payt, $identifier, $payment_for, $payment_for_user_id)
|
||||
{
|
||||
$provider = new PayPalClient;
|
||||
// Through facade. No need to import namespaces
|
||||
|
|
@ -36,8 +37,8 @@ class PayPalController extends Controller
|
|||
]
|
||||
],
|
||||
'application_context' => [
|
||||
'cancel_url' => route('cancel.paypal_payment', [$promotion_user_id, $payt->id, $shopping_payment->reference, $identifier]),
|
||||
'return_url' => route('success.paypal_payment', [$promotion_user_id, $payt->id, $shopping_payment->reference, $identifier])
|
||||
'cancel_url' => route('cancel.paypal_payment', [$payment_for, $payment_for_user_id, $payt->id, $shopping_payment->reference, $identifier]),
|
||||
'return_url' => route('success.paypal_payment', [$payment_for, $payment_for_user_id, $payt->id, $shopping_payment->reference, $identifier])
|
||||
]
|
||||
|
||||
]);
|
||||
|
|
@ -47,9 +48,8 @@ class PayPalController extends Controller
|
|||
|
||||
}
|
||||
|
||||
public function paymentSuccess($id, $transactionId=false, $reference=false, $identifier=false)
|
||||
public function paymentSuccess($payment_for, $id, $transactionId=false, $reference=false, $identifier=false)
|
||||
{
|
||||
$PromotionUser = PromotionUser::findOrFail($id);
|
||||
$payt = PaymentTransaction::findOrFail($transactionId);
|
||||
if($payt->shopping_payment->reference != $reference){
|
||||
abort(404);
|
||||
|
|
@ -74,16 +74,34 @@ class PayPalController extends Controller
|
|||
}
|
||||
$payt->request = $order['status'];
|
||||
$payt->save();
|
||||
return redirect(route('web_promotion_goto', ['thanksorder', $id, $payt->id, $reference, $identifier]));
|
||||
|
||||
switch ($payment_for) {
|
||||
case 7: //promotion
|
||||
$PromotionUser = PromotionUser::findOrFail($id);
|
||||
return redirect(route('web_promotion_goto', ['thanksorder', $id, $payt->id, $reference, $identifier]));
|
||||
case 8: //shop
|
||||
$userShop = UserShop::findOrFail($id);
|
||||
return redirect(route('web_shop_goto', ['thanksorder', $id, $payt->id, $reference, $identifier]));
|
||||
dd('Your payment has been declend. The payment cancelation page goes here!');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function paymentCancel($id, $transactionId=false, $reference=false, $identifier=false)
|
||||
public function paymentCancel($payment_for, $id, $transactionId=false, $reference=false, $identifier=false)
|
||||
{
|
||||
$PromotionUser = PromotionUser::findOrFail($id);
|
||||
|
||||
return redirect(url($PromotionUser->url));
|
||||
dd('Your payment has been declend. The payment cancelation page goes here!');
|
||||
switch ($payment_for) {
|
||||
case 7: //promotion
|
||||
$PromotionUser = PromotionUser::findOrFail($id);
|
||||
return redirect(url($PromotionUser->url));
|
||||
dd('Your payment has been declend. The payment cancelation page goes here!');
|
||||
case 8: //shop
|
||||
$userShop = UserShop::findOrFail($id);
|
||||
return redirect(url($userShop->url));
|
||||
dd('Your payment has been declend. The payment cancelation page goes here!');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,17 +4,18 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Models\UserCreditMargin as ModelsUserCreditMargin;
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Services\Util;
|
||||
use App\Services\Credit;
|
||||
use App\Services\Payment;
|
||||
use App\Models\UserCredit;
|
||||
use App\Models\ShoppingOrderMargin;
|
||||
use App\Models\UserCredit;
|
||||
use App\Models\UserCreditMargin;
|
||||
use App\Repositories\CreditRepository;
|
||||
use App\Services\Credit;
|
||||
use App\Services\Payment;
|
||||
use App\Services\Payment\UserBot;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Request;
|
||||
|
||||
class PaymentCreditController extends Controller
|
||||
{
|
||||
|
|
@ -23,10 +24,12 @@ class PaymentCreditController extends Controller
|
|||
private $endYear;
|
||||
private $rangeYears;
|
||||
private $activeYear;
|
||||
private $userBot;
|
||||
|
||||
public function __construct()
|
||||
public function __construct(UserBot $userBot)
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->userBot = $userBot;
|
||||
$this->startYear = 2021;
|
||||
$this->endYear = date('Y');
|
||||
$this->rangeYears = range($this->startYear, $this->endYear);
|
||||
|
|
@ -41,7 +44,11 @@ class PaymentCreditController extends Controller
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* fügt eine neue Manuelle Gutschrift hinzu
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(){
|
||||
$data = Request::all();
|
||||
|
||||
|
|
@ -64,7 +71,6 @@ class PaymentCreditController extends Controller
|
|||
|
||||
$credit = Util::reFormatNumber($data['credit']);
|
||||
$credit = number_format($credit, 2, '.', '');
|
||||
|
||||
Payment::addUserCreditMargin($user, $credit, 3, $data['message']);
|
||||
\Session()->flash('alert-success', "Guthaben hinzugefügt");
|
||||
}
|
||||
|
|
@ -72,6 +78,11 @@ class PaymentCreditController extends Controller
|
|||
return redirect(route('admin_payments_credit'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt eine neue komplette Gutschrift für einen Benutzer
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function create(){
|
||||
$data = Request::all();
|
||||
if(isset($data['action'])){
|
||||
|
|
@ -95,65 +106,18 @@ class PaymentCreditController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
private function makeData(){
|
||||
private function makeData(): array
|
||||
{
|
||||
$this->setActiveYears();
|
||||
//$date1 = Carbon::parse('01.01.'.$this->activeYear." 00:00:00")->format('Y-m-d H:i:s');
|
||||
//$date2 = Carbon::parse('31.12.'.$this->activeYear." 23:59:59")->toDateString();
|
||||
|
||||
$ShoppingOrderMargins = ShoppingOrderMargin::join('users', 'm_sponsor_id', '=', 'users.id')
|
||||
->groupBy('m_sponsor_id')
|
||||
->join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.id as user_id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->wherePaid(true)
|
||||
->whereCancellation(false)
|
||||
->wherePartnerCommissionPaid(false)
|
||||
->where('partner_commission_pending_to', '<', Carbon::now())
|
||||
->get();
|
||||
|
||||
$ShoppingOrderMarginPendings = ShoppingOrderMargin::join('users', 'm_sponsor_id', '=', 'users.id')
|
||||
->groupBy('m_sponsor_id')
|
||||
->join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.id as user_id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->wherePaid(true)
|
||||
->whereCancellation(false)
|
||||
->wherePartnerCommissionPaid(false)
|
||||
->where('partner_commission_pending_to', '>=', Carbon::now())
|
||||
->get();
|
||||
|
||||
$UserCreditMargins = UserCreditMargin::wherePaid(false)->get();
|
||||
$ShoppingOrderMarginUserIds = ShoppingOrderMargin::select('m_sponsor_id')->groupBy('m_sponsor_id')
|
||||
->wherePaid(true)
|
||||
->whereCancellation(false)
|
||||
->wherePartnerCommissionPaid(false)
|
||||
->where('partner_commission_pending_to', '<', Carbon::now())
|
||||
->get()->pluck('m_sponsor_id')->toArray();
|
||||
$this->userBot->readUserHasCredits();
|
||||
$this->userBot->readUserHasPendingCredit();
|
||||
|
||||
$onlyUserCreditMargins = [];
|
||||
foreach($UserCreditMargins as $key => $UserCreditMargin){
|
||||
if(!in_array($UserCreditMargin->user_id, $ShoppingOrderMarginUserIds)){
|
||||
if(isset($onlyUserCreditMargins[$UserCreditMargin->user_id])){
|
||||
$onlyUserCreditMargins[$UserCreditMargin->user_id]['sum'] += $UserCreditMargin->credit;
|
||||
$onlyUserCreditMargins[$UserCreditMargin->user_id]['entries'][$UserCreditMargin->id] = $UserCreditMargin;
|
||||
}else{
|
||||
$onlyUserCreditMargins[$UserCreditMargin->user_id] = [
|
||||
'user_id' => $UserCreditMargin->user->id,
|
||||
'first_name' => $UserCreditMargin->user->account->first_name,
|
||||
'last_name' => $UserCreditMargin->user->account->last_name,
|
||||
'email' => $UserCreditMargin->user->email,
|
||||
'sum' => $UserCreditMargin->credit,
|
||||
'entries' => [$UserCreditMargin->id => $UserCreditMargin],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
return [
|
||||
'years' => $this->rangeYears,
|
||||
'active_year' => $this->activeYear,
|
||||
'ShoppingOrderMargins' => $ShoppingOrderMargins,
|
||||
'ShoppingOrderMarginPendings' => $ShoppingOrderMarginPendings,
|
||||
'onlyUserCreditMargins' => $onlyUserCreditMargins,
|
||||
'users_credits' => $this->userBot->getUsers(),
|
||||
'users_credits_pending' => $this->userBot->getUsersPending(),
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function setActiveYears(){
|
||||
|
|
@ -173,19 +137,25 @@ class PaymentCreditController extends Controller
|
|||
\Session()->flash('alert-error', "Guthaben kann nicht gelöscht werden");
|
||||
}
|
||||
}
|
||||
if($del === 'shopping_order_margin'){
|
||||
$ShoppingOrderMargin = ShoppingOrderMargin::findOrFail($id);
|
||||
$ShoppingOrderMargin->out_paid = true;
|
||||
$ShoppingOrderMargin->save();
|
||||
\Session()->flash('alert-success', "Gutschrift ist gelöscht");
|
||||
}
|
||||
return redirect(route('admin_payments_credit'));
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$this->setActiveYears();
|
||||
$date1 = Carbon::parse('01.01.'.$this->activeYear)->format('Y-m-d');
|
||||
$date2 = Carbon::parse('31.12.'.$this->activeYear)->format('Y-m-d');
|
||||
$startDate = Carbon::parse("01.01.{$this->activeYear}")->format('Y-m-d');
|
||||
$endDate = Carbon::parse("31.12.{$this->activeYear}")->format('Y-m-d');
|
||||
|
||||
$query = UserCredit::with('user', 'user.account')->select('user_credits.*')
|
||||
//::with('shopping_user', )->select('shopping_orders.*')
|
||||
//->where('paid', '=', 1)
|
||||
->whereBetween('date', [$date1, $date2]);
|
||||
->whereBetween('date', [$startDate, $endDate]);
|
||||
//->orderBy('created_at', 'DESC');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class PaymentInvoiceController extends Controller
|
|||
return Payment::getShoppingOrderBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
|
||||
return Payment::getPaymentForTypeBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
|
||||
$ret = "";
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace App\Http\Controllers;
|
|||
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\UserLevel;
|
||||
use Request;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,75 +136,16 @@ class ProductController extends Controller
|
|||
// Upload FILE -----------------------------------------------------------------------------------------------------------------------
|
||||
public function imageUpload(){
|
||||
|
||||
$product_id = Request::get('product_id');
|
||||
$product = Product::findOrFail($product_id);
|
||||
|
||||
try {
|
||||
$image = \App\Services\Slim::getImages('images')[0];
|
||||
|
||||
if ( isset($image['output']['data']) )
|
||||
{
|
||||
|
||||
// Base64 of the image
|
||||
$data = $image['output']['data'];
|
||||
$file_ex = array( 'image/jpeg' => 'jpg', 'image/png' => 'png');
|
||||
|
||||
if (!isset($file_ex[$image['output']['type']])) {
|
||||
\Session()->flash('alert-danger', 'File is not jpg or png!');
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
|
||||
$ext = $file_ex[$image['output']['type']];
|
||||
// Original file name
|
||||
$name = $image['output']['name'];
|
||||
$name = \App\Services\Slim::sanitizeFileName($name);
|
||||
$name = uniqid() . '_' . $name;
|
||||
|
||||
$data = \Storage::disk('public')->put(
|
||||
'images/product/'.$product->id.'/'.$name,
|
||||
$data
|
||||
);
|
||||
|
||||
ProductImage::create([
|
||||
'product_id' => $product->id,
|
||||
'filename' => $name,
|
||||
'original_name' => $image['output']['name'],
|
||||
'ext' => $ext,
|
||||
'mine' => $image['output']['type'],
|
||||
'size' => $image['input']['size']
|
||||
]);
|
||||
|
||||
|
||||
\Session()->flash('alert-success', "Datei hochgeladen");
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
}
|
||||
\Session()->flash('alert-danger', "Datei leer");
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
\Session()->flash('alert-danger', "Fehler".$e);
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
if(Request::has('product_id')){
|
||||
$product = Product::findOrFail(Request::get('product_id'));
|
||||
return \App\Services\ProductImage::imageUpload('product', $product, Request::get('upload_type'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function imageDelete($image_id, $product_id){
|
||||
|
||||
public function imageDelete($product_image_id, $product_id){
|
||||
$product = Product::findOrFail($product_id);
|
||||
$product_image = ProductImage::findOrFail($image_id);
|
||||
|
||||
if($product_image->product_id == $product->id){
|
||||
$file = 'images/product/'.$product->id.'/'.$product_image->filename;
|
||||
\Storage::disk('public')->delete($file);
|
||||
|
||||
$product_image->delete();
|
||||
|
||||
\Session()->flash('alert-success', "Datei gelöscht");
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
|
||||
}
|
||||
\Session()->flash('alert-danger', "Datei nicht gefunden");
|
||||
return redirect(route('admin_product_edit', [$product->id]));
|
||||
return \App\Services\ProductImage::imageDelete('product', $product, $product_image_id);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,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::getPaymentForTypeBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
|
|
@ -210,7 +210,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::getPaymentForTypeBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
|
|
@ -246,43 +246,59 @@ class SalesController extends Controller
|
|||
abort(404);
|
||||
}
|
||||
if(isset($data['action'])){
|
||||
|
||||
if($data['action'] === 'store_shipped' && isset($data['shipped'])){
|
||||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
$shopping_order->shipped = $data['shipped'];
|
||||
$shopping_order->save();
|
||||
//handel Promotion Product and credit by storno
|
||||
Payment::handelUserPromotionOrder($shopping_order);
|
||||
Payment::handelUserShopOrder($shopping_order);
|
||||
|
||||
if($shopping_order->getAPIShippedType() === 'sent' || $shopping_order->getAPIShippedType() === 'close'){
|
||||
if(!$shopping_order->shipped_at){
|
||||
$shopping_order->shipped_at = now();
|
||||
$shopping_order->save();
|
||||
//set to oder_margin
|
||||
if($shopping_order->shopping_order_margin && $shopping_order->shopping_order_margin->hasPartnerCommission()){
|
||||
//is shipped set pending_to
|
||||
if($shopping_order->shopping_order_margin){
|
||||
if($shopping_order->shopping_order_margin->hasPartnerCommission()){
|
||||
$days = Setting::getContentBySlug('pending_partner_commissions_in_days');
|
||||
$days = $days ? $days : 20;
|
||||
$partner_commission_pending_to = $shopping_order->shipped_at;
|
||||
$partner_commission_pending_to->addDays($days);
|
||||
$shopping_order->shopping_order_margin->partner_commission_pending_to = $partner_commission_pending_to;
|
||||
$shopping_order->shopping_order_margin->save();
|
||||
$days = $days ? $days : 20;
|
||||
$partner_commission_pending_to = $shopping_order->shipped_at;
|
||||
$partner_commission_pending_to->addDays($days);
|
||||
$shopping_order->shopping_order_margin->partner_commission_pending_to = $partner_commission_pending_to;
|
||||
$shopping_order->shopping_order_margin->save();
|
||||
}else{
|
||||
$days = Setting::getContentBySlug('pending_order_margins_in_days');
|
||||
$days = $days ? $days : 20;
|
||||
$margin_pending_to = $shopping_order->shipped_at;
|
||||
$margin_pending_to->addDays($days);
|
||||
$shopping_order->shopping_order_margin->margin_pending_to = $margin_pending_to;
|
||||
$shopping_order->shopping_order_margin->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$shopping_order->shipped_at = null;
|
||||
$shopping_order->save();
|
||||
if($shopping_order->shopping_order_margin && $shopping_order->shopping_order_margin->hasPartnerCommission()){
|
||||
if($shopping_order->shopping_order_margin){
|
||||
//zurücksetzen der pending_to
|
||||
$shopping_order->shopping_order_margin->partner_commission_pending_to = null;
|
||||
$shopping_order->shopping_order_margin->margin_pending_to = null;
|
||||
$shopping_order->shopping_order_margin->save();
|
||||
}
|
||||
}
|
||||
if($shopping_order->getAPIShippedType() === 'cancel'){
|
||||
if($shopping_order->shopping_order_margin){
|
||||
$shopping_order->shopping_order_margin->cancellation = true;
|
||||
$shopping_order->shopping_order_margin->partner_commission_pending_to = null;
|
||||
$shopping_order->shopping_order_margin->margin_pending_to = null;
|
||||
$shopping_order->shopping_order_margin->save();
|
||||
}
|
||||
}else{
|
||||
if($shopping_order->shopping_order_margin && $shopping_order->shopping_order_margin->cancellation){
|
||||
$shopping_order->shopping_order_margin->cancellation = false;
|
||||
$shopping_order->shopping_order_margin->partner_commission_pending_to = null;
|
||||
$shopping_order->shopping_order_margin->margin_pending_to = null;
|
||||
$shopping_order->shopping_order_margin->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -326,10 +342,10 @@ class SalesController extends Controller
|
|||
$shopping_order->save();
|
||||
$shopping_payment->txaction = $data['txaction'];
|
||||
$shopping_payment->save();
|
||||
|
||||
if($payt->status === 'vor' && $payt->txaction === 'paid'){
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||
}
|
||||
|
||||
//handel credit loading by change when by $shopping_order_item->handl
|
||||
if($shopping_order->shopping_user->is_for === 'cr'){
|
||||
$last_UserPayCredit = UserPayCredit::where('shopping_order_id', $shopping_order->id)->whereIn('status', [7, 8])->orderBy('id', 'DESC')->first();
|
||||
|
|
|
|||
193
app/Http/Controllers/Stats/SalesController.php
Executable file
193
app/Http/Controllers/Stats/SalesController.php
Executable file
|
|
@ -0,0 +1,193 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\Stats;
|
||||
|
||||
use Auth;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Faker\Core\Number;
|
||||
use App\Exports\ExcelExport;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\Stats\Sales;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Services\BusinessPlan\ExportBot;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class SalesController extends Controller
|
||||
{
|
||||
|
||||
private $serviceSales;
|
||||
|
||||
public function __construct(Sales $serviceSales)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->serviceSales = $serviceSales;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(true),
|
||||
'filter_years' => HTMLHelper::getYearRange(2020),
|
||||
'filter_products' => $this->serviceSales->setFilterProducts(),
|
||||
];
|
||||
return view('admin.stats.salesvolume', $data);
|
||||
}
|
||||
|
||||
|
||||
public function download()
|
||||
{
|
||||
|
||||
$this->setFilterVars();
|
||||
|
||||
if (Request::get('action') === "filter") {
|
||||
// $data = Request::all();
|
||||
return back();
|
||||
}
|
||||
|
||||
if (Request::get('action') === "export") {
|
||||
$objects = $this->serviceSales->getObjects();
|
||||
$columns = [];
|
||||
$filename = "gs-absatzmengen-" . session('product_sales_vol_filter_month') . '_' . session('product_sales_vol_filter_year') . "-export";
|
||||
$headers = array(
|
||||
'#',
|
||||
'Produkt',
|
||||
'Artikelnummer',
|
||||
'Menge',
|
||||
'Gesamt Netto in EURO',
|
||||
'Vorjahr Menge',
|
||||
'Vorjahr Gesamt Netto in EURO',
|
||||
'Einzelrabatt',
|
||||
'Einzelrabatt %',
|
||||
'VP Einzelrabatt %',
|
||||
|
||||
|
||||
);
|
||||
if ($objects) {
|
||||
foreach ($objects as $key => $obj) {
|
||||
$columns[] = array(
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'qty' => $obj['qty'],
|
||||
'total' => $obj['total'],
|
||||
'pre_qty' => $obj['pre_qty'],
|
||||
'pre_total' => $obj['pre_total'],
|
||||
'single_commission' => $obj['single_commission'],
|
||||
'value_commission' => $obj['value_commission'],
|
||||
'partner_commission' => $obj['partner_commission'],
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
return Excel::download(new ExcelExport($columns, $headers), $filename . '.xls');
|
||||
}
|
||||
}
|
||||
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if (!session('product_sales_vol_filter_month')) {
|
||||
session(['product_sales_vol_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if (!session('product_sales_vol_filter_year')) {
|
||||
session(['product_sales_vol_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if (!session('product_sales_vol_filter_products')) {
|
||||
session(['product_sales_vol_filter_products' => []]);
|
||||
}
|
||||
if (Request::get('product_sales_vol_filter_month')) {
|
||||
session(['product_sales_vol_filter_month' => Request::get('product_sales_vol_filter_month')]);
|
||||
}
|
||||
if (Request::get('product_sales_vol_filter_year')) {
|
||||
session(['product_sales_vol_filter_year' => Request::get('product_sales_vol_filter_year')]);
|
||||
}
|
||||
if (Request::get('product_sales_vol_filter_products')) {
|
||||
session(['product_sales_vol_filter_products' => Request::get('product_sales_vol_filter_products')]);
|
||||
}
|
||||
|
||||
$this->serviceSales->setFilterVars(
|
||||
session('product_sales_vol_filter_month'),
|
||||
session('product_sales_vol_filter_year'),
|
||||
session('product_sales_vol_filter_products')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$this->setFilterVars();
|
||||
$collection = $this->serviceSales->getCollection();
|
||||
|
||||
/* $collect = collect([
|
||||
['id' => 1, 'name' => 'John', 'number'=>92012, 'value'=>123],
|
||||
['id' => 2, 'name' => 'Jane', 'number'=>92012, 'value'=>123],
|
||||
['id' => 3, 'name' => 'James', 'number'=>92012, 'value'=>123],
|
||||
]);
|
||||
*/
|
||||
|
||||
return \DataTables::of($collection)->toJson();
|
||||
}
|
||||
|
||||
/*private function testCheckFunction(){
|
||||
|
||||
//$date_start = Carbon::parse('01.'.session('product_sales_vol_filter_month').'.'.session('product_sales_vol_filter_year'))->format('Y-m-d');
|
||||
//$date_end = Carbon::parse('01.'.session('product_sales_vol_filter_month').'.'.session('product_sales_vol_filter_year'))->endOfMonth()->format('Y-m-d');
|
||||
|
||||
$date_start = Carbon::parse('01.01.2024')->format('Y-m-d H:i:s');
|
||||
$date_end = Carbon::parse('01.01.2024')->endOfMonth()->format('Y-m-d H:i:s');
|
||||
dump($date_start);
|
||||
dump($date_end);
|
||||
|
||||
$ShoppingOrders = ShoppingOrder::where('mode', 'live')->whereBetween('created_at', [$date_start, $date_end])->get();
|
||||
|
||||
$objects = [];
|
||||
$counter = 0;
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){
|
||||
|
||||
if($shopping_order_item->product){
|
||||
if($shopping_order_item->product->id === 122){
|
||||
//dump($shopping_order_item->qty);
|
||||
//$counter += $shopping_order_item->qty;
|
||||
if(isset($objects[$shopping_order_item->product->id])){
|
||||
$value = intval($objects[$shopping_order_item->product->id]['value'] + $shopping_order_item->qty);
|
||||
$objects[$shopping_order_item->product->id]['value'] = $value;
|
||||
}else{
|
||||
$objects[$shopping_order_item->product->id] = [
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'value' => $shopping_order_item->qty
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$ShoppingOrderItems = ShoppingOrderItem::whereProductId(122)->whereBetween('created_at', [$date_start, $date_end])->get();
|
||||
$counter = 0;
|
||||
foreach($ShoppingOrderItems as $ShoppingOrderItem){
|
||||
$counter += $ShoppingOrderItem->qty;
|
||||
dump($ShoppingOrderItem->id);
|
||||
}
|
||||
// dump($objects);
|
||||
dump($counter);
|
||||
dd("OKAY");
|
||||
}*/
|
||||
}
|
||||
|
|
@ -285,7 +285,7 @@ class AdminToolsController extends Controller
|
|||
$text = "";
|
||||
|
||||
$kas = new KasController();
|
||||
$domain = 'mivita.care';
|
||||
$domain = 'hier die DOMAIN';
|
||||
|
||||
$ssl = KasSLLController::getApiSSLParameter();
|
||||
|
||||
|
|
|
|||
|
|
@ -498,11 +498,16 @@ class CheckoutController extends Controller
|
|||
'net_amount' => Yard::instance('shopping')->getYardMargin()->net_amount,
|
||||
'from_payment_credit' => Yard::instance('shopping')->totalfromCredit(2, '.', ''),
|
||||
'from' => now(),
|
||||
'status' => $shopping_order->payment_for, //7 => 'from promotion', 8 => 'from shop',
|
||||
'content' => serialize(Yard::instance('shopping')->getYardMargin()->toArray())
|
||||
];
|
||||
if(Yard::instance('shopping')->getYardMargin()->net_partner_commission > 0){
|
||||
$data['m_sponsor_id'] = $shopping_order->auth_user->m_sponsor;
|
||||
$data['net_partner_commission'] = Yard::instance('shopping')->getYardMargin()->net_partner_commission;
|
||||
if(isset($shopping_order->auth_user->m_sponsor)){
|
||||
if($shopping_order->auth_user->user_sponsor && $shopping_order->auth_user->user_sponsor->isActiveAccount()){
|
||||
$data['m_sponsor_id'] = $shopping_order->auth_user->m_sponsor;
|
||||
$data['net_partner_commission'] = Yard::instance('shopping')->getYardMargin()->net_partner_commission;
|
||||
}
|
||||
}
|
||||
}
|
||||
$shopping_order_margin = false;
|
||||
if ($this->getPayments('shopping_order_margin_id')) {
|
||||
|
|
|
|||
|
|
@ -370,7 +370,11 @@ class HomepartyController extends Controller
|
|||
$date = date('d.m.Y H:i:s', $time);
|
||||
$user = User::find(Auth::user()->id);
|
||||
Yard::instance('shopping')->destroy();
|
||||
Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty '.$date, 1, \App\Services\HomepartyCart::$price, ['image' => "", 'slug' => $time, 'weight' => 0]);
|
||||
die("STOP nicht getestet");
|
||||
Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty '.$date, 1, \App\Services\HomepartyCart::$price, /*need TAX*/ 1, ['image' => "", 'slug' => $time, 'weight' => 0]);
|
||||
|
||||
// $cartItem = Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty '.$date, 1, \App\Services\HomepartyCart::$ek_price, false, false, ['image' => "", 'slug' => $time, 'weight' => 0]);
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
|
|
|
|||
94
app/Http/Controllers/User/MyOrderController.php
Normal file
94
app/Http/Controllers/User/MyOrderController.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
use Auth;
|
||||
use Yard;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use App\Services\Util;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserShop;
|
||||
use App\Services\Payment;
|
||||
use App\Models\UserHistory;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ProductCategory;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ProductBuy;
|
||||
|
||||
class MyOrderController 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);
|
||||
}
|
||||
$shopping_order->getLastShoppingPayment();
|
||||
|
||||
$data = [
|
||||
'shopping_order' => $shopping_order,
|
||||
'isAdmin' => false,
|
||||
];
|
||||
return view('user.order.detail', $data);
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$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_myorder_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 $ShoppingOrder->getFormattedTotalShipping()." €";
|
||||
})
|
||||
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
|
||||
})
|
||||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return Payment::getPaymentForTypeBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->rawColumns(['id', 'txaction', 'payment_for', 'shipped'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,18 +7,20 @@ use Yard;
|
|||
use Request;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use App\Services\Shop;
|
||||
use App\Services\Util;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserShop;
|
||||
use App\Services\Payment;
|
||||
use App\Models\ProductBuy;
|
||||
use App\Models\UserHistory;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\UserService;
|
||||
use App\Models\ProductCategory;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ProductBuy;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
|
|
@ -28,80 +30,15 @@ class OrderController extends Controller
|
|||
$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);
|
||||
}
|
||||
$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 $ShoppingOrder->getFormattedTotalShipping()." €";
|
||||
})
|
||||
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
|
||||
})
|
||||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
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>';
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->rawColumns(['id', 'txaction', 'payment_for', 'shipped'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
public function delivery($for, $id=null)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
|
||||
$shopping_user = null;
|
||||
$delivery_id = null;
|
||||
if($for === 'ot'){
|
||||
$shopping_user = $this->checkShoppingUser($id, $user);
|
||||
if(strpos($for, 'ot') !== false){
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
$delivery_id = $shopping_user->id;
|
||||
if(!$this->checkShoppingCountry($for, $delivery_id) && !\Session()->has('custom-error')){
|
||||
if(!Shop::checkShoppingCountry($for, $delivery_id) && !\Session()->has('custom-error')){
|
||||
\Session()->flash('custom-error', __('validation.custom.shipping_not_found'));
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
}
|
||||
|
|
@ -109,12 +46,11 @@ class OrderController extends Controller
|
|||
|
||||
if(Request::get('action') === 'next'){
|
||||
Yard::instance('shopping')->destroy();
|
||||
if(Request::get('switchers-radio-is-for') === 'ot'){
|
||||
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,
|
||||
|
|
@ -132,16 +68,23 @@ class OrderController extends Controller
|
|||
$shopping_user = null;
|
||||
$delivery_id = null;
|
||||
|
||||
if($for === 'ot'){
|
||||
$shopping_user = $this->checkShoppingUser($id, $user);
|
||||
if(strpos($for, 'ot') !== false){
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
$delivery_id = $shopping_user->id;
|
||||
}
|
||||
$shipping_country_id = $this->checkShoppingCountry($for, $id);
|
||||
if(!$shipping_country_id){
|
||||
\Session()->flash('custom-error', __('validation.custom.shipping_not_found'));
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
if($for === 'ot-customer'){ //noch nicht implementiert
|
||||
//Liederung an ot-customer (Kunden) Zahlung und Rechnung geht an Kunden
|
||||
UserService::initCustomerYard($shopping_user, $for);
|
||||
}else{
|
||||
//Lieferung an user oder ot-member (Kunden) rechnung geht an User
|
||||
//lieferland und rechnungsland prüfen
|
||||
$shipping_country_id = Shop::checkShoppingCountry($for, $id);
|
||||
if(!$shipping_country_id){
|
||||
\Session()->flash('custom-error', __('validation.custom.shipping_not_found'));
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
}
|
||||
UserService::initUserYard($user, $shipping_country_id, $for);
|
||||
}
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id, $for);
|
||||
|
||||
if($for === 'cr'){
|
||||
Yard::instance('shopping')->setGlobalTaxRate(0);
|
||||
|
|
@ -150,7 +93,6 @@ class OrderController extends Controller
|
|||
}else{
|
||||
Yard::instance('shopping')->setShoppingUser($user, true);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'shopping_user' => $shopping_user,
|
||||
'user' => $user,
|
||||
|
|
@ -183,6 +125,8 @@ class OrderController extends Controller
|
|||
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'])){
|
||||
|
|
@ -211,6 +155,7 @@ class OrderController extends Controller
|
|||
$data['is_from'] = 'user_order';
|
||||
$data['is_for'] = $for;
|
||||
$data['shopping_user_id'] = $id;
|
||||
$data['user_price_infos'] = Yard::instance('shopping')->getUserPriceInfos();
|
||||
unset($data['quantity']);
|
||||
unset($data['_token']);
|
||||
|
||||
|
|
@ -236,48 +181,108 @@ class OrderController extends Controller
|
|||
return redirect(route('user_checkout', [$identifier]));
|
||||
}
|
||||
|
||||
private function checkShoppingCountry($for, $id=null){
|
||||
|
||||
private function checkSendYardForPayment($data, $id){
|
||||
|
||||
$country_id = null;
|
||||
if($for === 'me' || $for === 'mp' || $for === 'cr'){
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if($user->same_as_billing){
|
||||
$country_id = $user->account->country_id;
|
||||
}else{
|
||||
$country_id = $user->account->shipping_country_id;
|
||||
}
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_user = null;
|
||||
if(strpos($data['shipping_is_for'], 'ot') !== false){
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
}
|
||||
if($for === 'ot' && $id){
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->same_as_billing){
|
||||
$country_id = $shopping_user->billing_country_id;
|
||||
}else{
|
||||
$country_id = $shopping_user->shipping_country_id;
|
||||
}
|
||||
|
||||
$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($country_id){
|
||||
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
|
||||
return $shipping_country->id;
|
||||
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'));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
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());
|
||||
//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' && 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'));
|
||||
}
|
||||
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'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function checkShoppingUser($id, $user){
|
||||
if($id === null){
|
||||
abort(403, 'Error: Keine User ID');
|
||||
}
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->member_id !== $user->id){
|
||||
abort(403, 'Error: Falsche User ID');
|
||||
}
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->is_like){
|
||||
abort(403, 'Error: Kunde in Prüfung');
|
||||
}
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
|
|
@ -430,7 +435,11 @@ class OrderController extends Controller
|
|||
}
|
||||
|
||||
//get the card item
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(false, true), $product->tax,
|
||||
|
||||
//Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, $product->tax,
|
||||
//$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), true, Yard::instance('shopping')->getUserCountry()), $product->getTaxWith(Yard::instance('shopping')->getUserCountry()), //$product->tax, true?
|
||||
[
|
||||
'image' => $image,
|
||||
'slug' => $product->slug,
|
||||
|
|
@ -440,7 +449,14 @@ class OrderController extends Controller
|
|||
'value_commission' => $product->value_commission,
|
||||
'partner_commission' => $product->partner_commission,
|
||||
]);
|
||||
Yard::setTax($cartItem->rowId, $product->tax);
|
||||
|
||||
if(Yard::instance('shopping')->getUserTaxFree()){
|
||||
//Yard::setTax($cartItem->rowId, 0);
|
||||
Yard::instance('shopping')->setGlobalTaxRate(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']);
|
||||
|
|
@ -476,7 +492,7 @@ class OrderController extends Controller
|
|||
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);
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country->id, $is_for); //$is_for == 'ot' or 'me'
|
||||
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
|
||||
}
|
||||
}
|
||||
|
|
@ -543,14 +559,29 @@ class OrderController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
private function getCompProducts($for){
|
||||
|
||||
if($for === 'me' && \App\Models\Setting::getContentBySlug('order_partner_is_comp_me')){
|
||||
return Product::whereActive(true)->whereJsonContains('show_on', ['2'])->where('shipping_addon', true)->orderBy('pos', 'DESC')->get();
|
||||
private function getCompProducts($for) {
|
||||
if($for === 'me' && \App\Models\Setting::getContentBySlug('order_partner_is_comp_me')) {
|
||||
return Product::whereActive(true)
|
||||
->where(function($query) {
|
||||
$query->whereRaw("JSON_CONTAINS(show_on, '\"2\"')")
|
||||
->orWhereRaw("JSON_CONTAINS(show_on, '\"11\"')");
|
||||
})
|
||||
->where('shipping_addon', true)
|
||||
->orderBy('pos', 'DESC')
|
||||
->get();
|
||||
}
|
||||
if($for === 'ot' && \App\Models\Setting::getContentBySlug('order_partner_is_comp_ot')){
|
||||
return Product::whereActive(true)->whereJsonContains('show_on', ['1'])->where('shipping_addon', true)->orderBy('pos', 'DESC')->get();
|
||||
|
||||
if($for === 'ot' && \App\Models\Setting::getContentBySlug('order_partner_is_comp_ot')) {
|
||||
return Product::whereActive(true)
|
||||
->where(function($query) {
|
||||
$query->whereRaw("JSON_CONTAINS(show_on, '\"1\"')")
|
||||
->orWhereRaw("JSON_CONTAINS(show_on, '\"11\"')");
|
||||
})
|
||||
->where('shipping_addon', true)
|
||||
->orderBy('pos', 'DESC')
|
||||
->get();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@ class PaymentController extends Controller
|
|||
return nl2br($user_pay_credit->message);
|
||||
}elseif($user_pay_credit->status === 5 || $user_pay_credit->status === 6){
|
||||
return trans('payment.'.$user_pay_credit->message).
|
||||
' <a class="btn btn-outline-secondary btn-xs" href="'.route('user_sales_order_detail', [$user_pay_credit->shopping_order_id]).'"><i class="ion ion-md-eye"></i></a>';
|
||||
' <a class="btn btn-outline-secondary btn-xs" href="'.route('user_sales_detail', [$user_pay_credit->shopping_order_id]).'"><i class="ion ion-md-eye"></i></a>';
|
||||
}else{
|
||||
return trans('payment.'.$user_pay_credit->message).
|
||||
' <a class="btn btn-outline-secondary btn-xs" href="'.route('user_order_detail', [$user_pay_credit->shopping_order_id]).'"><i class="ion ion-md-eye"></i></a>';
|
||||
' <a class="btn btn-outline-secondary btn-xs" href="'.route('user_myorder_detail', [$user_pay_credit->shopping_order_id]).'"><i class="ion ion-md-eye"></i></a>';
|
||||
}
|
||||
})
|
||||
->addColumn('credit', function (UserPayCredit $user_pay_credit) {
|
||||
|
|
|
|||
|
|
@ -1,50 +1,56 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\Payment;
|
||||
use App\User;
|
||||
|
||||
|
||||
class SalesController extends Controller
|
||||
{
|
||||
protected $userShopRepo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('active.account');
|
||||
}
|
||||
|
||||
public function orders()
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
];
|
||||
return view('user.sales.orders', $data);
|
||||
return view('user.sales.index', $data);
|
||||
}
|
||||
|
||||
public function orderDetail($id)
|
||||
public function detail($id)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->member_id !== $user->id){
|
||||
abort(404);
|
||||
}
|
||||
if($shopping_order->payment_for !== 6 && $shopping_order->payment_for !== 7 && $shopping_order->payment_for !== 8){
|
||||
return redirect(route('user_myorder_detail', [$shopping_order->id]));
|
||||
abort(403, 'Beraterbestellung');
|
||||
}
|
||||
$data = [
|
||||
'shopping_order' => $shopping_order,
|
||||
'isAdmin' => false,
|
||||
];
|
||||
return view('user.sales.order_detail', $data);
|
||||
|
||||
return view('user.sales.detail', $data);
|
||||
}
|
||||
|
||||
public function ordersDatatable(){
|
||||
public function datatable(){
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$query = ShoppingOrder::with('shopping_user')->select('shopping_orders.*')->where('shopping_orders.member_id', $user->id);
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<a href="' . route('user_sales_order_detail', [$ShoppingOrder->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
return '<a href="' . route('user_sales_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");
|
||||
|
|
@ -53,7 +59,7 @@ class SalesController extends Controller
|
|||
return Payment::getShoppingOrderBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getFormattedTotalShipping();
|
||||
return '<span class="no-line-break">'.$ShoppingOrder->getFormattedTotalShipping()." €</span>";
|
||||
})
|
||||
->addColumn('orders', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->orders : '';
|
||||
|
|
@ -62,15 +68,25 @@ class SalesController 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::getPaymentForTypeBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>
|
||||
';
|
||||
})
|
||||
->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>' : '-';
|
||||
})
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
->rawColumns(['id', 'payment_for', 'txaction', 'user_shop_id'])
|
||||
->orderColumn('user_shop_id', 'user_shop_id $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
|
||||
->rawColumns(['id', 'txaction', 'user_shop_id', 'total_shipping', 'invoice', 'shipped', 'payment_for'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
119
app/Http/Controllers/User/ShopController.php
Normal file
119
app/Http/Controllers/User/ShopController.php
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use Request;
|
||||
use App\User;
|
||||
use Response;
|
||||
use Validator;
|
||||
use App\Services\Util;
|
||||
use App\Models\UserShop;
|
||||
use App\Models\PromotionUser;
|
||||
use App\Services\UserService;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Repositories\UserShopRepository;
|
||||
|
||||
class ShopController extends Controller
|
||||
{
|
||||
protected $userShopRepo;
|
||||
|
||||
public function __construct(UserShopRepository $userShopRepo)
|
||||
{
|
||||
$this->middleware('active.account');
|
||||
$this->userShopRepo = $userShopRepo;
|
||||
}
|
||||
|
||||
public function index(){
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
// $user_shop = UserShop::where('user_id', Auth::user()->id)->first();
|
||||
if(!$user->shop){
|
||||
//create new shop
|
||||
$user = $this->createNewUserShop(Auth::user());
|
||||
}
|
||||
if($user->shop->user_id != Auth::user()->id){
|
||||
abort(404);
|
||||
}
|
||||
$data = [
|
||||
'user_shop' => $user->shop,
|
||||
];
|
||||
|
||||
return view('user.shop.detail', $data);
|
||||
}
|
||||
private function createNewUserShop($user){
|
||||
return $this->userShopRepo->create($user);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$data = Request::all();
|
||||
$user = Auth::user();
|
||||
|
||||
if(isset($data['action']) && $data['action'] === 'save-user-shop'){
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
'user_shop_url' => ' required|alpha_dash|profanity|'.'unique:user_shops,url,'.$user->shop->id.',id'.'|min:4|max:20|full_word_check',
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
$profanity = \App\Models\Setting::getContentBySlug('promotion_user_url_profanity');
|
||||
$profanity = array_map('trim', explode(',', $profanity));
|
||||
if(in_array($value, $profanity)){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return redirect(route('user_shop'))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
$model = $this->userShopRepo->update($user->shop->id, Request::all());
|
||||
}
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('user_shop'));
|
||||
}
|
||||
|
||||
public function load(){
|
||||
$data = Request::all();
|
||||
|
||||
if(Request::ajax()) {
|
||||
if(isset($data['action']) && $data['action'] === 'validate_url'){
|
||||
$unique = 'unique:user_shops,url';
|
||||
if(isset($data['usid'])){
|
||||
$unique .= ','.$data['usid'].',id';
|
||||
}
|
||||
$rules = array(
|
||||
'user_shop_url' => ' required|alpha_dash|profanity|'.$unique.'|min:4|max:20|full_word_check',
|
||||
);
|
||||
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
|
||||
$profanity = \App\Models\Setting::getContentBySlug('promotion_user_url_profanity');
|
||||
$profanity = array_map('trim', explode(',', $profanity));
|
||||
if(in_array($value, $profanity)){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
//$messages = $validator->messages();
|
||||
return Response::json(array(
|
||||
'success' => false,
|
||||
'errors' => $validator->getMessageBag()->toArray()
|
||||
|
||||
));
|
||||
}
|
||||
//$slug = SlugService::createSlug(UserShop::class, 'slug', Request::get('user_promotion_url'));
|
||||
$name = Util::sanitize(Request::get('user_shop_url'), true, false, true, true);
|
||||
|
||||
return Response::json(array(
|
||||
'success' => true,
|
||||
'preview_user_shop_url' => config('app.shop_url')."/".$name,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\Payment;
|
||||
use App\User;
|
||||
|
||||
|
||||
class SalesController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('active.shop');
|
||||
}
|
||||
|
||||
public function orders()
|
||||
{
|
||||
$data = [
|
||||
];
|
||||
return view('user.shop.sales.orders', $data);
|
||||
}
|
||||
|
||||
public function orderDetail($id)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->member_id !== $user->id){
|
||||
abort(404);
|
||||
}
|
||||
$data = [
|
||||
'shopping_order' => $shopping_order,
|
||||
'isAdmin' => false,
|
||||
];
|
||||
return view('user.shop.sales.order_detail', $data);
|
||||
}
|
||||
|
||||
public function ordersDatatable(){
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$query = ShoppingOrder::with('shopping_user')->select('shopping_orders.*')->where('member_id', $user->id);
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<a href="' . route('user_shop_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 $ShoppingOrder->getFormattedTotalShipping();
|
||||
})
|
||||
->addColumn('orders', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->orders : '';
|
||||
})
|
||||
->addColumn('user_shop_id', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->user_shop ? '<a href="'.$ShoppingOrder->user_shop->getSubdomain(false).'" target="_blank">'.$ShoppingOrder->user_shop->getSubdomain(false).'</span>' : '';
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('user_shop_id', 'user_shop_id $1')
|
||||
->rawColumns(['id', 'txaction', 'user_shop_id'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -39,6 +39,15 @@ class UserDataController extends Controller
|
|||
/*if(!$user->account){
|
||||
$user->account = new UserAccount();
|
||||
}*/
|
||||
$data = Request::all();
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_validate"){
|
||||
return $this->userRepo->reverse_charge_validate($data, $user, route('user_edit', [$user->id]));
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete"){
|
||||
return $this->userRepo->reverse_charge_delete($data, $user, route('user_edit', [$user->id]));
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name'=>'required',
|
||||
|
|
@ -50,9 +59,6 @@ class UserDataController extends Controller
|
|||
'mobil' => 'required_without:phone',
|
||||
'tax_number' => 'required_without:tax_identification_number',
|
||||
'tax_identification_number' => 'required_without:tax_number',
|
||||
'birthday_day' => 'required',
|
||||
'birthday_month' => 'required',
|
||||
'birthday_year' => 'required',
|
||||
'country_id' => 'required|integer|min:1',
|
||||
'email' => 'required|string|email|max:255|exists:users,email',
|
||||
'email-confirm' => 'required|same:email',
|
||||
|
|
@ -79,7 +85,7 @@ class UserDataController extends Controller
|
|||
} else {
|
||||
$this->userRepo->update(Request::all());
|
||||
\Session()->flash('alert-save', true);
|
||||
return redirect('/user/edit');
|
||||
return redirect(route('user_edit', [$user->id]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -343,8 +343,10 @@ class UserShopController extends Controller
|
|||
|
||||
public function userShopRegisterSubDomain($slug){
|
||||
|
||||
return ['success' => false, 'error' => 'no KAS'];
|
||||
/*
|
||||
$kas = new KasController();
|
||||
$domain = 'mivita.care';
|
||||
$domain = 'HIER DIE DOMAIN';
|
||||
|
||||
|
||||
//check if exisist
|
||||
|
|
@ -360,7 +362,7 @@ class UserShopController extends Controller
|
|||
$pra = array(
|
||||
'subdomain_name' => $slug,
|
||||
'domain_name' => $domain,
|
||||
'subdomain_path' => '/mein.mivita.care/public/',
|
||||
'subdomain_path' => '/hier der Ordner /public/',
|
||||
'php_version' => '7.3',
|
||||
//'ssl_proxy' => 'Y',
|
||||
//'redirect_status' => 0
|
||||
|
|
@ -370,6 +372,7 @@ class UserShopController extends Controller
|
|||
return ['success' => true];
|
||||
}
|
||||
return ['success' => false, 'error' => $add_subdomain];
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use App\Models\PaymentMethod;
|
|||
use App\Models\PromotionUser;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Services\PromotionCart;
|
||||
use App\Services\UserCart;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\CheckoutRepository;
|
||||
|
|
@ -37,13 +37,16 @@ class PromotionController extends Controller
|
|||
}
|
||||
|
||||
if($path === 'impressum'){
|
||||
return view('web.promotion.impressum');
|
||||
return view('web.legal.impressum');
|
||||
}
|
||||
if($path === 'datenschutzerklaerung'){
|
||||
return view('web.promotion.datenschutzerklaerung');
|
||||
return view('web.legal.datenschutzerklaerung');
|
||||
}
|
||||
if($path === 'widerrufsbelehrung'){
|
||||
return view('web.promotion.widerrufsbelehrung');
|
||||
return view('web.legal.widerrufsbelehrung');
|
||||
}
|
||||
if($path === 'versandarten'){
|
||||
return view('web.legal.versandarten');
|
||||
}
|
||||
//search for promo
|
||||
$PromotionUser = PromotionUser::where('url', trim($path))->whereNull('user_deleted_at')->first();
|
||||
|
|
@ -56,17 +59,23 @@ class PromotionController extends Controller
|
|||
];
|
||||
return view('web.promotion.outofstock', $data);
|
||||
}
|
||||
PromotionCart::initYard();
|
||||
UserCart::initYard('prom', null, $PromotionUser);
|
||||
|
||||
$first_category = Category::where('active', true)->whereJsonContains('show_on', ['3'])->orderBy('pos', 'DESC')->first();
|
||||
$first_category_id = isset($first_category->id) ? $first_category->id : false;
|
||||
$shop_products = $this->getShowProducts();
|
||||
$first_category_id = false;
|
||||
if(Request::get('catid')){
|
||||
$first_category_id = Request::get('catid');
|
||||
}
|
||||
|
||||
//$first_category = Category::where('active', true)->whereJsonContains('show_on', ['3'])->orderBy('pos', 'DESC')->first();
|
||||
//$first_category_id = isset($first_category->id) ? $first_category->id : false;
|
||||
$shop_products = $this->getShowProducts($first_category_id);
|
||||
|
||||
$data = [
|
||||
'promotion_user' => $PromotionUser,
|
||||
'shop_products' => $shop_products,
|
||||
'user_payment_methods' => PaymentMethod::getDefaultAsArray()->toArray(),
|
||||
'first_category_id' => $first_category_id,
|
||||
'categories_by_show_on' => '3'
|
||||
];
|
||||
return view('web.promotion.index', $data);
|
||||
}
|
||||
|
|
@ -230,38 +239,38 @@ class PromotionController extends Controller
|
|||
return response()->json(['response' => $data, 'shop_products_view'=>$shop_products_view, 'status'=>$status]);
|
||||
}
|
||||
if($data['action'] === 'switch-free-product'){
|
||||
\App\Services\PromotionCart::updateFeeProduct($data);
|
||||
\App\Services\UserCart::updateFeeProduct($data);
|
||||
}
|
||||
if($data['action'] === 'add-shop-product'){
|
||||
$data['qty'] = \App\Services\PromotionCart::updateProduct($data, true);
|
||||
$data['qty'] = \App\Services\UserCart::updateProduct($data, true);
|
||||
}
|
||||
if($data['action'] === 'update-shop-product'){
|
||||
$data['qty'] = \App\Services\PromotionCart::updateProduct($data);
|
||||
$data['qty'] = \App\Services\UserCart::updateProduct($data);
|
||||
}
|
||||
if($data['action'] === 'remove-shop-product'){
|
||||
\App\Services\PromotionCart::updateProduct($data);
|
||||
\App\Services\UserCart::updateProduct($data);
|
||||
$data['qty'] = 0;
|
||||
}
|
||||
if($data['action'] === 'clear-cart'){
|
||||
\App\Services\PromotionCart::clearCart($data);
|
||||
\App\Services\UserCart::clearCart($data);
|
||||
}
|
||||
if($data['action'] === 'switch-shipping'){
|
||||
\App\Services\PromotionCart::switchShipping($data);
|
||||
\App\Services\UserCart::switchShipping($data);
|
||||
}
|
||||
if($data['action'] === 'change-state-shipping'){
|
||||
\App\Services\PromotionCart::changeStateShipping($data);
|
||||
\App\Services\UserCart::changeStateShipping($data, 'prom');
|
||||
}
|
||||
|
||||
$cart = view("web.promotion._promotion_cart", compact('data'))->render();
|
||||
if(Yard::instance('shopping')->isQuickShipping()){
|
||||
$invoice = view("web.promotion._invoice_details_quick")->render();
|
||||
$invoice = view("web.components._invoice_details_quick")->render();
|
||||
}else{
|
||||
$invoice = view("web.promotion._invoice_details")->render();
|
||||
$invoice = view("web.components._invoice_details")->render();
|
||||
}
|
||||
$checkout = view("web.promotion._checkout")->render();
|
||||
$data['shipping_price_formated'] = PromotionCart::getCurrentShippingPrice();
|
||||
$checkout = view("web.components._checkout")->render();
|
||||
$data['shipping_price_formated'] = UserCart::getCurrentShippingPrice(2); //shipping_for === 2 promotion , 3 shop
|
||||
|
||||
return response()->json(['response' => $data, 'cart'=>$cart, 'invoice'=>$invoice, 'checkout'=>$checkout, 'status'=>$status]);
|
||||
return response()->json(['response' => $data, 'cart'=>$cart, 'invoice'=>$invoice, 'checkout'=>$checkout, 'status'=>$status, 'basketqty'=>Yard::instance('shopping')->count()]);
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,19 +3,21 @@
|
|||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailContact;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Models\UserHistory;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\SysLog;
|
||||
use App\Services\UserService;
|
||||
use App\User;
|
||||
use GuzzleHttp\Client;
|
||||
use Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use App\Services\Util;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Services\SysLog;
|
||||
use App\Mail\MailContact;
|
||||
use App\Models\UserHistory;
|
||||
use App\Models\UserRegister;
|
||||
use App\Services\UserService;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class RegisterController extends Controller
|
||||
|
|
@ -34,71 +36,160 @@ class RegisterController extends Controller
|
|||
$this->userRepo = $userRepo;
|
||||
}
|
||||
|
||||
public function member($member_id = false)
|
||||
public function showConsentPage()
|
||||
{
|
||||
$data = [
|
||||
'from_member_id' => session('from_member_id')
|
||||
];
|
||||
return view('auth.recaptcha-consent', $data);
|
||||
}
|
||||
|
||||
public function acceptConsent()
|
||||
{
|
||||
if (!Request::has('recaptcha_consent')) {
|
||||
return back()->withErrors(['error' => 'Bitte stimmen Sie der Verwendung von reCAPTCHA zu']);
|
||||
}
|
||||
|
||||
session(['recaptcha_consent' => true]);
|
||||
return redirect()->route('register.form');
|
||||
}
|
||||
|
||||
public function showRegistrationForm()
|
||||
{
|
||||
if (!session('recaptcha_consent')) {
|
||||
return redirect()->route('register.consent');
|
||||
}
|
||||
$data = [
|
||||
'from_member_id' => session('from_member_id')
|
||||
];
|
||||
return view('auth.register', $data);
|
||||
}
|
||||
|
||||
public function member($from_member_id = false)
|
||||
{
|
||||
$this->userRepo->clearUserRegister();
|
||||
|
||||
if(!$from_member_id){
|
||||
return redirect()->route('register.consent');
|
||||
}
|
||||
|
||||
//ist ein gültiger Member ID und ist aktiv?
|
||||
$user_id = (int) str_replace('gs', '', $from_member_id) - config('main.add_number_id');
|
||||
$user = User::find($user_id);
|
||||
if(!$user || !$user->isActive() || !$user->isActiveAccount()){
|
||||
return redirect()->route('register.consent');
|
||||
}
|
||||
session(['from_member_id' => $from_member_id]);
|
||||
return redirect()->route('register.consent');
|
||||
|
||||
/*
|
||||
//hat einen Member ID?
|
||||
if(!$member_id){
|
||||
return redirect('/registrierung');
|
||||
}
|
||||
|
||||
//ist ein gültiger Member ID und ist aktiv?
|
||||
$user_id = (int) str_replace('gs', '', $member_id) - config('main.add_number_id');
|
||||
$user = User::find($user_id);
|
||||
if(!$user || !$user->isActive() || !$user->isActiveAccount()){
|
||||
return redirect('/registrierung');
|
||||
}
|
||||
|
||||
if (!session('recaptcha_consent')) {
|
||||
$data = [
|
||||
'from_member_id' => Request::get('from_member_id')
|
||||
];
|
||||
return view('auth.recaptcha-consent', $data);
|
||||
|
||||
//return redirect()->route('register.consent')->with(['from_member_id' => $member_id]);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'from_member_id' => $member_id
|
||||
];
|
||||
return view('auth.register', $data);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public function register(){
|
||||
|
||||
|
||||
$this->userRepo->clearUserRegister();
|
||||
// Überprüfe zuerst die reCAPTCHA-Einwilligung
|
||||
|
||||
/* if (!Request::has('recaptcha_consent')) {
|
||||
return back()->withErrors(['recaptcha_consent' => 'Bitte stimmen Sie der Verwendung von reCAPTCHA zu'])->withInput(Request::all());
|
||||
}*/
|
||||
|
||||
// Überprüfe reCAPTCHA
|
||||
$recaptchaResponse = Request::input('g-recaptcha-response');
|
||||
if (!$this->verifyRecaptcha($recaptchaResponse)) {
|
||||
return back()->withErrors(['g-recaptcha-response' => 'Bitte bestätigen Sie, dass Sie kein Roboter sind'])->withInput(Request::all());
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name'=>'required',
|
||||
'last_name'=>'required',
|
||||
'first_name'=>'required|string|min:2',
|
||||
'last_name'=>'required|string|min:2',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
'password_confirmation' => 'required|string|min:6',
|
||||
'accepted_data_protection' => 'required',
|
||||
'g-recaptcha-response' => 'required',
|
||||
);
|
||||
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
//search in UserRegister
|
||||
$data = Request::all();
|
||||
$user = $this->userRepo->create($data);
|
||||
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
|
||||
$user->lang = !empty(\App::getLocale()) ? \App::getLocale() : "de";
|
||||
$user->confirmation_code = $confirmation_code;
|
||||
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
|
||||
$user->confirmation_code_remider = 0;
|
||||
if(isset($data['from_member_id'])){
|
||||
$user->m_sponsor = (int) str_replace('gs', '', $data['from_member_id']) - config('main.add_number_id');
|
||||
$UserRegister = UserRegister::where('identifier', $data['email'])->first();
|
||||
if($UserRegister){
|
||||
$exists = [
|
||||
'register_email' => $data['email']
|
||||
];
|
||||
return view('auth.existing', $exists);
|
||||
}
|
||||
$user->save();
|
||||
|
||||
$user = User::find($user->id);
|
||||
|
||||
$userObj = $this->userRepo->createUserRegister($data);
|
||||
$from_member_id = session('from_member_id');
|
||||
$user_id = isset($from_member_id) ? (int) str_replace('gs', '', $from_member_id) - config('main.add_number_id') : config('app.main_user_id'); // Krummel
|
||||
try {
|
||||
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailVerifyAccount($confirmation_code, $user));
|
||||
Mail::to($userObj->email)->bcc(config('app.info_mail'))->send(new MailVerifyAccount($userObj->confirmation_code, $userObj));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
SysLog::action('register-user', 'auth_register', 5)
|
||||
->setUserId($user->id)
|
||||
->setModel($user->id, User::class)
|
||||
->setUserId($user_id)
|
||||
->setModel(null, UserRegister::class)
|
||||
->setMessage('Error send register E-Mail: '.$e->getMessage())
|
||||
->save();
|
||||
}
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'register', 'status'=>0]);
|
||||
UserHistory::create(['user_id' => $user_id, 'action'=>'register', 'status'=>0]);
|
||||
|
||||
return redirect('/user_register/finish');
|
||||
}
|
||||
|
||||
// Neue Methode zur Überprüfung des reCAPTCHA
|
||||
private function verifyRecaptcha($recaptchaResponse)
|
||||
{
|
||||
if (empty($recaptchaResponse)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$client = new Client();
|
||||
$response = $client->post('https://www.google.com/recaptcha/api/siteverify', [
|
||||
'form_params' => [
|
||||
'secret' => config('services.recaptcha.secret_key'),
|
||||
'response' => $recaptchaResponse
|
||||
]
|
||||
]);
|
||||
|
||||
$body = json_decode((string)$response->getBody());
|
||||
return $body->success;
|
||||
}
|
||||
|
||||
public function finish()
|
||||
{
|
||||
$data = [
|
||||
|
|
@ -106,4 +197,40 @@ class RegisterController extends Controller
|
|||
];
|
||||
return view('auth.finish', $data);
|
||||
}
|
||||
|
||||
public function verify($confirmation_code){
|
||||
|
||||
if( ! $confirmation_code)
|
||||
{
|
||||
return redirect('/status/error');
|
||||
}
|
||||
|
||||
$UserRegister = UserRegister::where ('instance', $confirmation_code)->first();
|
||||
|
||||
if ( ! $UserRegister)
|
||||
{
|
||||
return redirect('/status/not/found');
|
||||
}
|
||||
|
||||
$user = $this->userRepo->create($UserRegister);
|
||||
|
||||
//Login!
|
||||
Auth::login($user);
|
||||
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
public function registerAgain(){
|
||||
$data = Request::all();
|
||||
if(!isset($data['register_email'])){
|
||||
abort(403, "No E-Mail");
|
||||
}
|
||||
$UserRegister = UserRegister::where('identifier', $data['register_email'])->first();
|
||||
if(!$UserRegister){
|
||||
abort(403, "No E-Mail Register");
|
||||
}
|
||||
Mail::to($UserRegister->identifier)->bcc(config('app.info_mail'))->send(new MailVerifyAccount($UserRegister->instance, $UserRegister->content));
|
||||
return redirect('/user_register/finish');
|
||||
|
||||
}
|
||||
}
|
||||
294
app/Http/Controllers/Web/ShopController.php
Normal file
294
app/Http/Controllers/Web/ShopController.php
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use Yard;
|
||||
use Request;
|
||||
use Response;
|
||||
use Validator;
|
||||
use App\Services\Util;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserShop;
|
||||
use App\Services\Payment;
|
||||
use App\Models\UserHistory;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Services\UserCart;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\CheckoutRepository;
|
||||
|
||||
class ShopController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function serve($path = null)
|
||||
{
|
||||
if(!isset($path)){
|
||||
$path = 'grueneseele';
|
||||
//abort(402);
|
||||
}
|
||||
if($path === 'impressum'){
|
||||
return view('web.legal.impressum');
|
||||
}
|
||||
if($path === 'datenschutzerklaerung'){
|
||||
return view('web.legal.datenschutzerklaerung');
|
||||
}
|
||||
if($path === 'widerrufsbelehrung'){
|
||||
return view('web.legal.widerrufsbelehrung');
|
||||
}
|
||||
if($path === 'versandarten'){
|
||||
return view('web.legal.versandarten');
|
||||
}
|
||||
|
||||
//search for promo
|
||||
$userShop = UserShop::where('url', trim($path))->first();
|
||||
if(!$userShop){
|
||||
//redirect !!!!
|
||||
abort(402);
|
||||
}
|
||||
if(!$userShop->isActive()){
|
||||
$data = [
|
||||
'user_shop' => $userShop,
|
||||
];
|
||||
//redirect !!!!
|
||||
return view('web.shop.outofstock', $data);
|
||||
}
|
||||
UserCart::initYard('shop', $userShop, null);
|
||||
$first_category_id = false;
|
||||
if(Request::get('catid')){
|
||||
$first_category_id = Request::get('catid');
|
||||
}
|
||||
|
||||
$userMargin = \App\Services\Shop::calculateUserShopMargins($userShop, null);
|
||||
|
||||
//$first_category = Category::where('active', true)->whereJsonContains('show_on', ['8'])->orderBy('pos', 'DESC')->first();
|
||||
// $first_category_id = isset($first_category->id) ? $first_category->id : false;
|
||||
$shop_products = $this->getShowProducts($first_category_id);
|
||||
|
||||
$data = [
|
||||
'user_shop' => $userShop,
|
||||
'shop_products' => $shop_products,
|
||||
'user_payment_methods' => PaymentMethod::getDefaultAsArray()->toArray(),
|
||||
'first_category_id' => $first_category_id,
|
||||
'categories_by_show_on' => '8',
|
||||
'userMargin' => $userMargin
|
||||
];
|
||||
return view('web.shop.index', $data);
|
||||
}
|
||||
|
||||
public function goto($load, $user_shop_id, $transactionId=false, $reference=false, $identifier=false){
|
||||
$userShop = UserShop::findOrFail($user_shop_id);
|
||||
$data = [
|
||||
'user_shop' => $userShop,
|
||||
];
|
||||
|
||||
if($load === 'thanksreminder'){
|
||||
return view('web.shop.thanksreminder', $data);
|
||||
}
|
||||
if($load === 'notactive'){
|
||||
return view('web.shop.notactive', $data);
|
||||
}
|
||||
if($load === 'thanksorder'){
|
||||
$payt = PaymentTransaction::findOrFail($transactionId);
|
||||
if($payt->shopping_payment->reference != $reference){
|
||||
abort(404);
|
||||
}
|
||||
Yard::instance('shopping')->destroy();
|
||||
$checkRepo = new CheckoutRepository();
|
||||
$checkRepo->destroy();
|
||||
if(($payt->status === 'fnc' || $payt->status === 'vor' || $payt->status === 'pp' || $payt->status === 'non') && $payt->txaction === 'prev'){
|
||||
$this->directPaymentStatus($payt, $identifier);
|
||||
}
|
||||
$data = [
|
||||
'user_shop' => $userShop,
|
||||
'order_reference' => $payt->shopping_payment->reference,
|
||||
'pay_trans' => $payt,
|
||||
];
|
||||
return view('web.shop.thanksorder', $data);
|
||||
}
|
||||
|
||||
}
|
||||
public function store($user_shop_id){
|
||||
|
||||
$userShop = UserShop::findOrFail($user_shop_id);
|
||||
$data = Request::all();
|
||||
if(!isset($data['action'])){
|
||||
abort(402);
|
||||
}
|
||||
|
||||
if($data['action'] === 'submit-reminder-service'){
|
||||
return redirect(route('web_shop_goto', ['thanksreminder', $userShop->id]));
|
||||
}
|
||||
if($data['action'] === 'submit-order'){
|
||||
$rules = array(
|
||||
'billing_firstname'=>'required',
|
||||
'billing_lastname'=>'required',
|
||||
'billing_address'=>'required',
|
||||
'billing_zipcode'=>'required',
|
||||
'billing_city' => 'required',
|
||||
'billing_state' => 'required',
|
||||
'billing_email'=>'required|email',
|
||||
);
|
||||
|
||||
if(Request::get('same_as_billing')){
|
||||
$rules = array_merge($rules, [
|
||||
'shipping_firstname'=>'required',
|
||||
'shipping_lastname'=>'required',
|
||||
'shipping_address'=>'required',
|
||||
'shipping_zipcode'=>'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_salutation' => 'required'
|
||||
]);
|
||||
}
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
$identifier = Util::getToken();
|
||||
$data['is_from'] = 'shopping';
|
||||
$data['is_for'] = 'us'; //usershopping
|
||||
unset($data['_token']);
|
||||
Yard::instance('shopping')->putYardExtra('shopping_data', $data);
|
||||
|
||||
UserHistory::create(['user_id' => $userShop->user_id, 'action'=>'web_shop_payment', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier]);
|
||||
$checkRepo = new CheckoutRepository();
|
||||
$checkRepo->setUserShop(8, $userShop);
|
||||
$checkRepo->init($identifier, $data);
|
||||
return $checkRepo->makePayment();
|
||||
}
|
||||
}
|
||||
|
||||
private function directPaymentStatus(PaymentTransaction $payt, $identifier){
|
||||
|
||||
if(isset($payt->transmitted_data['param'])){
|
||||
$shopping_order = ShoppingOrder::find($payt->transmitted_data['param']);
|
||||
$shopping_payment = ShoppingPayment::where('reference', $payt->transmitted_data['reference'])->first();
|
||||
|
||||
$shopping_order->txaction = 'open';
|
||||
$shopping_order->save();
|
||||
$payt->txaction = "open";
|
||||
|
||||
//is Promotion Handel it
|
||||
if($shopping_order->promotion_user_id > 0){
|
||||
Payment::handelPromotionProduct($shopping_order);
|
||||
}
|
||||
if($shopping_payment){
|
||||
//Payment::handelUserPayCredits($shopping_order, 'deduction');
|
||||
if($payt->status === 'vor'){
|
||||
$shopping_payment->txaction = 'open';
|
||||
$shopping_order->txaction = 'open';
|
||||
$payt->txaction = "open";
|
||||
$shopping_order->save();
|
||||
|
||||
}
|
||||
if($payt->status === 'pp'){
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||
$shopping_payment->txaction = 'paid';
|
||||
$shopping_order->txaction = 'paid';
|
||||
$payt->txaction = "paid";
|
||||
$shopping_order->save();
|
||||
}
|
||||
if($payt->status === 'fnc'){
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||
$shopping_payment->txaction = 'paid';
|
||||
$shopping_order->txaction = 'paid';
|
||||
$payt->txaction = "paid";
|
||||
$shopping_order->save();
|
||||
|
||||
}
|
||||
if($payt->status === 'non'){
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||
$shopping_payment->txaction = 'paid';
|
||||
$shopping_order->txaction = 'paid';
|
||||
$payt->txaction = "paid";
|
||||
$shopping_order->save();
|
||||
\App\Services\Shop::newUserOrder($shopping_order->shopping_user->number);
|
||||
}
|
||||
$shopping_payment->save();
|
||||
}
|
||||
$payt->save();
|
||||
$data = [
|
||||
'mode' => $payt->transmitted_data['mode'],
|
||||
'txaction' => $payt->txaction,
|
||||
'send_link' => false,
|
||||
];
|
||||
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function load(){
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
$status = false;
|
||||
|
||||
if(Request::ajax()){
|
||||
if($data['action'] === 'web-show-product'){
|
||||
$product = Product::find($data['id']); //current user form order
|
||||
$ret = view("web.shop.show_product", compact('product', 'data'))->render();
|
||||
}
|
||||
if(isset($data['perform'])){
|
||||
if($data['action'] === 'switch-show_products'){
|
||||
$category_id = isset($data['show_products_option']) ? $data['show_products_option'] : false;
|
||||
$shop_products = $this->getShowProducts($category_id);
|
||||
$shop_products_view = view("web.shop._shop_products_inner", compact('shop_products'))->render();
|
||||
return response()->json(['response' => $data, 'shop_products_view'=>$shop_products_view, 'status'=>$status]);
|
||||
}
|
||||
if($data['action'] === 'add-shop-product'){
|
||||
$data['qty'] = \App\Services\UserCart::updateProduct($data, true);
|
||||
}
|
||||
if($data['action'] === 'minus-shop-product'){
|
||||
$data['qty'] = \App\Services\UserCart::updateProduct($data, false, true);
|
||||
}
|
||||
if($data['action'] === 'update-shop-product'){
|
||||
$data['qty'] = \App\Services\UserCart::updateProduct($data);
|
||||
}
|
||||
if($data['action'] === 'remove-shop-product'){
|
||||
\App\Services\UserCart::updateProduct($data);
|
||||
$data['qty'] = 0;
|
||||
}
|
||||
if($data['action'] === 'clear-cart'){
|
||||
\App\Services\UserCart::clearCart($data);
|
||||
}
|
||||
if($data['action'] === 'switch-shipping'){
|
||||
\App\Services\UserCart::switchShipping($data);
|
||||
}
|
||||
if($data['action'] === 'change-state-shipping'){
|
||||
\App\Services\UserCart::changeStateShipping($data, 'shop');
|
||||
}
|
||||
|
||||
$cart = view("web.shop._shop_cart", compact('data'))->render();
|
||||
if(Yard::instance('shopping')->isQuickShipping()){
|
||||
$invoice = view("web.components._invoice_details_quick")->render();
|
||||
}else{
|
||||
$invoice = view("web.components._invoice_details")->render();
|
||||
}
|
||||
$checkout = view("web.components._checkout")->render();
|
||||
$data['shipping_price_formated'] = UserCart::getCurrentShippingPrice(3); //shipping_for === 2 promotion , 3 shop
|
||||
|
||||
return response()->json(['response' => $data, 'cart'=>$cart, 'invoice'=>$invoice, 'checkout'=>$checkout, 'status'=>$status, 'basketqty'=>Yard::instance('shopping')->count()]);
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getShowProducts($category_id = false){
|
||||
$shop_products = [];
|
||||
if($category_id){
|
||||
$shop_products = Product::where('active', true)->whereJsonContains('show_on', ['8'])
|
||||
->whereHas('categories', function ($query) use ($category_id) {
|
||||
$query->where('category_id', $category_id); //->whereJsonContains('show_on', ['3']);
|
||||
})->orderBy('pos', 'ASC')->get();
|
||||
}else{
|
||||
$shop_products = Product::where('active', true)->whereJsonContains('show_on', ['8'])
|
||||
->orderBy('pos', 'ASC')->get();
|
||||
}
|
||||
return $shop_products;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,22 +2,23 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\MailReleaseAccount;
|
||||
use App\Models\File;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\UserHistory;
|
||||
use App\Models\UserLevel;
|
||||
use App\Repositories\FileRepository;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Hash;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Request;
|
||||
use Validator;
|
||||
use Yard;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use App\Models\File;
|
||||
use App\Services\Util;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserLevel;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\UserHistory;
|
||||
use App\Mail\MailReleaseAccount;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Repositories\FileRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class WizardController extends Controller
|
||||
{
|
||||
|
|
@ -149,7 +150,13 @@ class WizardController extends Controller
|
|||
if (!$user->account) {
|
||||
$user->account = new UserAccount();
|
||||
}
|
||||
|
||||
|
||||
$data = Request::all();
|
||||
if($step == 7 && Request::get('user_country_id')){
|
||||
$user->account->country_id = Request::get('user_country_id');
|
||||
$user->account->save();
|
||||
return redirect(route('wizard_register', [1]));
|
||||
}
|
||||
if ($step == 0) {
|
||||
$rules = array(
|
||||
'accepted_data_protection' => 'required',
|
||||
|
|
@ -185,7 +192,23 @@ class WizardController extends Controller
|
|||
$user->save();
|
||||
return redirect(route('wizard_register'));
|
||||
}
|
||||
|
||||
if ($step == 1) {
|
||||
$data = Request::all();
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_validate"){
|
||||
$user->wizard = 1;
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_validate($data, $user, route('wizard_register', [1]));
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete"){
|
||||
$user->wizard = 1;
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_delete($data, $user, route('wizard_register', [1]));
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name' => 'required',
|
||||
|
|
@ -198,9 +221,6 @@ class WizardController extends Controller
|
|||
'tax_number' => 'required_without:tax_identification_number',
|
||||
'tax_identification_number' => 'required_without:tax_number',
|
||||
'country_id' => 'required|integer|min:1',
|
||||
'birthday_day' => 'required',
|
||||
'birthday_month' => 'required',
|
||||
'birthday_year' => 'required'
|
||||
);
|
||||
|
||||
if (!Request::get('same_as_billing')) {
|
||||
|
|
@ -220,19 +240,26 @@ class WizardController extends Controller
|
|||
$user->save();
|
||||
return redirect(route('wizard_register', [1]))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
$data = Request::all();
|
||||
$data['same_as_billing'] = Request::get('same_as_billing') == NULL ? 0 : 1;
|
||||
$data['birthday_day'] = isset($data['birthday_day']) ? $data['birthday_day'] : 1;
|
||||
$data['birthday_month'] = isset($data['birthday_month']) ? $data['birthday_month'] : 1;
|
||||
$data['birthday_year'] = isset($data['birthday_year']) ? $data['birthday_year'] : 1970;
|
||||
$data['birthday'] = $data['birthday_day'].".".$data['birthday_month'].".".$data['birthday_year'];
|
||||
$data['birthday_year'] = isset($data['birthday_year']) ? $data['birthday_year'] : 1900;
|
||||
$data['birthday'] = $data['birthday_day'].".".$data['birthday_month'].".".$data['birthday_year'];
|
||||
$data['birthday'] = $data['birthday'] == "1.1.1900" ? null : $data['birthday'];
|
||||
$user->account->fill($data)->save();
|
||||
$user->wizard = 2;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'));
|
||||
}
|
||||
|
||||
if ($step == 2) {
|
||||
/* if ($step == 2) {
|
||||
//kein Ausweis hochladen - deaktiviert
|
||||
dd("deaktiviert");
|
||||
$user->wizard = 3;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'));
|
||||
/*
|
||||
if(Request::get('submit') === 'do'){
|
||||
if(File::whereUserId($user->id)->whereIdentifier('id_card')->count() == 0){
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
|
|
@ -251,8 +278,10 @@ class WizardController extends Controller
|
|||
$this->fileRepo->_set('identifier', 'id_card');
|
||||
return $this->fileRepo->uploadFile(Request::all());
|
||||
}
|
||||
*/
|
||||
|
||||
if ($step == 3) {
|
||||
if ($step == 2) {
|
||||
$data = Request::all();
|
||||
if(Request::get('submit') === 'do'){
|
||||
$data = Request::all();
|
||||
|
||||
|
|
@ -260,7 +289,7 @@ class WizardController extends Controller
|
|||
if(File::whereUserId($user->id)->whereIdentifier('business_license')->count() == 0){
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$validator->errors()->add('field', __('Kein Gewerbeschein hinterlegt, bitte erst hochladen.'));
|
||||
$user->wizard = 3;
|
||||
$user->wizard = 2;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
|
@ -272,7 +301,7 @@ class WizardController extends Controller
|
|||
if(!$data['non_business_license_reason'] || $data['non_business_license_reason'] == ""){
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$validator->errors()->add('field', __('Bitte gib eine Begründung ein, warum Du keinen Gewerbeschein benötigst.'));
|
||||
$user->wizard = 3;
|
||||
$user->wizard = 2;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register'))->withErrors($validator)->withInput(Request::all());
|
||||
}else{
|
||||
|
|
@ -281,7 +310,7 @@ class WizardController extends Controller
|
|||
}
|
||||
|
||||
$user->account->setNotice('business_license', $data['business_license_choose']);
|
||||
$user->wizard = 4;
|
||||
$user->wizard = 3;
|
||||
$user->save();
|
||||
|
||||
return redirect(route('wizard_register'));
|
||||
|
|
@ -293,7 +322,7 @@ class WizardController extends Controller
|
|||
return $this->fileRepo->uploadFile(Request::all());
|
||||
}
|
||||
|
||||
if ($step == 4) {
|
||||
if ($step == 3) {
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
|
|
@ -397,6 +426,23 @@ class WizardController extends Controller
|
|||
return redirect(route('wizard_create', [12]));
|
||||
}
|
||||
if($step == 12){
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_validate"){
|
||||
$user->wizard = 12;
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_validate($data, $user, route('wizard_create', [12]));
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] == "reverse_charge_delete"){
|
||||
$user->wizard = 12;
|
||||
$user->save();
|
||||
$userRepo = new UserRepository($user);
|
||||
return $userRepo->reverse_charge_delete($data, $user, route('wizard_create', [12]));
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name' => 'required',
|
||||
|
|
@ -409,9 +455,6 @@ class WizardController extends Controller
|
|||
'tax_number' => 'required_without:tax_identification_number',
|
||||
'tax_identification_number' => 'required_without:tax_number',
|
||||
'country_id' => 'required|integer|min:1',
|
||||
'birthday_day' => 'required',
|
||||
'birthday_month' => 'required',
|
||||
'birthday_year' => 'required'
|
||||
);
|
||||
|
||||
if(!Request::get('same_as_billing')){
|
||||
|
|
@ -464,6 +507,15 @@ class WizardController extends Controller
|
|||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
/*need setGlobalTaxRate
|
||||
$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]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||
}
|
||||
*/
|
||||
//Keine steuer
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
Yard::instance('shopping')->setGlobalTaxRate(0);
|
||||
|
||||
|
|
@ -475,6 +527,18 @@ class WizardController extends Controller
|
|||
if($product_on_board->images->count()){
|
||||
$image = $product_on_board->images->first()->slug;
|
||||
}
|
||||
|
||||
/*
|
||||
need?
|
||||
$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]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||
}
|
||||
*/
|
||||
Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->price, $product->tax, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight]);
|
||||
}
|
||||
}
|
||||
|
|
@ -522,10 +586,16 @@ class WizardController extends Controller
|
|||
if($relation === 'upload'){
|
||||
$user = User::findOrFail(Auth::user()->id);
|
||||
$file = $user->files()->findOrFail($id);
|
||||
$identifier = $file->identifier;
|
||||
//remove file
|
||||
\Storage::disk('user')->delete($file->dir.$file->filename);
|
||||
$file->delete();
|
||||
\Session()->flash('alert-success', "Datei gelöscht");
|
||||
if($identifier === 'business_license'){
|
||||
$user->wizard = 2;
|
||||
$user->save();
|
||||
return redirect(route('wizard_register', [2]));
|
||||
}
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue