Update Framework, Invoices
This commit is contained in:
parent
cc5c147c27
commit
9b0b5feb7e
174 changed files with 28356 additions and 8093 deletions
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
|
|
@ -29,10 +29,12 @@ class Handler extends ExceptionHandler
|
|||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param \Throwable $exception
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
public function report(Throwable $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
|
|
@ -41,10 +43,12 @@ class Handler extends ExceptionHandler
|
|||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param \Throwable $exception
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
public function render($request, Throwable $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,12 @@ namespace App\Http\Controllers\Api;
|
|||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailCheckout;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Services\Payment;
|
||||
use App\Services\Shop;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class PayoneController extends Controller
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ class ShoppingUserController extends Controller
|
|||
$wp_order_numbers = $request->wp_order_numbers;
|
||||
}
|
||||
|
||||
|
||||
if(!$wp_order_numbers || !is_array($wp_order_numbers)){
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
|
|
@ -594,7 +593,7 @@ 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, false, false, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
|
||||
}
|
||||
}
|
||||
$order->message = $error;
|
||||
|
|
@ -615,12 +614,13 @@ class ShoppingUserController extends Controller
|
|||
}
|
||||
|
||||
private function makeShoppingOrder($shopping_user, $wp_invoice_path, $wp_notice){
|
||||
|
||||
|
||||
$data = [
|
||||
'shopping_user_id' => $shopping_user->id,
|
||||
'auth_user_id' => $shopping_user->auth_user_id,
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'user_shop_id' => auth()->user()->user_sponsor->shop->id,
|
||||
'payment_for' => 7,
|
||||
'member_id' => $shopping_user->member_id,
|
||||
'total' => Yard::instance('shopping')->total(2, '.', ''),
|
||||
'subtotal' => Yard::instance('shopping')->subtotal(2, '.', ''),
|
||||
|
|
@ -646,8 +646,11 @@ class ShoppingUserController extends Controller
|
|||
}
|
||||
$items = Yard::instance('shopping')->content();
|
||||
|
||||
|
||||
$shopping_order->shopping_order_items()->each(function($model) use ($items, $shopping_order) {
|
||||
foreach ($items as $item) {
|
||||
$price_net = Yard::instance('shopping')->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
if ($model->row_id === $item->rowId) {
|
||||
$model->fill([
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
|
|
@ -655,8 +658,12 @@ class ShoppingUserController extends Controller
|
|||
'product_id' => $item->id,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
|
||||
'price_net' => $price_net,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'tax' => $tax,
|
||||
'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id),
|
||||
'discount' => $shopping_order->getUserDiscount(),
|
||||
'points' => $item->options->points,
|
||||
'slug' => $item->options->slug,
|
||||
])->save();
|
||||
return false;
|
||||
|
|
@ -667,19 +674,27 @@ class ShoppingUserController extends Controller
|
|||
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (!ShoppingOrderItem::where('shopping_order_id', $shopping_order->id)->where('row_id', $item->rowId)->count())
|
||||
if (!ShoppingOrderItem::where('shopping_order_id', $shopping_order->id)->where('row_id', $item->rowId)->count()){
|
||||
$price_net = Yard::instance('shopping')->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
ShoppingOrderItem::create([
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
'product_id' => $item->id,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
|
||||
'price_net' => $price_net,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'tax' => $tax,
|
||||
'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id),
|
||||
'discount' => $shopping_order->getUserDiscount(),
|
||||
'points' => $item->options->points,
|
||||
'slug' => $item->options->slug
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$shopping_order->makeTaxSplit();
|
||||
return $shopping_order;
|
||||
}
|
||||
|
||||
|
|
|
|||
125
app/Http/Controllers/FileController.php
Normal file
125
app/Http/Controllers/FileController.php
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Storage;
|
||||
use Response;
|
||||
use Auth;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
private function isPermission($shopping_order){
|
||||
$user_id = $shopping_order->auth_user_id ? $shopping_order->auth_user_id : $shopping_order->member_id;
|
||||
if(Auth::user()->isAdmin() || $user_id == Auth::user()->id){
|
||||
return true;
|
||||
}
|
||||
abort(404);
|
||||
|
||||
}
|
||||
|
||||
public function show($id = null, $disk = null, $do='file')
|
||||
{
|
||||
$path = "";
|
||||
$filename = "";
|
||||
|
||||
/*if($disk === 'user'){
|
||||
$file = \App\Models\File::findOrFail($id);
|
||||
$this->isPermission($file->user_id);
|
||||
$path = Storage::disk($disk)->path($file->dir.$file->filename);
|
||||
if (file_exists($path)) {
|
||||
return Response::file($path);
|
||||
}
|
||||
}*/
|
||||
|
||||
if ($disk === 'invoice'){
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->user_invoice){
|
||||
$this->isPermission($shopping_order);
|
||||
$user_invoice = $shopping_order->user_invoice;
|
||||
$filename = $user_invoice->filename;
|
||||
$disk = $user_invoice->disk;
|
||||
$path = $user_invoice->getDownloadPath();
|
||||
if (!Storage::disk($disk)->exists($path)) {
|
||||
return Response::make('File no found.', 404);;
|
||||
}
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
|
||||
}
|
||||
if($do === 'download'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
|
||||
}
|
||||
if($do === 'stream'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition','inline; filename="'.$filename.'"');
|
||||
}
|
||||
}
|
||||
|
||||
if ($disk === 'delivery'){
|
||||
$shopping_order = \App\Models\ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->user_invoice){
|
||||
$this->isPermission($shopping_order);
|
||||
$user_invoice = $shopping_order->user_invoice;
|
||||
$filename = $user_invoice->delivery_filename;
|
||||
$disk = $user_invoice->disk;
|
||||
$path = $user_invoice->getDownloadPathDelivery();
|
||||
if (!Storage::disk($disk)->exists($path)) {
|
||||
return Response::make('File no found.', 404);;
|
||||
}
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
|
||||
}
|
||||
if($do === 'download'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
|
||||
}
|
||||
if($do === 'stream'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition','inline; 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);
|
||||
$mime = Storage::disk('public')->mimeType($path);
|
||||
|
||||
if($do === 'download'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition', 'attachment; filename="'.$filename.'"');
|
||||
}
|
||||
if($do === 'stream'){
|
||||
return Response::make($file, 200)
|
||||
->header("Content-Type", $mime)
|
||||
->header('Content-disposition','filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -391,22 +391,23 @@ class LeadController extends Controller
|
|||
->addColumn('payment_shop_date', function (User $user) {
|
||||
return $user->payment_shop ? $user->getPaymentShopDateFormat(false) : "-";
|
||||
})
|
||||
->addColumn('shop_domain', function (User $user) {
|
||||
return $user->shop ? ' <span class="small">'.$user->shop->getSubdomain(false).'</span>' : '';
|
||||
|
||||
})
|
||||
->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', 'payment_shop'])
|
||||
->rawColumns(['id', 'confirmed', 'active', 'agreement', 'payment_account', 'payment_shop', 'shop_domain'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ class MembershipController extends Controller
|
|||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$qty = Request::get('qty') ? Request::get('qty') : 1;
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
$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]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
|
|||
239
app/Http/Controllers/PaymentCreditController.php
Normal file
239
app/Http/Controllers/PaymentCreditController.php
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
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\UserCreditMargin;
|
||||
use App\Repositories\CreditRepository;
|
||||
|
||||
class PaymentCreditController extends Controller
|
||||
{
|
||||
|
||||
private $startYear;
|
||||
private $endYear;
|
||||
private $rangeYears;
|
||||
private $activeYear;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->startYear = 2021;
|
||||
$this->endYear = date('Y');
|
||||
$this->rangeYears = range($this->startYear, $this->endYear);
|
||||
$this->activeYear = $this->endYear;
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
abort(403, "in progress");
|
||||
$data = $this->makeData();
|
||||
return view('admin.payment.credit.index', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function store(){
|
||||
$data = Request::all();
|
||||
|
||||
if(isset($data['action']) && $data['action'] === 'add-user-credit'){
|
||||
$add_credit_error = false;
|
||||
if(!isset($data['member_id']) || !$user = User::find($data['member_id'])){
|
||||
$add_credit_error = 'Vertriebspartner nicht gefunden';
|
||||
}
|
||||
if(!isset($data['credit'])){
|
||||
$add_credit_error = 'Bitte Betrag eingeben';
|
||||
}
|
||||
if(!isset($data['message'])){
|
||||
$add_credit_error = 'Bitte Mitteilung eingeben';
|
||||
}
|
||||
if($add_credit_error){
|
||||
$data = $this->makeData();
|
||||
$data['add_credit_error'] = $add_credit_error;
|
||||
return view('admin.payment.credit.index', $data);
|
||||
}
|
||||
|
||||
$credit = Util::reFormatNumber($data['credit']);
|
||||
$credit = number_format($credit, 2, '.', '');
|
||||
|
||||
Payment::addUserCreditMargin($user, $credit, 3, $data['message']);
|
||||
\Session()->flash('alert-success', "Guthaben hinzugefügt");
|
||||
}
|
||||
|
||||
return redirect(route('admin_payments_credit'));
|
||||
}
|
||||
|
||||
public function create(){
|
||||
$data = Request::all();
|
||||
if(isset($data['action'])){
|
||||
if($data['action'] === 'create_credit'){
|
||||
if(!isset($data['userid'])){
|
||||
abort(404);
|
||||
}
|
||||
$user = User::findOrFail($data['userid']);
|
||||
$invoice_repo = new CreditRepository($user);
|
||||
$invoice_repo->create($data);
|
||||
\Session()->flash('alert-success', "Gutschrift erstellt");
|
||||
return redirect($data['back']);
|
||||
}
|
||||
if($data['action'] === 'user-credit-status'){
|
||||
$UserCredit = UserCredit::findOrFail($data['id']);
|
||||
$UserCredit->status = $data['status'];
|
||||
$UserCredit->save();
|
||||
\Session()->flash('alert-success', "Status gespeichert");
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function makeData(){
|
||||
$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();
|
||||
|
||||
$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 = [
|
||||
'years' => $this->rangeYears,
|
||||
'active_year' => $this->activeYear,
|
||||
'ShoppingOrderMargins' => $ShoppingOrderMargins,
|
||||
'ShoppingOrderMarginPendings' => $ShoppingOrderMarginPendings,
|
||||
'onlyUserCreditMargins' => $onlyUserCreditMargins,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function setActiveYears(){
|
||||
if(Request::get('filter_sales_year')){
|
||||
$this->activeYear = Request::get('filter_sales_year');
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id, $del){
|
||||
|
||||
if($del === 'user_credit_margin'){
|
||||
$UserCreditMargin = UserCreditMargin::findOrFail($id);
|
||||
if($deleteTime = $UserCreditMargin->deleteTime()){
|
||||
$UserCreditMargin->delete();
|
||||
\Session()->flash('alert-success', "Guthaben ist gelöscht");
|
||||
}else{
|
||||
\Session()->flash('alert-error', "Guthaben kann nicht gelöscht werden");
|
||||
}
|
||||
}
|
||||
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');
|
||||
|
||||
$query = UserCredit::with('user', 'user.account')->select('user_credits.*')
|
||||
//::with('shopping_user', )->select('shopping_orders.*')
|
||||
//->where('paid', '=', 1)
|
||||
->whereBetween('date', [$date1, $date2]);
|
||||
//->orderBy('created_at', 'DESC');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
|
||||
->addColumn('total', function (UserCredit $UserCredit) {
|
||||
return $UserCredit->getFormattedTotal()." €";
|
||||
})
|
||||
->addColumn('user_margins', function (UserCredit $UserCredit) {
|
||||
$ret = "";
|
||||
if($UserCredit->user_margins){
|
||||
foreach($UserCredit->user_margins as $user_margin){
|
||||
$ret .= $user_margin->firstname."/".$user_margin->lastname."/".$user_margin->reference."/".$user_margin->created_at."<br>";
|
||||
}
|
||||
}
|
||||
if($UserCredit->user_credits){
|
||||
foreach($UserCredit->user_credits as $user_credit){
|
||||
$ret .= nl2br($user_credit->message)." / ".$user_credit->created_at."<br>";
|
||||
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
})
|
||||
/* ->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
|
||||
return Payment::getShoppingOrderBadge($ShoppingOrder);
|
||||
})*/
|
||||
->addColumn('credit', function (UserCredit $UserCredit) {
|
||||
$ret = "";
|
||||
if(Credit::isCredit($UserCredit)){
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
}else{
|
||||
$ret = "-";
|
||||
}
|
||||
return $ret;
|
||||
})
|
||||
|
||||
->addColumn('status', function (UserCredit $UserCredit) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-load-content" data-modal="modal-lg"
|
||||
data-id="'.$UserCredit->id.'" data-route="'.route('modal_load').'" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-'.$UserCredit->getStatusColor().'">'.$UserCredit->getStatusType().' <span class="ion ion-md-cash"></span></span>
|
||||
</a>';
|
||||
})
|
||||
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('status', 'status $1')
|
||||
->orderColumn('total', 'total $1')
|
||||
->rawColumns(['shipping_order', 'total', 'credit', 'status', 'user_margins'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
129
app/Http/Controllers/PaymentInvoiceController.php
Normal file
129
app/Http/Controllers/PaymentInvoiceController.php
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Services\Payment;
|
||||
use App\Models\UserInvoice;
|
||||
|
||||
class PaymentInvoiceController extends Controller
|
||||
{
|
||||
|
||||
private $startYear;
|
||||
private $endYear;
|
||||
private $rangeYears;
|
||||
private $activeYear;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => UserInvoice::$monthNames,
|
||||
'filter_years' => UserInvoice::getYearRange(),
|
||||
];
|
||||
return view('admin.payment.invoice', $data);
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
|
||||
if(!session('invoice_filter_month')){
|
||||
session(['invoice_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('invoice_filter_year')){
|
||||
session(['invoice_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(Request::get('invoice_filter_name')){
|
||||
session(['invoice_filter_name' => Request::get('invoice_filter_name')]);
|
||||
}
|
||||
if(Request::get('invoice_filter_month')){
|
||||
session(['invoice_filter_month' => Request::get('invoice_filter_month')]);
|
||||
}
|
||||
if(Request::get('invoice_filter_year')){
|
||||
session(['invoice_filter_year' => Request::get('invoice_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
||||
private function initSearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('invoice_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if(Request::get('invoice_filter_name')){
|
||||
$query->where('shopping_order.shopping_user.billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->where('shopping_order.shopping_user.billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->where('shopping_order.shopping_user.billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
}
|
||||
|
||||
//->orderBy('created_at', 'DESC');
|
||||
/* $query = FlexHour::leftJoin("flex_hour_items", function($join) {
|
||||
$join->on("flex_hour_items.flex_hour_id","=","flex_hours.id");
|
||||
$join->where("flex_hour_items.date","=", FlexHourItemBot::$date);
|
||||
})*/
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$query = $this->initSearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order->auth_user_id){
|
||||
return '<a href="' . route('admin_sales_users_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
}
|
||||
return '<a href="' . route('admin_sales_customers_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
|
||||
})
|
||||
->addColumn('total_shipping', function (UserInvoice $UserInvoice) {
|
||||
return '<span class="no-line-break">'.$UserInvoice->shopping_order->getFormattedTotalShipping()." €</span>";
|
||||
})
|
||||
->addColumn('created_at', function (UserInvoice $UserInvoice) {
|
||||
return $UserInvoice->created_at->format("d.m.Y");
|
||||
})
|
||||
/*
|
||||
->addColumn('shipping_order', function (UserInvoice $UserInvoice) {
|
||||
$ret = "";
|
||||
foreach($UserInvoice->shopping_order_items as $shopping_order_item){
|
||||
$ret .= $shopping_order_item->product->name."<br>";
|
||||
}
|
||||
return $ret;
|
||||
})
|
||||
*/
|
||||
->addColumn('txaction', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order){
|
||||
return Payment::getShoppingOrderBadge($UserInvoice->shopping_order);
|
||||
}
|
||||
return "-";
|
||||
})
|
||||
->addColumn('status', function (UserInvoice $UserInvoice) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-load-content" data-modal="modal-lg"
|
||||
data-id="'.$UserInvoice->id.'" data-route="'.route('modal_load').'" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-'.$UserInvoice->getStatusColor().'">'.$UserInvoice->getStatusType().'</span>
|
||||
</a>';
|
||||
})
|
||||
->addColumn('invoice', function (UserInvoice $UserInvoice) {
|
||||
$ret = "";
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
|
||||
return $ret;
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('invoice_number', 'invoice_number $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->rawColumns(['id', 'shipping_order', 'txaction', 'total_shipping', 'status', 'txaction', 'invoice'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,14 +2,15 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\PaymentTransaction;
|
||||
use Request;
|
||||
use App\Models\UserShop;
|
||||
use App\Services\Payment;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserShop;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Services\Payment;
|
||||
use Request;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
|
||||
class SalesController extends Controller
|
||||
{
|
||||
|
|
@ -70,7 +71,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('payment', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
|
||||
|
|
@ -78,17 +79,12 @@ class SalesController extends Controller
|
|||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
})
|
||||
->addColumn('is_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
if($ShoppingOrder->shopping_user->is_for === 'me'){
|
||||
return '<span class="badge badge-pill badge-secondary">Beraterbestellung</span>';
|
||||
}
|
||||
if($ShoppingOrder->shopping_user->is_for === 'ot'){
|
||||
return '<span class="badge badge-pill badge-info">Kundenbestellung</span>';
|
||||
}
|
||||
if($ShoppingOrder->shopping_user->is_for === 'hp'){
|
||||
return '<span class="badge badge-pill badge-dark">Homepartybestellung</span>';
|
||||
}
|
||||
return '-';
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</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>' : '-';
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
|
|
@ -108,8 +104,9 @@ class SalesController extends Controller
|
|||
->orderColumn('user_shop_id', 'user_shop_id $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
|
||||
->rawColumns(['id', 'txaction', 'user_shop_id', 'auth_user_shop', 'is_for', 'shipped'])
|
||||
->rawColumns(['id', 'txaction', 'user_shop_id', 'auth_user_shop', 'payment_for', 'total_shipping', 'invoice', 'shipped'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +217,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('payment', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
|
||||
|
|
@ -228,17 +225,15 @@ class SalesController extends Controller
|
|||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
})
|
||||
->addColumn('is_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
if($ShoppingOrder->shopping_user->is_for === 'me'){
|
||||
return '<span class="badge badge-pill badge-secondary">Beraterbestellung</span>';
|
||||
}
|
||||
if($ShoppingOrder->shopping_user->is_for === 'ot'){
|
||||
return '<span class="badge badge-pill badge-info">Kundenbestellung</span>';
|
||||
}
|
||||
if($ShoppingOrder->shopping_user->is_for === 'hp'){
|
||||
return '<span class="badge badge-pill badge-dark">Homepartybestellung</span>';
|
||||
}
|
||||
return '-';
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
|
||||
})
|
||||
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
|
||||
if($ShoppingOrder->txaction === 'extern' && $ShoppingOrder->wp_invoice_path){
|
||||
return '<span class="no-line-break"><a href="'.$ShoppingOrder->wp_invoice_path.'" class="btn btn-secondary btn-xs"><i class="fa fa-external-link-alt"></i> <i class="fa fa-download"></i></a> </div>';
|
||||
}
|
||||
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
|
||||
<a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a></span>' : '-';
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
|
|
@ -267,8 +262,9 @@ class SalesController extends Controller
|
|||
->orderColumn('user_shop_id', 'user_shop_id $1')
|
||||
->orderColumn('member_id', 'member_id $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->rawColumns(['id', 'member_id', 'txaction', 'user_shop_id', 'is_for', 'shipped'])
|
||||
->rawColumns(['id', 'member_id', 'txaction', 'user_shop_id', 'payment_for', 'total_shipping', 'invoice', 'shipped'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
|
@ -306,6 +302,8 @@ class SalesController extends Controller
|
|||
$shopping_payment->save();
|
||||
|
||||
//TODO can send MAIL
|
||||
//Bei Zahlung auf Rechnung wurde die Rechnung schon erstellt,
|
||||
//wenn muss hier die Storno erstellt werden
|
||||
//Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
|
||||
}
|
||||
|
||||
|
|
@ -315,4 +313,31 @@ class SalesController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Manuelle Rechnung erstellen.*/
|
||||
public function invoice(){
|
||||
$data = Request::all();
|
||||
if(!isset($data['id'])){
|
||||
abort(404);
|
||||
}
|
||||
if(isset($data['action'])){
|
||||
if($data['action'] === 'create_invoice'){
|
||||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if($shopping_order->isInvoice()){
|
||||
$invoice_repo->update($data);
|
||||
}else{
|
||||
$invoice_repo->createAndSalesVolume($data);
|
||||
}
|
||||
if(isset($data['view']) && $data['view'] === 'sales_customer'){
|
||||
return redirect(route('admin_sales_customers_detail', [$shopping_order->id]));
|
||||
}
|
||||
return redirect(route('admin_sales_users_detail', [$shopping_order->id]));
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
45
app/Http/Controllers/SettingController.php
Normal file
45
app/Http/Controllers/SettingController.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Request;
|
||||
|
||||
|
||||
class SettingController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'values' => [],
|
||||
];
|
||||
return view('admin.settings.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
if(isset($data['action'])){
|
||||
if(isset($data['settings'])){
|
||||
foreach ($data['settings'] as $key=>$value){
|
||||
$value['val'] = isset($value['val']) ? $value['val'] : false;
|
||||
Setting::setContentBySlug($key, $value['val'], $value['type']);
|
||||
}
|
||||
}
|
||||
}
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_settings'));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -3,20 +3,23 @@
|
|||
namespace App\Http\Controllers\SyS;
|
||||
|
||||
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Http\Controllers\Api\KasSLLController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailInfo;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserShop;
|
||||
use App\Repositories\ContractPDFRepository;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Services\Shop;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Mail\MailInfo;
|
||||
use App\Services\Shop;
|
||||
use App\Models\UserShop;
|
||||
use App\Models\Homeparty;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Repositories\ContractPDFRepository;
|
||||
use App\Http\Controllers\Api\KasSLLController;
|
||||
|
||||
|
||||
class AdminToolsController extends Controller
|
||||
|
|
@ -86,7 +89,166 @@ class AdminToolsController extends Controller
|
|||
return back();
|
||||
}
|
||||
|
||||
public function points()
|
||||
{
|
||||
$c = 0;
|
||||
|
||||
if(false){ //8
|
||||
dump("make homeparty tax_split in shopping_order");
|
||||
dd('check point function');
|
||||
$ShoppingOrders = ShoppingOrder::where('payment_for', '=', NULL)->get();
|
||||
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
dump($ShoppingOrder->id);
|
||||
dump($ShoppingOrder->shopping_user->getOrderPaymentFor());
|
||||
$ShoppingOrder->payment_for = $ShoppingOrder->shopping_user->getOrderPaymentFor();
|
||||
$ShoppingOrder->save();
|
||||
|
||||
$c ++;
|
||||
}
|
||||
dd($c);
|
||||
}
|
||||
|
||||
|
||||
if(false){ //8
|
||||
dump("make homeparty tax_split in shopping_order");
|
||||
dd('check point function');
|
||||
$ShoppingOrders = ShoppingOrder::where('homeparty_id', '!=', NULL)->get();
|
||||
//->skip(0)->take(500)->get();
|
||||
//->skip(500)->take(500)->get();
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
$ShoppingOrder->makeHomepartyTaxSplit();
|
||||
$c ++;
|
||||
}
|
||||
dd($c);
|
||||
}
|
||||
|
||||
if(false){ //7
|
||||
dump("make homeparty shipping_tax in homeparty order user_cart");
|
||||
dd('check point function');
|
||||
$ShoppingOrders = ShoppingOrder::where('homeparty_id', '!=', NULL)->get();
|
||||
//->skip(0)->take(500)->get();
|
||||
//->skip(500)->take(500)->get();
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
if(isset($ShoppingOrder->homeparty->order['user_carts'])){
|
||||
$user_carts = [];
|
||||
foreach($ShoppingOrder->homeparty->order['user_carts'] as $id => $values){
|
||||
$values['shipping_tax'] = round($values['shipping_price'] - $values['shipping_price_net'], 2);
|
||||
dump($values['shipping_tax']);
|
||||
$user_carts[$id] = $values;
|
||||
}
|
||||
$order = $ShoppingOrder->homeparty->order;
|
||||
$order['user_carts'] = $user_carts;
|
||||
$ShoppingOrder->homeparty->order = $order;
|
||||
$ShoppingOrder->homeparty->save();
|
||||
|
||||
}
|
||||
$c ++;
|
||||
}
|
||||
dd($c);
|
||||
}
|
||||
|
||||
if(false){ //6
|
||||
dump("make tax_split in shopping_order");
|
||||
dd('check point function');
|
||||
$ShoppingOrders = ShoppingOrder::where('homeparty_id', '=', NULL)->get();
|
||||
//->skip(0)->take(500)->get();
|
||||
//->skip(500)->take(500)->get();
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
$ShoppingOrder->makeTaxSplit();
|
||||
$c ++;
|
||||
}
|
||||
dd($c);
|
||||
}
|
||||
|
||||
if(false){ //5
|
||||
//run after make points etc.
|
||||
dump("correction shopping_order homeparty");
|
||||
//dd('check point function');
|
||||
$ShoppingOrders = ShoppingOrder::where('payment_for', 5)->get();
|
||||
//->skip(0)->take(500)->get();
|
||||
//->skip(500)->take(500)->get();
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
$homeparty = Homeparty::find($ShoppingOrder->homeparty_id);
|
||||
if($homeparty && $homeparty->completed && $homeparty->step > 10){
|
||||
$ShoppingOrder->subtotal = $homeparty->order['ek_price_net'];
|
||||
$ShoppingOrder->subtotal_ws = 0;
|
||||
$ShoppingOrder->tax = $ShoppingOrder->total - $homeparty->order['ek_price_net'];
|
||||
$ShoppingOrder->points = $homeparty->order['points'] - $homeparty->order['bonus_points_diff'];
|
||||
$ShoppingOrder->save();
|
||||
$c ++;
|
||||
}
|
||||
|
||||
}
|
||||
dd($c);
|
||||
}
|
||||
|
||||
if(false){ //4
|
||||
dump("make tax in ShoppingOrderItem");
|
||||
dd('check point function');
|
||||
$ShoppingOrderItems = ShoppingOrderItem::all();
|
||||
//->skip(0)->take(500)->get();
|
||||
//->skip(500)->take(500)->get();
|
||||
foreach($ShoppingOrderItems as $item){
|
||||
$item->tax = $item->price - $item->price_net;
|
||||
$item->save();
|
||||
$c ++;
|
||||
}
|
||||
dd($c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(false){ //3
|
||||
dump("make price_net in ShoppingOrderItem");
|
||||
dd('check point function');
|
||||
$ShoppingOrderItems = ShoppingOrderItem::where('price_net', '=', NULL)->get();
|
||||
//->skip(0)->take(500)->get();
|
||||
//->skip(500)->take(500)->get();
|
||||
foreach($ShoppingOrderItems as $item){
|
||||
$item->price_net = $item->price / (100 + $item->tax_rate) * 100;
|
||||
$item->save();
|
||||
$c ++;
|
||||
}
|
||||
dd($c);
|
||||
}
|
||||
|
||||
if(false){ //2
|
||||
dump("add payment_for in shopping_order");
|
||||
dd('check point function');
|
||||
$ShoppingUsers = ShoppingUser::all();
|
||||
foreach($ShoppingUsers as $ShoppingUser){
|
||||
if($ShoppingUser->shopping_order){
|
||||
$ShoppingUser->shopping_order->payment_for = $ShoppingUser->getOrderPaymentFor();
|
||||
$ShoppingUser->shopping_order->save();
|
||||
$c ++;
|
||||
}
|
||||
}
|
||||
dd($c);
|
||||
}
|
||||
|
||||
if(false){ //1
|
||||
dump("make points in shopping_order_item and total in ShoppingOrder");
|
||||
dd('check point function');
|
||||
$ShoppingOrders = ShoppingOrder::all();
|
||||
//->skip(0)->take(500)->get();
|
||||
//->skip(500)->take(500)->get();
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
$points_total = 0;
|
||||
foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){
|
||||
$points = $shopping_order_item->product ? $shopping_order_item->product->points : 0;
|
||||
$points_total += $points;
|
||||
$shopping_order_item->points = $points;
|
||||
$shopping_order_item->save();
|
||||
$c ++;
|
||||
}
|
||||
$ShoppingOrder->points = $points_total;
|
||||
$ShoppingOrder->save();
|
||||
}
|
||||
dd($c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function cronjobs()
|
||||
|
|
|
|||
|
|
@ -342,8 +342,8 @@ class HomepartyController extends Controller
|
|||
'tax_rate' => 0,
|
||||
'points' => $product->points,
|
||||
'margin' => $margin,
|
||||
'ek-price' => $product->getPriceWith(true, true, $homeparty->getUserCountry()),
|
||||
'ek-price_net' => $product->getPriceWith(true, true, $homeparty->getUserCountry()),
|
||||
'ek_price' => $product->getPriceWith(true, true, $homeparty->getUserCountry()),
|
||||
'ek_price_net' => $product->getPriceWith(true, true, $homeparty->getUserCountry()),
|
||||
'slug' => $product->slug
|
||||
]);
|
||||
}else{
|
||||
|
|
@ -357,8 +357,8 @@ class HomepartyController extends Controller
|
|||
'tax_rate' => $product->getTaxWith($homeparty->getUserCountry()),
|
||||
'points' => $product->points,
|
||||
'margin' => $margin,
|
||||
'ek-price' => $product->getPriceWith(false, true, $homeparty->getUserCountry()),
|
||||
'ek-price_net' => $product->getPriceWith(true, true, $homeparty->getUserCountry()),
|
||||
'ek_price' => $product->getPriceWith(false, true, $homeparty->getUserCountry()),
|
||||
'ek_price_net' => $product->getPriceWith(true, true, $homeparty->getUserCountry()),
|
||||
'slug' => $product->slug
|
||||
]);
|
||||
}
|
||||
|
|
@ -459,7 +459,7 @@ class HomepartyController extends Controller
|
|||
$date = date('d.m.Y H:i:s', $time);
|
||||
$user = User::find(Auth::user()->id);
|
||||
Yard::instance('shopping')->destroy();
|
||||
$cartItem = Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty '.$date, 1, \App\Services\HomepartyCart::$ek_price, ['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();
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class OrderController 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('payment', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
|
||||
|
|
@ -76,17 +76,12 @@ class OrderController extends Controller
|
|||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
})
|
||||
->addColumn('is_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
if($ShoppingOrder->shopping_user->is_for === 'me'){
|
||||
return '<span class="badge badge-pill badge-secondary">Beraterbestellung</span>';
|
||||
}
|
||||
if($ShoppingOrder->shopping_user->is_for === 'ot'){
|
||||
return '<span class="badge badge-pill badge-info">Kundenbestellung</span>';
|
||||
}
|
||||
if($ShoppingOrder->shopping_user->is_for === 'hp'){
|
||||
return '<span class="badge badge-pill badge-dark">Homepartybestellung</span>';
|
||||
}
|
||||
return '-';
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</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>' : '-';
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
|
|
@ -95,7 +90,9 @@ class OrderController extends Controller
|
|||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->rawColumns(['id', 'txaction', 'is_for', 'shipped'])
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
|
||||
->rawColumns(['id', 'txaction', 'payment_for', 'total_shipping', 'invoice', 'shipped'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
|
@ -381,7 +378,7 @@ class OrderController extends Controller
|
|||
}
|
||||
|
||||
//get the card item
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(false, true, Yard::instance('shopping')->getUserCountry()), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(false, true, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance('shopping')->getUserCountry()));
|
||||
|
||||
if(isset($data['qty']) && $data['qty'] > 0){
|
||||
|
|
@ -458,7 +455,7 @@ class OrderController extends Controller
|
|||
if ($product->images->count()) {
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, 0,
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, 0, false, false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => 0, 'points' => 0,
|
||||
'comp' => $data['comp_num'], 'product_id' => $product->id]);
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class ShopSalesController 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 : '';
|
||||
|
|
@ -61,11 +61,22 @@ class ShopSalesController extends Controller
|
|||
->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>' : '';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</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('user_shop_id', 'user_shop_id $1')
|
||||
->rawColumns(['id', 'txaction', 'user_shop_id'])
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
|
||||
|
||||
->rawColumns(['id', 'txaction', 'user_shop_id', 'total_shipping', 'invoice', 'payment_for'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class CardController extends Controller
|
|||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
|
||||
if(Yard::instance('shopping')->getUserTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
@ -59,7 +59,7 @@ class CardController extends Controller
|
|||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
|
||||
if(Yard::instance('shopping')->getUserTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
@ -81,6 +81,7 @@ class CardController extends Controller
|
|||
}else{
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange(),
|
||||
|
|
|
|||
|
|
@ -255,7 +255,6 @@ class CheckoutController extends Controller
|
|||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
$data = Request::all();
|
||||
//make User
|
||||
$shopping_user = $this->makeShoppingUser($data);
|
||||
|
|
@ -471,19 +470,20 @@ class CheckoutController extends Controller
|
|||
//get data
|
||||
$homeparty = Homeparty::find($shopping_user->homeparty_id);
|
||||
//set Data!
|
||||
$total = Yard::instance('shopping')->total(2, '.', ''); //ek_price
|
||||
$data = [
|
||||
'shopping_user_id' => $shopping_user->id,
|
||||
'auth_user_id' => $shopping_user->auth_user_id,
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'user_shop_id' => $user_shop->id,
|
||||
'payment_for' => Util::getUserPaymentFor(),
|
||||
'payment_for' => $shopping_user->getOrderPaymentFor(),
|
||||
'homeparty_id' => $shopping_user->homeparty_id,
|
||||
'total' => Yard::instance('shopping')->total(2, '.', ''),
|
||||
'subtotal' => $homeparty->order['price_net'],
|
||||
'total' => $total,
|
||||
'subtotal' => $homeparty->order['ek_price_net'],
|
||||
'shipping' => $homeparty->order['shipping_price'],
|
||||
'shipping_net' => $homeparty->order['shipping_price_net'],
|
||||
'subtotal_ws' => 0,
|
||||
'tax' => 0,
|
||||
'tax' => $total - $homeparty->order['ek_price_net'],
|
||||
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'points' => $homeparty->order['points'] - $homeparty->order['bonus_points_diff'],
|
||||
'weight' => 0,
|
||||
|
|
@ -496,7 +496,7 @@ class CheckoutController extends Controller
|
|||
'auth_user_id' => $shopping_user->auth_user_id,
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'user_shop_id' => $user_shop->id,
|
||||
'payment_for' => Util::getUserPaymentFor(),
|
||||
'payment_for' => $shopping_user->getOrderPaymentFor(),
|
||||
'total' => Yard::instance('shopping')->total(2, '.', ''),
|
||||
'subtotal' => Yard::instance('shopping')->subtotal(2, '.', ''),
|
||||
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
|
||||
|
|
@ -528,6 +528,8 @@ class CheckoutController extends Controller
|
|||
$shopping_order->shopping_order_items()->each(function($model) use ($items, $shopping_order, $shopping_user) {
|
||||
foreach ($items as $item) {
|
||||
if ($model->row_id === $item->rowId) {
|
||||
$price_net = Yard::instance('shopping')->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
$data = [
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
|
|
@ -535,8 +537,12 @@ class CheckoutController extends Controller
|
|||
'comp' => $item->options->comp,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
|
||||
'price_net' => $price_net,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'tax' => $tax,
|
||||
'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id),
|
||||
'discount' => $shopping_order->getUserDiscount(),
|
||||
'points' => $item->options->points,
|
||||
'slug' => $item->options->slug,
|
||||
];
|
||||
if($shopping_user->is_from === 'homeparty'){
|
||||
|
|
@ -549,10 +555,12 @@ class CheckoutController extends Controller
|
|||
}
|
||||
return $model->delete();
|
||||
});
|
||||
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (!ShoppingOrderItem::where('shopping_order_id', $shopping_order->id)->where('row_id', $item->rowId)->count()){
|
||||
|
||||
$price_net = Yard::instance('shopping')->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
|
||||
$data = [
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
|
|
@ -560,8 +568,12 @@ class CheckoutController extends Controller
|
|||
'comp' => $item->options->comp,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
|
||||
'price_net' => $price_net,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'tax' => $tax,
|
||||
'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id),
|
||||
'discount' => $shopping_order->getUserDiscount(),
|
||||
'points' => $item->options->points,
|
||||
'slug' => $item->options->slug
|
||||
];
|
||||
|
||||
|
|
@ -573,8 +585,11 @@ class CheckoutController extends Controller
|
|||
$shopping_order_item = ShoppingOrderItem::create($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($shopping_user->is_from === 'homeparty'){
|
||||
$shopping_order->makeHomepartyTaxSplit();
|
||||
}else{
|
||||
$shopping_order->makeTaxSplit();
|
||||
}
|
||||
return $shopping_order;
|
||||
}
|
||||
|
||||
|
|
@ -605,7 +620,7 @@ class CheckoutController extends Controller
|
|||
{
|
||||
$this->session->remove($this->instance);
|
||||
}
|
||||
|
||||
//is for Rechnung MIV
|
||||
private function directPaymentStatus(PaymentTransaction $payt){
|
||||
|
||||
if(isset($payt->transmitted_data['param'])){
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ class WizardController extends Controller
|
|||
$image = $product->images->first()->slug;
|
||||
}
|
||||
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
$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]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
@ -494,7 +494,7 @@ class WizardController extends Controller
|
|||
if($product_on_board->images->count()){
|
||||
$image = $product_on_board->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight]);
|
||||
$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]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -27,11 +27,10 @@ class Subdomain
|
|||
$request->route()->forgetParameter('subdomain');
|
||||
Util::setPostRoute('user/');
|
||||
if($user_shop){
|
||||
|
||||
if(!$user_shop->active){
|
||||
abort(503);
|
||||
}
|
||||
if(!$user_shop->user->isActiveShop()){
|
||||
if(!$user_shop->user && !$user_shop->user->isActiveShop()){
|
||||
abort(503);
|
||||
}
|
||||
\Session::put('user_shop', $user_shop);
|
||||
|
|
|
|||
45
app/Libraries/InvoicePDF.php
Normal file
45
app/Libraries/InvoicePDF.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
namespace App\Libraries;
|
||||
|
||||
use App\Libraries\CouponPDF;
|
||||
use App\Models\Coupon;
|
||||
use Storage;
|
||||
|
||||
class InvoicePDF{
|
||||
|
||||
protected $view;
|
||||
protected $pdf;
|
||||
|
||||
|
||||
public function __construct($view)
|
||||
{
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function create($data, $name='test.pdf', $output='stream', $path = false){
|
||||
|
||||
header('Content-type: text/html; charset=UTF-8') ;//chrome
|
||||
//dd($data);
|
||||
|
||||
$pdf = app('dompdf.wrapper');
|
||||
$pdf->getDomPDF()->set_option("enable_php", true);
|
||||
$pdf->loadView($this->view, $data);
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
if($output === 'stream'){
|
||||
return $pdf->stream($name);
|
||||
}
|
||||
if($output === 'download'){
|
||||
return $pdf->download($name);
|
||||
}
|
||||
|
||||
if($output === 'save'){
|
||||
if($path){
|
||||
$pdf->save($path.$name);
|
||||
return $path.$name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
53
app/Mail/MailInvoice.php
Normal file
53
app/Mail/MailInvoice.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Services\Invoice;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\UserInvoice;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Storage;
|
||||
|
||||
class MailInvoice extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected $shopping_order;
|
||||
protected $user_invoice;
|
||||
|
||||
public $subject;
|
||||
|
||||
|
||||
public function __construct(ShoppingOrder $shopping_order, UserInvoice $user_invoice)
|
||||
{
|
||||
$this->shopping_order = $shopping_order;
|
||||
$this->user_invoice = $user_invoice;
|
||||
$this->subject = 'Rechnung zu Deiner Bestellung: '.$shopping_order->getLastShoppingPayment('reference') ;
|
||||
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$title = __('email.invoice_title');
|
||||
$copy1line = __('email.invoice_copy1line').$this->shopping_order->getLastShoppingPayment('reference');
|
||||
|
||||
$filename = $this->user_invoice->filename;
|
||||
$disk = $this->user_invoice->disk;
|
||||
$path = $this->user_invoice->getDownloadPath();
|
||||
if (!Storage::disk($disk)->exists($path)) {
|
||||
return;
|
||||
}
|
||||
$file = Storage::disk($disk)->path($path);
|
||||
$file = str_replace('//', '/', $file);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
|
||||
return $this->view('emails.blank')->with([
|
||||
'title' => $title,
|
||||
'copy1line' => $copy1line,
|
||||
])->attach($file,[
|
||||
'as' => $filename,
|
||||
'mime' => $mime,
|
||||
]); // attach file;
|
||||
}
|
||||
}
|
||||
|
|
@ -45,6 +45,7 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransHeadline($value)
|
||||
* @property-read \App\Models\IqImage|null $iq_image
|
||||
* @property-read int|null $product_categories_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ use PHPUnit\Framework\Constraint\Count;
|
|||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CountryPrice[] $country_prices
|
||||
* @property-read int|null $country_prices_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereCurrencyUnit($value)
|
||||
* @property bool|null $eu_country
|
||||
* @property bool|null $supply_country
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Country whereEuCountry($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Country whereSupplyCountry($value)
|
||||
*/
|
||||
class Country extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,6 +59,19 @@ use Illuminate\Database\Eloquent\Collection;
|
|||
* @property-read int|null $homeparty_guests_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereTokenActive($value)
|
||||
* @property int|null $country_id
|
||||
* @property int|null $step
|
||||
* @property array|null $settings
|
||||
* @property array|null $order
|
||||
* @property array|null $card_info
|
||||
* @property-read Country|null $country
|
||||
* @property-read Collection|\App\Models\HomepartyUserOrderItem[] $homeparty_order_items
|
||||
* @property-read int|null $homeparty_order_items_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereCardInfo($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereOrder($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereSettings($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereStep($value)
|
||||
*/
|
||||
class Homeparty extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\HomepartyUserOrderItem[] $homeparty_user_order_items
|
||||
* @property-read int|null $homeparty_user_order_items_count
|
||||
* @property string|null $delivery
|
||||
* @property array|null $settings
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUser whereDelivery($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUser whereSettings($value)
|
||||
*/
|
||||
class HomepartyUser extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property float $tax_rate
|
||||
* @property int $points
|
||||
* @property float $margin
|
||||
* @property float $ek-price
|
||||
* @property float $ek_price
|
||||
* @property string $slug
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
|
|
@ -48,6 +48,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereTaxRate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property float|null $ek_price_net
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUserOrderItem whereEkPriceNet($value)
|
||||
*/
|
||||
class HomepartyUserOrderItem extends Model
|
||||
{
|
||||
|
|
@ -63,8 +65,8 @@ class HomepartyUserOrderItem extends Model
|
|||
'tax_rate' => 'float',
|
||||
'points' => 'int',
|
||||
'margin' => 'float',
|
||||
'ek-price' => 'float',
|
||||
'ek-price_net' => 'float'
|
||||
'ek_price' => 'float',
|
||||
'ek_price_net' => 'float'
|
||||
|
||||
];
|
||||
|
||||
|
|
@ -78,8 +80,8 @@ class HomepartyUserOrderItem extends Model
|
|||
'tax_rate',
|
||||
'points',
|
||||
'margin',
|
||||
'ek-price',
|
||||
'ek-price_net',
|
||||
'ek_price',
|
||||
'ek_price_net',
|
||||
'slug'
|
||||
];
|
||||
|
||||
|
|
@ -120,32 +122,32 @@ class HomepartyUserOrderItem extends Model
|
|||
|
||||
public function getFormattedEKPrice()
|
||||
{
|
||||
return formatNumber($this->attributes['ek-price']);
|
||||
return formatNumber($this->attributes['ek_price']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalEKPrice()
|
||||
{
|
||||
return formatNumber($this->attributes['ek-price'] * $this->attributes['qty']);
|
||||
return formatNumber($this->attributes['ek_price'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function getFormattedEKPriceNet()
|
||||
{
|
||||
return formatNumber($this->attributes['ek-price_net']);
|
||||
return formatNumber($this->attributes['ek_price_net']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalEKPriceNet()
|
||||
{
|
||||
return formatNumber($this->attributes['ek-price_net'] * $this->attributes['qty']);
|
||||
return formatNumber($this->attributes['ek_price_net'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function getFormattedIncomePrice()
|
||||
{
|
||||
return formatNumber($this->attributes['price'] - $this->attributes['ek-price']);
|
||||
return formatNumber($this->attributes['price'] - $this->attributes['ek_price']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalIncomePrice()
|
||||
{
|
||||
return formatNumber(($this->attributes['price'] - $this->attributes['ek-price']) * $this->attributes['qty']);
|
||||
return formatNumber(($this->attributes['price'] - $this->attributes['ek_price']) * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalPoints()
|
||||
|
|
@ -171,22 +173,22 @@ class HomepartyUserOrderItem extends Model
|
|||
|
||||
public function geTotalEKPrice()
|
||||
{
|
||||
return (float) ($this->attributes['ek-price'] * $this->attributes['qty']);
|
||||
return (float) ($this->attributes['ek_price'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function geTotalEKPriceNet()
|
||||
{
|
||||
return (float) ($this->attributes['ek-price_net'] * $this->attributes['qty']);
|
||||
return (float) ($this->attributes['ek_price_net'] * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
public function getIncomePrice()
|
||||
{
|
||||
return (float) ($this->attributes['price'] - $this->attributes['ek-price']);
|
||||
return (float) ($this->attributes['price'] - $this->attributes['ek-ek_price']);
|
||||
}
|
||||
|
||||
public function geTotalIncomePrice()
|
||||
{
|
||||
return (float) (($this->attributes['price'] - $this->attributes['ek-price']) * $this->attributes['qty']);
|
||||
return (float) (($this->attributes['price'] - $this->attributes['ek_price']) * $this->attributes['qty']);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqImage wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|IqImage withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class IqImage extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShowAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property array|null $show_on
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PaymentMethod whereShowOn($value)
|
||||
*/
|
||||
class PaymentMethod extends Model
|
||||
{
|
||||
|
|
@ -85,7 +87,7 @@ class PaymentMethod extends Model
|
|||
|
||||
public function getShowOnTypes(){
|
||||
$ret = [];
|
||||
if($this->show_on){
|
||||
if($this->show_on && is_array($this->show_on)){
|
||||
foreach($this->show_on as $show){
|
||||
$ret[] = isset(self::$showONs[$show]) ? self::$showONs[$show] : '-';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property-read int|null $ingredients_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductIngredient[] $product_ingredients
|
||||
* @property-read int|null $product_ingredients_count
|
||||
* @property bool|null $no_commission
|
||||
* @property array|null $show_on
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Ingredient[] $p_ingredients
|
||||
* @property-read int|null $p_ingredients_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereNoCommission($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereShowOn($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
|
@ -297,8 +304,7 @@ class Product extends Model
|
|||
{
|
||||
return isset($this->attributes['price_ek']) ? Util::formatNumber($this->attributes['price_ek']) : "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getFormattedPriceOld()
|
||||
{
|
||||
return isset($this->attributes['price_old']) ? Util::formatNumber($this->attributes['price_old']) : "";
|
||||
|
|
@ -437,17 +443,18 @@ class Product extends Model
|
|||
|
||||
public function getShowOnTypes(){
|
||||
$ret = [];
|
||||
foreach($this->show_on as $show){
|
||||
$ret[] = isset($this->showONs[$show]) ? $this->showONs[$show] : '-';
|
||||
if($this->show_on && is_array($this->show_on)){
|
||||
foreach($this->show_on as $show){
|
||||
$ret[] = isset($this->showONs[$show]) ? $this->showONs[$show] : '-';
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public function setPosAttribute($value){
|
||||
$this->attributes['pos'] = is_numeric($value) ? $value : null;
|
||||
|
||||
}
|
||||
|
||||
public function getLang($key)
|
||||
{
|
||||
$lang = \App::getLocale();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory query()
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProductCategory wherePos($value)
|
||||
*/
|
||||
class ProductCategory extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage query()
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class ProductImage extends Model
|
||||
{
|
||||
|
|
|
|||
144
app/Models/Setting.php
Normal file
144
app/Models/Setting.php
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Setting
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $identifier
|
||||
* @property string $slug
|
||||
* @property int $referenz
|
||||
* @property string|null $action
|
||||
* @property string|null $object
|
||||
* @property string|null $full_text
|
||||
* @property string|null $text
|
||||
* @property int|null $int
|
||||
* @property int $status
|
||||
* @property string|null $type
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereAction($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereFullText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereInt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereObject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereReferenz($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereText($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $table = 'settings';
|
||||
|
||||
protected $casts = [
|
||||
'referenz' => 'int',
|
||||
'status' => 'int',
|
||||
'int' => 'int',
|
||||
'object' => 'array'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'identifier',
|
||||
'slug',
|
||||
'referenz',
|
||||
'action',
|
||||
'object',
|
||||
'full_text',
|
||||
'text',
|
||||
'int',
|
||||
'status',
|
||||
'type'
|
||||
];
|
||||
|
||||
protected static $types = [
|
||||
'object' => 'Object',
|
||||
'full_text' => 'Full Text',
|
||||
'text' => 'Text',
|
||||
'int' => 'Zahl',
|
||||
'bool' => 'Bool',
|
||||
|
||||
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
'source' => 'name'
|
||||
]
|
||||
];
|
||||
}
|
||||
public static function getContentBySlug($slug){
|
||||
$content = self::whereSlug(trim($slug))->first();
|
||||
if($content){
|
||||
switch ($content->type){
|
||||
case 'object':
|
||||
return $content->object;
|
||||
break;
|
||||
case 'full_text':
|
||||
return $content->full_text;
|
||||
break;
|
||||
case 'text':
|
||||
return $content->text;
|
||||
break;
|
||||
case 'int':
|
||||
return $content->int;
|
||||
break;
|
||||
case 'bool':
|
||||
return $content->int === 1 ? true : false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function setContentBySlug($slug, $value, $type = "full_text"){
|
||||
|
||||
$content = self::whereSlug(trim($slug))->first();
|
||||
if(!$content) {
|
||||
$content = self::create([
|
||||
'slug' => $slug,
|
||||
'type' => $type,
|
||||
]);
|
||||
}
|
||||
$content->type = $type;
|
||||
switch ($content->type){
|
||||
case 'object':
|
||||
$content->object = $value ? $value : null;;
|
||||
break;
|
||||
case 'full_text':
|
||||
$content->full_text = $value ? $value : null;;
|
||||
break;
|
||||
case 'text':
|
||||
$content->text = $value ? $value : null;;
|
||||
break;
|
||||
case 'int':
|
||||
$content->int = (int) $value;
|
||||
break;
|
||||
case 'bool':
|
||||
$content->int = $value ? 1 : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$content->save();
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
|
@ -80,6 +80,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereSubtotalWs($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereTracking($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereWpInvoicePath($value)
|
||||
* @property int|null $homeparty_id
|
||||
* @property array|null $wp_notice
|
||||
* @property-read \App\Models\Homeparty|null $homeparty
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereHomepartyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereWpNotice($value)
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
{
|
||||
|
|
@ -93,6 +98,7 @@ class ShoppingOrder extends Model
|
|||
'auth_user_id',
|
||||
'member_id',
|
||||
'homeparty_id',
|
||||
'payment_for',
|
||||
'country_id',
|
||||
'user_shop_id',
|
||||
'total',
|
||||
|
|
@ -101,6 +107,7 @@ class ShoppingOrder extends Model
|
|||
'shipping_net',
|
||||
'subtotal_ws',
|
||||
'tax',
|
||||
'tax_split',
|
||||
'total_shipping',
|
||||
'points',
|
||||
'weight',
|
||||
|
|
@ -115,6 +122,7 @@ class ShoppingOrder extends Model
|
|||
|
||||
protected $casts = [
|
||||
'wp_notice' => 'array',
|
||||
'tax_split' => 'array',
|
||||
];
|
||||
|
||||
public static $shippedTypes = [
|
||||
|
|
@ -141,6 +149,34 @@ class ShoppingOrder extends Model
|
|||
10 => 'danger',
|
||||
];
|
||||
|
||||
public static $paymentForTypes = [
|
||||
0 => '',
|
||||
1 => 'Registrierung',
|
||||
2 => 'Mitgliedschaft',
|
||||
3 => 'Bestellung',
|
||||
4 => 'Kundenbestellung',
|
||||
5 => 'Homeparty',
|
||||
6 => 'Shop',
|
||||
7 => 'extern',
|
||||
10 => '',
|
||||
];
|
||||
|
||||
public static $paymentForColors = [
|
||||
0 => 'default',
|
||||
1 => 'warning',
|
||||
2 => 'warning',
|
||||
3 => 'secondary',
|
||||
4 => 'info',
|
||||
5 => 'dark',
|
||||
6 => 'secondary',
|
||||
7 => 'dark',
|
||||
8 => 'info',
|
||||
9 => 'default',
|
||||
10 => 'info',
|
||||
11 => 'default'
|
||||
|
||||
];
|
||||
|
||||
|
||||
public function shopping_user()
|
||||
{
|
||||
|
|
@ -183,7 +219,10 @@ class ShoppingOrder extends Model
|
|||
return $this->hasOne('App\Models\UserHistory','shopping_order_id')->latest();
|
||||
}
|
||||
|
||||
|
||||
public function user_invoice(){
|
||||
return $this->hasOne('App\Models\UserInvoice', 'shopping_order_id', '');
|
||||
}
|
||||
|
||||
public function shopping_order_items(){
|
||||
return $this->hasMany('App\Models\ShoppingOrderItem', 'shopping_order_id');
|
||||
}
|
||||
|
|
@ -192,6 +231,18 @@ class ShoppingOrder extends Model
|
|||
return $this->hasMany('App\Models\ShoppingPayment', 'shopping_order_id');
|
||||
}
|
||||
|
||||
public function user_sales_volume(){
|
||||
return $this->hasMany('App\Models\UserSalesVolume', 'shopping_order_id');
|
||||
}
|
||||
|
||||
public function user_sales_volume_no_userid(){
|
||||
return $this->hasMany('App\Models\UserSalesVolume', 'shopping_order_id')->where('user_id', '=', NULL)->first();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function setUserHistoryValue($values = []){
|
||||
if($user_history = $this->user_history){
|
||||
foreach ($values as $key=>$val){
|
||||
|
|
@ -250,6 +301,11 @@ class ShoppingOrder extends Model
|
|||
{
|
||||
return formatNumber($this->attributes['subtotal_ws']);
|
||||
}
|
||||
|
||||
public function getFormattedSubtotalShipping()
|
||||
{
|
||||
return formatNumber($this->attributes['subtotal_shipping']);
|
||||
}
|
||||
|
||||
public function getFormattedTax()
|
||||
{
|
||||
|
|
@ -261,8 +317,33 @@ class ShoppingOrder extends Model
|
|||
return formatNumber($this->attributes['total_shipping']);
|
||||
}
|
||||
|
||||
public function getPriceVkNetBy($product_id)
|
||||
{
|
||||
if($product = Product::find($product_id)){
|
||||
if($this->shipping_country && $this->shipping_country->country){
|
||||
return $product->getPriceWith(true, false, $this->shipping_country->country);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPaymentForType(){
|
||||
return isset(self::$paymentForTypes[$this->payment_for]) ? self::$paymentForTypes[$this->payment_for] : "";
|
||||
}
|
||||
public function getPaymentForColor(){
|
||||
return isset(self::$paymentForColors[$this->payment_for]) ? self::$paymentForColors[$this->payment_for] : "";
|
||||
}
|
||||
|
||||
|
||||
public function getUserDiscount()
|
||||
{
|
||||
if($this->auth_user && $this->auth_user->user_level){
|
||||
return $this->auth_user->user_level->getFormattedMargin();
|
||||
}
|
||||
if($this->member && $this->member->user_level){
|
||||
return $this->member->user_level->getFormattedMargin();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getItemsCount(){
|
||||
$count = 0;
|
||||
|
|
@ -271,9 +352,128 @@ class ShoppingOrder extends Model
|
|||
$count += $shopping_order_item->qty;
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
public function isInvoice(){
|
||||
return $this->user_invoice ? true : false;
|
||||
}
|
||||
|
||||
public function getStatusByOrder(){
|
||||
if($this->payment_for){
|
||||
if($this->payment_for === 6){ //Kunde-Shop
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function makeHomepartyTaxSplit()
|
||||
{
|
||||
$tax_split = [];
|
||||
if($this->homeparty){
|
||||
foreach($this->homeparty->homeparty_order_items as $item){
|
||||
$tax_rate = intval($item->tax_rate);
|
||||
if($tax_rate > 0){
|
||||
$vk_tax = round((($item->price - $item->price_net) * $item->qty), 2);
|
||||
$ek_tax = round((($item->ek_price - $item->ek_price_net) * $item->qty), 2);
|
||||
if(isset($tax_split[$tax_rate])){
|
||||
$tax_split[$tax_rate]['vk_tax'] = round($tax_split[$tax_rate]['vk_tax'] + $vk_tax, 2);
|
||||
$tax_split[$tax_rate]['ek_tax'] = round($tax_split[$tax_rate]['ek_tax'] + $ek_tax, 2);
|
||||
}else{
|
||||
$tax_split[$tax_rate] = ['vk_tax' => $vk_tax, 'ek_tax' => $ek_tax];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_vk_tax = 0;
|
||||
$order_ek_tax = 0;
|
||||
if($this->homeparty->order){
|
||||
if(isset($this->homeparty->order['ek_price_net'])){
|
||||
$order_vk_tax = round((($this->homeparty->order['price'] - $this->homeparty->order['price_net'])), 2);
|
||||
$order_ek_tax = round((($this->homeparty->order['ek_price'] - $this->homeparty->order['ek_price_net'])), 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($tax_split[16])){
|
||||
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
}
|
||||
if(isset($tax_split[19])){
|
||||
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
}
|
||||
|
||||
if(isset($tax_split[5])){
|
||||
if(!isset($tax_split[16])){
|
||||
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
}
|
||||
$tax_split[16]['vk_tax'] = round($tax_split[16]['vk_tax'] - $tax_split[5]['vk_tax'], 2);
|
||||
$tax_split[16]['ek_tax'] = round($tax_split[16]['ek_tax'] - $tax_split[5]['ek_tax'], 2);
|
||||
}
|
||||
if(isset($tax_split[7])){
|
||||
if(!isset($tax_split[19])){
|
||||
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
}
|
||||
$tax_split[19]['vk_tax'] = round($tax_split[19]['vk_tax'] - $tax_split[7]['vk_tax'], 2);
|
||||
$tax_split[19]['ek_tax'] = round($tax_split[19]['ek_tax'] - $tax_split[7]['ek_tax'], 2);
|
||||
}
|
||||
|
||||
|
||||
foreach($tax_split as $key=>$value){
|
||||
$tax_split[$key]['vk_tax'] = number_format($value['vk_tax'], 2);
|
||||
$tax_split[$key]['ek_tax'] = number_format($value['ek_tax'], 2);
|
||||
|
||||
}
|
||||
}
|
||||
if(!isset($tax_split[16]) && !isset($tax_split[19])){
|
||||
$tax_split = NULL;
|
||||
}
|
||||
$this->tax_split = $tax_split;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function makeTaxSplit()
|
||||
{
|
||||
$tax_split = NULL;
|
||||
|
||||
if($this->tax > 0){
|
||||
$tax_split = [];
|
||||
foreach($this->shopping_order_items as $item){
|
||||
$tax_rate = intval($item->tax_rate);
|
||||
if($tax_rate > 0){
|
||||
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ?
|
||||
round($tax_split[$tax_rate] + ($item->tax * $item->qty), 2) :
|
||||
round(($item->tax * $item->qty), 2);
|
||||
}
|
||||
}
|
||||
if(isset($tax_split[16])){
|
||||
$tax_split[16] = $this->tax;
|
||||
}
|
||||
if(isset($tax_split[19])){
|
||||
$tax_split[19] = $this->tax;
|
||||
}
|
||||
|
||||
if(isset($tax_split[5])){
|
||||
if(!isset($tax_split[16])){
|
||||
$tax_split[16] = $this->tax;
|
||||
}
|
||||
$tax_split[16] = round($tax_split[16] - $tax_split[5], 2);
|
||||
}
|
||||
if(isset($tax_split[7])){
|
||||
if(!isset($tax_split[19])){
|
||||
$tax_split[19] = $this->tax;
|
||||
}
|
||||
$tax_split[19] = round($tax_split[19] - $tax_split[7], 2);
|
||||
|
||||
}
|
||||
|
||||
foreach($tax_split as $key=>$value){
|
||||
$tax_split[$key] = number_format($value, 2);
|
||||
}
|
||||
}
|
||||
$this->tax_split = $tax_split;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property float|null $price_net
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereComp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem wherePriceNet($value)
|
||||
* @property int|null $homeparty_id
|
||||
* @property-read \App\Models\Homeparty|null $homeparty
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereHomepartyId($value)
|
||||
*/
|
||||
class ShoppingOrderItem extends Model
|
||||
{
|
||||
|
|
@ -63,10 +66,13 @@ class ShoppingOrderItem extends Model
|
|||
'price',
|
||||
'price_net',
|
||||
'tax_rate',
|
||||
'tax',
|
||||
'price_vk_net',
|
||||
'discount',
|
||||
'points',
|
||||
'slug',
|
||||
];
|
||||
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ShoppingOrder','shopping_order_id');
|
||||
|
|
@ -97,6 +103,27 @@ class ShoppingOrderItem extends Model
|
|||
return formatNumber($this->attributes['price_net']);
|
||||
}
|
||||
|
||||
public function getFormattedPriceVkNet()
|
||||
{
|
||||
return formatNumber($this->attributes['price_vk_net']);
|
||||
}
|
||||
|
||||
public function getFormattedTaxRate()
|
||||
{
|
||||
return cleanNumberFormat($this->attributes['tax_rate']);
|
||||
}
|
||||
|
||||
public function getTaxRate()
|
||||
{
|
||||
return formatNumber($this->attributes['tax']);
|
||||
}
|
||||
|
||||
|
||||
public function getFormattedDiscount()
|
||||
{
|
||||
return cleanNumberFormat($this->attributes['discount']);
|
||||
}
|
||||
|
||||
public function getFormattedTotalPriceNet()
|
||||
{
|
||||
return formatNumber($this->attributes['price_net'] * $this->attributes['qty']);
|
||||
|
|
|
|||
|
|
@ -113,6 +113,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereIsFrom($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShoppingUserId($value)
|
||||
* @property int|null $homeparty_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereHomepartyId($value)
|
||||
*/
|
||||
class ShoppingUser extends Model
|
||||
{
|
||||
|
|
@ -246,6 +248,26 @@ class ShoppingUser extends Model
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getOrderPaymentFor() {
|
||||
|
||||
switch($this->is_from){
|
||||
case 'wizard':
|
||||
return 1;
|
||||
case 'membership':
|
||||
return 2;
|
||||
case 'user_order':
|
||||
return $this->is_for === 'me' ? 3 : 4;
|
||||
case 'homeparty':
|
||||
return 5;
|
||||
case 'shopping':
|
||||
return 6;
|
||||
case 'extern':
|
||||
return 7;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public function getAPIShippedType() {
|
||||
if($this->shopping_order){
|
||||
return $this->shopping_order->getAPIShippedType();
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|SySetting withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class SySetting extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -119,6 +119,12 @@ use Carbon\Carbon;
|
|||
* @property array|null $notice
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereAcceptedContract($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserAccount whereNotice($value)
|
||||
* @property int $reverse_charge
|
||||
* @property string|null $reverse_charge_code
|
||||
* @property string|null $reverse_charge_valid
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereReverseCharge($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereReverseChargeCode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereReverseChargeValid($value)
|
||||
*/
|
||||
class UserAccount extends Model
|
||||
{
|
||||
|
|
|
|||
183
app/Models/UserInvoice.php
Normal file
183
app/Models/UserInvoice.php
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class UserInvoice
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $shopping_order_id
|
||||
* @property int|null $month
|
||||
* @property int|null $year
|
||||
* @property Carbon|null $date
|
||||
* @property string|null $full_number
|
||||
* @property int|null $number
|
||||
* @property string|null $file
|
||||
* @property string|null $infos
|
||||
* @property bool $paid
|
||||
* @property Carbon|null $paid_date
|
||||
* @property bool $cancellation
|
||||
* @property int|null $cancellation_id
|
||||
* @property Carbon|null $cancellation_date
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
*
|
||||
* @property ShoppingOrder $shopping_order
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class UserInvoice extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'user_invoices';
|
||||
|
||||
protected $casts = [
|
||||
'shopping_order_id' => 'int',
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'number' => 'int',
|
||||
'paid' => 'bool',
|
||||
'cancellation' => 'bool',
|
||||
'cancellation_id' => 'int',
|
||||
'status' => 'int',
|
||||
'infos' => 'array',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date',
|
||||
'paid_date',
|
||||
'cancellation_date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'shopping_order_id',
|
||||
'month',
|
||||
'year',
|
||||
'date',
|
||||
'full_number',
|
||||
'number',
|
||||
'filename',
|
||||
'dir',
|
||||
'delivery_filename',
|
||||
'delivery_dir',
|
||||
'disk',
|
||||
'infos',
|
||||
'paid',
|
||||
'paid_date',
|
||||
'cancellation',
|
||||
'cancellation_id',
|
||||
'cancellation_date',
|
||||
'status'
|
||||
];
|
||||
|
||||
public static $monthNames = [
|
||||
1 => 'Januar',
|
||||
2 => 'Februar',
|
||||
3 => 'März',
|
||||
4 => 'April',
|
||||
5 => 'Mai',
|
||||
6 => 'Juni',
|
||||
7 => 'Juli',
|
||||
8 => 'August',
|
||||
9 => 'September',
|
||||
10 => 'Oktober',
|
||||
11 => 'November',
|
||||
12 => 'Dezember'
|
||||
];
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => '-',
|
||||
1 => 'Bestellung',
|
||||
2 => 'Shop',
|
||||
11 => 'storniert B.',
|
||||
12 => 'storniert Shop',
|
||||
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
11 => 'danger',
|
||||
12 => 'danger',
|
||||
|
||||
];
|
||||
|
||||
public function shopping_order(){
|
||||
return $this->belongsTo(ShoppingOrder::class);
|
||||
}
|
||||
|
||||
public function getDateAttribute($value){
|
||||
return $this->attributes['date'] ? Carbon::parse($this->attributes['date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setDateAttribute( $value ) {
|
||||
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getDateRaw(){
|
||||
return isset($this->attributes['date']) ? $this->attributes['date'] : NULL;
|
||||
}
|
||||
|
||||
public function getPaidDateAttribute($value){
|
||||
return $this->attributes['paid_date'] ? Carbon::parse($this->attributes['paid_date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setPaidDateAttribute( $value ) {
|
||||
$this->attributes['paid_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getPaidDateRaw(){
|
||||
return isset($this->attributes['paid_date']) ? $this->attributes['paid_date'] : NULL;
|
||||
}
|
||||
|
||||
public function getCancellationDateAttribute($value){
|
||||
return $this->attributes['cancellation_date'] ? Carbon::parse($this->attributes['cancellation_date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setCancellationDateAttribute( $value ) {
|
||||
$this->attributes['cancellation_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getCancellationDateRaw(){
|
||||
return isset($this->attributes['cancellation_date']) ? $this->attributes['cancellation_date'] : NULL;
|
||||
}
|
||||
|
||||
public static function getYearRange()
|
||||
{
|
||||
$start = 2021;
|
||||
$end = date("Y");
|
||||
return array_reverse(range($start, $end));
|
||||
}
|
||||
|
||||
public static function getMonthName($month)
|
||||
{
|
||||
return isset(self::$monthNames[$month]) ? self::$monthNames[$month] : $month;
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
public function getDownloadPath($full = false){
|
||||
if(!$full){
|
||||
return $this->dir.$this->filename;
|
||||
}
|
||||
return \Storage::disk($this->disk)->path($this->dir.$this->filename);
|
||||
}
|
||||
|
||||
public function getDownloadPathDelivery($full = false){
|
||||
if(!$full){
|
||||
return $this->delivery_dir.$this->delivery_filename;
|
||||
}
|
||||
return \Storage::disk($this->disk)->path($this->delivery_dir.$this->delivery_filename);
|
||||
}
|
||||
}
|
||||
229
app/Models/UserInvoiceCredit.php
Normal file
229
app/Models/UserInvoiceCredit.php
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class UserInvoiceCredit
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $auth_user_id
|
||||
* @property int|null $shopping_order_id
|
||||
* @property int|null $shopping_user_id
|
||||
* @property string $type
|
||||
* @property string|null $full_number
|
||||
* @property int|null $number
|
||||
* @property float|null $net
|
||||
* @property float|null $tax_rate
|
||||
* @property float|null $tax
|
||||
* @property float|null $total
|
||||
* @property string|null $file
|
||||
* @property string|null $contents
|
||||
* @property string|null $infos
|
||||
* @property string|null $subject
|
||||
* @property string|null $address
|
||||
* @property bool $paid
|
||||
* @property Carbon|null $paid_date
|
||||
* @property int|null $cancellation_id
|
||||
* @property Carbon|null $cancellation_date
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property User|null $user
|
||||
* @property UserInvoiceCredit|null $user_invoice_credit
|
||||
* @property ShoppingOrder|null $shopping_order
|
||||
* @property ShoppingUser|null $shopping_user
|
||||
* @property Collection|UserInvoiceCredit[] $user_invoice_credits
|
||||
* @package App\Models
|
||||
* @property-read int|null $user_invoice_credits_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|UserInvoiceCredit onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereAddress($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereAuthUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereCancellationDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereCancellationId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereContents($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereFile($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereFullNumber($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereInfos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereNet($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereNumber($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit wherePaid($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit wherePaidDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereShoppingOrderId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereShoppingUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereSubject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereTax($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereTaxRate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereTotal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoiceCredit whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|UserInvoiceCredit withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|UserInvoiceCredit withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserInvoiceCredit extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'user_invoice_credits';
|
||||
|
||||
protected $casts = [
|
||||
'auth_user_id' => 'int',
|
||||
'shopping_order_id' => 'int',
|
||||
'shopping_user_id' => 'int',
|
||||
'number' => 'int',
|
||||
'year' => 'int',
|
||||
'month' => 'int',
|
||||
'net' => 'float',
|
||||
'tax_rate' => 'float',
|
||||
'tax' => 'float',
|
||||
'total' => 'float',
|
||||
'paid' => 'bool',
|
||||
'cancellation_id' => 'int',
|
||||
'status' => 'int',
|
||||
'file' => 'array',
|
||||
'contents' => 'array',
|
||||
'infos' => 'array',
|
||||
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'paid_date',
|
||||
'cancellation_date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'auth_user_id',
|
||||
'shopping_order_id',
|
||||
'shopping_user_id',
|
||||
'type',
|
||||
'year',
|
||||
'month',
|
||||
'full_number',
|
||||
'number',
|
||||
'net',
|
||||
'tax_rate',
|
||||
'tax',
|
||||
'total',
|
||||
'file',
|
||||
'contents',
|
||||
'infos',
|
||||
'subject',
|
||||
'address',
|
||||
'paid',
|
||||
'paid_date',
|
||||
'cancellation_id',
|
||||
'cancellation_date',
|
||||
'status'
|
||||
];
|
||||
|
||||
public static $monthNames = [
|
||||
1 => 'Januar',
|
||||
2 => 'Februar',
|
||||
3 => 'März',
|
||||
4 => 'April',
|
||||
5 => 'Mai',
|
||||
6 => 'Juni',
|
||||
7 => 'Juli',
|
||||
8 => 'August',
|
||||
9 => 'September',
|
||||
10 => 'Oktober',
|
||||
11 => 'November',
|
||||
12 => 'Dezember'
|
||||
];
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => 'offen',
|
||||
1 => 'bezahlt',
|
||||
2 => 'prüfen',
|
||||
10 => 'storniert'
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
10 => 'danger',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\App\User::class, 'auth_user_id');
|
||||
}
|
||||
|
||||
public function user_invoice_credit()
|
||||
{
|
||||
return $this->belongsTo(UserInvoiceCredit::class, 'cancellation_id');
|
||||
}
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->belongsTo(ShoppingOrder::class);
|
||||
}
|
||||
|
||||
public function shopping_user()
|
||||
{
|
||||
return $this->belongsTo(ShoppingUser::class);
|
||||
}
|
||||
|
||||
public function user_invoice_credits()
|
||||
{
|
||||
return $this->hasMany(UserInvoiceCredit::class, 'cancellation_id');
|
||||
}
|
||||
|
||||
public function getPaidDateAttribute($value){
|
||||
return $this->attributes['paid_date'] ? Carbon::parse($this->attributes['paid_date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setPaidDateAttribute( $value ) {
|
||||
$this->attributes['paid_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getPaidDateRaw(){
|
||||
return isset($this->attributes['paid_date']) ? $this->attributes['paid_date'] : NULL;
|
||||
}
|
||||
|
||||
public function getCancellationDateAttribute($value){
|
||||
return $this->attributes['cancellation_date'] ? Carbon::parse($this->attributes['cancellation_date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setCancellationDateAttribute( $value ) {
|
||||
$this->attributes['cancellation_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getCancellationDateRaw(){
|
||||
return isset($this->attributes['cancellation_date']) ? $this->attributes['cancellation_date'] : NULL;
|
||||
}
|
||||
|
||||
public static function getYearRange()
|
||||
{
|
||||
$start = 2021;
|
||||
$end = date("Y");
|
||||
return array_reverse(range($start, $end));
|
||||
}
|
||||
|
||||
public static function getMonthName($month)
|
||||
{
|
||||
return isset(self::$monthNames[$month]) ? self::$monthNames[$month] : $month;
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
}
|
||||
152
app/Models/UserSalesVolume.php
Normal file
152
app/Models/UserSalesVolume.php
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\ShoppingOrder;
|
||||
|
||||
/**
|
||||
* Class UserSalesVolume
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int|null $shopping_order_id
|
||||
* @property int|null $month
|
||||
* @property int|null $year
|
||||
* @property Carbon|null $date
|
||||
* @property int|null $points
|
||||
* @property int|null $month_points
|
||||
* @property float|null $total_net
|
||||
* @property float|null $month_total_net
|
||||
* @property string|null $message
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property ShoppingOrder|null $shopping_order
|
||||
* @property User $user
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class UserSalesVolume extends Model
|
||||
{
|
||||
protected $table = 'user_sales_volumes';
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'shopping_order_id' => 'int',
|
||||
'user_invoice_id' => 'int',
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'points' => 'int',
|
||||
'month_points' => 'int',
|
||||
'month_shop_points' => 'int',
|
||||
'total_net' => 'float',
|
||||
'month_total_net' => 'float',
|
||||
'month_shop_total_net' => 'float',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'shopping_order_id',
|
||||
'user_invoice_id',
|
||||
'month',
|
||||
'year',
|
||||
'date',
|
||||
'points',
|
||||
'month_points',
|
||||
'month_shop_points',
|
||||
'total_net',
|
||||
'month_total_net',
|
||||
'month_shop_total_net',
|
||||
'message',
|
||||
'status'
|
||||
];
|
||||
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => 'nicht zugewiesen',
|
||||
1 => 'hinzugefügt aus Bestellung',
|
||||
2 => 'hinzugefügt aus Shop',
|
||||
3 => 'hinzugefügt aus Shop / pending',
|
||||
10 => ''
|
||||
];
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->belongsTo(ShoppingOrder::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function user_invoice()
|
||||
{
|
||||
return $this->belongsTo(UserInvoice::class);
|
||||
}
|
||||
|
||||
public function getDateAttribute(){
|
||||
return $this->attributes['date'] ? Carbon::parse($this->attributes['date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
public function setDateAttribute( $value ) {
|
||||
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getDateRaw(){
|
||||
return isset($this->attributes['date']) ? $this->attributes['date'] : NULL;
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
}
|
||||
|
||||
public static function getStatusByOrder($ShoppingOrder){
|
||||
if($ShoppingOrder->payment_for){
|
||||
if($ShoppingOrder->payment_for === 6){ //Kunde-Shop
|
||||
if($ShoppingOrder->shopping_user && $ShoppingOrder->shopping_user->is_like){
|
||||
return 3; //shop Kunden, berater zuordnen
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getFormatedMonthYear(){
|
||||
return str_pad($this->month, 2, "0", STR_PAD_LEFT)."/".$this->year;
|
||||
}
|
||||
|
||||
public function setToUserAndCalculate($user_id){
|
||||
|
||||
$month = $this->month;
|
||||
$year = $this->year;
|
||||
$month_shop_points = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('points');
|
||||
$month_shop_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('total_net');
|
||||
$month_points = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('points');
|
||||
$month_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('total_net');
|
||||
|
||||
$month_shop_points += $this->points;
|
||||
$month_shop_total_net += $this->total_net;
|
||||
|
||||
$this->user_id = $user_id;
|
||||
$this->month_shop_points = $month_shop_points;
|
||||
$this->month_shop_total_net = $month_shop_total_net;
|
||||
$this->month_points = $month_points;
|
||||
$this->month_total_net = $month_total_net;
|
||||
$this->status = 2;
|
||||
$this->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -65,6 +65,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserShop withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class UserShop extends Model
|
||||
{
|
||||
|
|
@ -83,8 +84,8 @@ class UserShop extends Model
|
|||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
use Sluggable;
|
||||
|
||||
public function sluggable()
|
||||
{
|
||||
return [
|
||||
|
|
@ -93,6 +94,7 @@ class UserShop extends Model
|
|||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'user_id');
|
||||
|
|
@ -135,6 +137,10 @@ class UserShop extends Model
|
|||
|
||||
//check if exisist
|
||||
$subdomain = $kas->action('get_subdomains', $pra);
|
||||
if(is_soap_fault($subdomain)){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!empty($subdomain[0]['is_active']) && $subdomain[0]['is_active'] == 'Y'){
|
||||
$this->is_online = true;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereUserShopId($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserShopOnSite withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
*/
|
||||
class UserShopOnSite extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,8 +92,7 @@ class ContractPDFRepository extends BaseRepository {
|
|||
$pre = $this->model->account->country_id ? $this->convert($this->model->account->country->de)." " : "";
|
||||
$pdf->Write(0, $pre);
|
||||
|
||||
if($this->model->m_sponsor){
|
||||
|
||||
if($this->model->m_sponsor && $this->model->user_sponsor->account){
|
||||
$y += 48;
|
||||
$pdf->SetXY($x1, $y);
|
||||
$pdf->Write(0, $this->convert($this->model->user_sponsor->account->company));
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class FileRepository extends BaseRepository {
|
|||
$originalName = $file->getClientOriginalName();
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
$mine = $file->getClientMimeType();
|
||||
$size = $file->getClientSize();
|
||||
$size = $file->getSize();
|
||||
|
||||
|
||||
$originalNameWithoutExt = substr($originalName, 0, strlen($originalName) - strlen($extension) - 1);
|
||||
|
|
|
|||
197
app/Repositories/InvoiceRepository.php
Normal file
197
app/Repositories/InvoiceRepository.php
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Libraries\InvoicePDF;
|
||||
use PDF;
|
||||
use Storage;
|
||||
use App\Services\Invoice;
|
||||
use App\Models\UserInvoice;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\MyPDFMerger;
|
||||
use App\Models\UserSalesVolume;
|
||||
|
||||
class InvoiceRepository extends BaseRepository {
|
||||
|
||||
private $invoice_date;
|
||||
private $invoice_number;
|
||||
private $filename;
|
||||
private $dir;
|
||||
private $user_sales_volume;
|
||||
|
||||
private $delivery_dir;
|
||||
private $delivery_filename;
|
||||
|
||||
|
||||
public function __construct(ShoppingOrder $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function create($request = [])
|
||||
{
|
||||
//need invoice $data
|
||||
$number = Invoice::getInvoiceNumber();
|
||||
$this->invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $this->model->created_at->format("d.m.Y");
|
||||
$invoice_send_mail = isset($request['invoice_send_mail']) ? false : true;
|
||||
$this->invoice_number = Invoice::createInvoiceNumber($number, $this->invoice_date);
|
||||
$this->dir = Invoice::getInvoiceStorageDir($this->invoice_date);
|
||||
$this->filename = Invoice::makeInvoiceFilename($this->invoice_number);
|
||||
$this->delivery_dir = Invoice::getDeliveryStorageDir($this->invoice_date);
|
||||
$this->delivery_filename = Invoice::makeDeliveryFilename($this->invoice_number);
|
||||
|
||||
$this->makePDF();
|
||||
|
||||
$user_invoice = UserInvoice::create([
|
||||
'shopping_order_id' => $this->model->id,
|
||||
'year' => \Carbon::parse($this->invoice_date)->format('Y'),
|
||||
'month' => \Carbon::parse($this->invoice_date)->format('m'),
|
||||
'date' => $this->invoice_date,
|
||||
'full_number' => $this->invoice_number,
|
||||
'number' => $number,
|
||||
'filename' => $this->filename,
|
||||
'dir' => $this->dir,
|
||||
'delivery_filename' => $this->delivery_filename,
|
||||
'delivery_dir' => $this->delivery_dir,
|
||||
'disk' => 'public',
|
||||
'status' => $this->model->getStatusByOrder()
|
||||
]);
|
||||
Invoice::makeNextInvoiceNumber();
|
||||
if($invoice_send_mail){
|
||||
Invoice::sendInvoiceMail($this->model, $user_invoice);
|
||||
}
|
||||
return $user_invoice;
|
||||
}
|
||||
|
||||
public function update($request = []){
|
||||
if($user_invoice = $this->model->user_invoice){
|
||||
$number = $user_invoice->number;
|
||||
$this->invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $user_invoice->date;
|
||||
$invoice_send_mail = isset($request['invoice_send_mail']) ? false: true;
|
||||
$this->invoice_number = Invoice::createInvoiceNumber($number, $this->invoice_date);
|
||||
$this->dir = Invoice::getInvoiceStorageDir($this->invoice_date);
|
||||
$this->filename = Invoice::makeInvoiceFilename($this->invoice_number);
|
||||
$this->delivery_dir = Invoice::getDeliveryStorageDir($this->invoice_date);
|
||||
$this->delivery_filename = Invoice::makeDeliveryFilename($this->invoice_number);
|
||||
|
||||
$this->user_sales_volume = UserSalesVolume::where('user_invoice_id', $this->model->user_invoice->id)->first();
|
||||
$this->makePDF();
|
||||
|
||||
$user_invoice->fill([
|
||||
'shopping_order_id' => $this->model->id,
|
||||
'year' => \Carbon::parse($this->invoice_date)->format('Y'),
|
||||
'month' => \Carbon::parse($this->invoice_date)->format('m'),
|
||||
'date' => $this->invoice_date,
|
||||
'full_number' => $this->invoice_number,
|
||||
'number' => $number,
|
||||
'filename' => $this->filename,
|
||||
'dir' => $this->dir,
|
||||
'delivery_filename' => $this->delivery_filename,
|
||||
'delivery_dir' => $this->delivery_dir,
|
||||
'disk' => 'public',
|
||||
])->save();
|
||||
|
||||
if($invoice_send_mail){
|
||||
Invoice::sendInvoiceMail($this->model, $user_invoice);
|
||||
}
|
||||
return $user_invoice;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function makePDF(){
|
||||
$data = [
|
||||
'shopping_order' => $this->model,
|
||||
'invoice_date' => $this->invoice_date,
|
||||
'invoice_number' => $this->invoice_number,
|
||||
'user_sales_volume' => $this->user_sales_volume,
|
||||
];
|
||||
|
||||
if(!Storage::disk('public')->exists( $this->dir )){
|
||||
Storage::disk('public')->makeDirectory($this->dir); //creates directory
|
||||
}
|
||||
if(!Storage::disk('public')->exists( $this->delivery_dir )){
|
||||
Storage::disk('public')->makeDirectory($this->delivery_dir); //creates directory
|
||||
}
|
||||
|
||||
$path = Storage::disk('public')->getAdapter()->getPathPrefix();
|
||||
|
||||
//invoice
|
||||
$pdf_file = new InvoicePDF('pdf.invoice');
|
||||
$pdf_file->create($data, $this->filename, 'save', $path.$this->dir);
|
||||
$pdfMerger = new MyPDFMerger();
|
||||
$pdfMerger->addPDF($path.$this->dir.$this->filename);
|
||||
$file = $pdfMerger->myMerge('string', $this->filename, 'template_invoice_de');
|
||||
Storage::disk('public')->put($this->dir.$this->filename, $file);
|
||||
|
||||
$pdf_file = new InvoicePDF('pdf.delivery');
|
||||
$pdf_file->create($data, $this->delivery_filename, 'save', $path.$this->delivery_dir);
|
||||
$pdfMerger = new MyPDFMerger();
|
||||
$pdfMerger->addPDF($path.$this->delivery_dir.$this->delivery_filename);
|
||||
$file = $pdfMerger->myMerge('string', $this->delivery_filename, 'template_invoice_de');
|
||||
Storage::disk('public')->put($this->delivery_dir.$this->delivery_filename, $file);
|
||||
}
|
||||
|
||||
public function userSalesVolume()
|
||||
{
|
||||
|
||||
/*
|
||||
status
|
||||
1 => 'hinzugefügt aus Bestellung',
|
||||
2 => 'hinzugefügt aus Shop',
|
||||
3 => 'hinzugefügt aus Shop / pending',
|
||||
|
||||
*/
|
||||
$status = UserSalesVolume::getStatusByOrder($this->model);
|
||||
$user_id = $this->model->auth_user_id ? $this->model->auth_user_id : $this->model->member_id;
|
||||
$month = date('m');
|
||||
$year = date('Y');
|
||||
|
||||
if($status === 3){ //shop bestellung User pending
|
||||
$user_id = $this->model->auth_user_id ? $this->model->auth_user_id : $this->model->member_id;
|
||||
$month_points = 0;
|
||||
$month_total_net = 0;
|
||||
$month_shop_points = 0;
|
||||
$month_shop_total_net = 0;
|
||||
}else{
|
||||
$month_points = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('points');
|
||||
$month_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('total_net');
|
||||
$month_shop_points = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('points');
|
||||
$month_shop_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('total_net');
|
||||
}
|
||||
switch ($status) {
|
||||
case 1: //Bestellung
|
||||
$month_points += $this->model->points;
|
||||
$month_total_net += $this->model->subtotal;
|
||||
break;
|
||||
case 2: //Shop
|
||||
$month_shop_points += $this->model->points;
|
||||
$month_shop_total_net += $this->model->subtotal;
|
||||
break;
|
||||
}
|
||||
|
||||
return UserSalesVolume::create([
|
||||
'user_id' => $user_id,
|
||||
'shopping_order_id' => $this->model->id,
|
||||
'month' => $month,
|
||||
'year' => $year,
|
||||
'date' => date('d.m.Y'),
|
||||
'points' => $this->model->points,
|
||||
'month_points' => $month_points,
|
||||
'month_shop_points' => $month_shop_points,
|
||||
'total_net' => $this->model->subtotal,
|
||||
'month_total_net' => $month_total_net,
|
||||
'month_shop_total_net' => $month_shop_total_net,
|
||||
'message' => '',
|
||||
'status' => $status,
|
||||
]);
|
||||
}
|
||||
|
||||
public function createAndSalesVolume($request = [])
|
||||
{
|
||||
$this->user_sales_volume = $this->userSalesVolume();
|
||||
$user_invoice = $this->create($request);
|
||||
$this->user_sales_volume->user_invoice_id = $user_invoice->id;
|
||||
$this->user_sales_volume->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ class CustomerPriority
|
|||
if($mail){ //send mail
|
||||
Mail::to(config('app.info_mail'))->send(new MailInfo($shopping_user, 'check_is_like_customer'));
|
||||
}
|
||||
return 'like';
|
||||
return 'like'.$shopping_user->member_id;
|
||||
}
|
||||
if($newCustomer){
|
||||
self::newCustomer($shopping_user);
|
||||
|
|
@ -77,6 +77,11 @@ class CustomerPriority
|
|||
Mail::to($shopping_user->member->email)->send(new MailCheckout($shopping_user->shopping_order->txaction, $shopping_user->shopping_order, $shopping_user->shopping_order->shopping_payments->last(), false, $shopping_user->shopping_order->mode));
|
||||
}
|
||||
}
|
||||
//set Points and Volume
|
||||
if ($shopping_user->shopping_order && $user_sales_volume = $shopping_user->shopping_order->user_sales_volume_no_userid()) {
|
||||
$user_sales_volume->setToUserAndCalculate($shopping_user->member_id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -233,6 +238,7 @@ class CustomerPriority
|
|||
->where('auth_user_id', '=', NULL)
|
||||
->where('number', '!=', NULL) //has number
|
||||
->where('id', '!=', $shopping_user->id)
|
||||
->where('member_id', '!=', $shopping_user->member_id)
|
||||
->where('billing_lastname', '=', $shopping_user->billing_lastname)
|
||||
->where('billing_zipcode', '=', $shopping_user->billing_zipcode)
|
||||
->get()->pluck('number', 'id')->unique()->toArray();
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class HomepartyCart
|
|||
$user_cart->shipping_price = $price;
|
||||
$user_cart->shipping_tax_rate = $shipping_price->tax_rate;
|
||||
$user_cart->shipping_price_net = round($price / ((100+$shipping_price->tax_rate) / 100), 2);
|
||||
$user_cart->shipping_tax = round($price / (100+$shipping_price->tax_rate) * 100, 2);
|
||||
$user_cart->shipping_tax = round($user_cart->shipping_price - $user_cart->shipping_price_net, 2);
|
||||
}
|
||||
|
||||
if($homeparty_user->is_host){
|
||||
|
|
|
|||
66
app/Services/Invoice.php
Normal file
66
app/Services/Invoice.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Mail\MailInvoice;
|
||||
use App\Models\Setting;
|
||||
use App\Models\ShoppingOrder;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class Invoice
|
||||
{
|
||||
|
||||
public static function getInvoiceNumber(){
|
||||
return (int) Setting::getContentBySlug('invoice-number');
|
||||
}
|
||||
|
||||
public static function makeNextInvoiceNumber(){
|
||||
$invoice_number = self::getInvoiceNumber();
|
||||
$invoice_number = $invoice_number+1;
|
||||
Setting::setContentBySlug('invoice-number', $invoice_number, 'int');
|
||||
return $invoice_number;
|
||||
}
|
||||
|
||||
public static function createInvoiceNumber($invoice_number, $invoice_date){
|
||||
$prefix = \Carbon::parse($invoice_date)->format('Y');
|
||||
$invoice_number = str_pad($invoice_number, 5, '0', STR_PAD_LEFT);
|
||||
return $prefix.$invoice_number;
|
||||
}
|
||||
|
||||
public static function getInvoiceStorageDir($invoice_date){
|
||||
return "invoice/".\Carbon::parse($invoice_date)->format('Y/m/');
|
||||
}
|
||||
|
||||
public static function getDeliveryStorageDir($invoice_date){
|
||||
return "delivery/".\Carbon::parse($invoice_date)->format('Y/m/');
|
||||
}
|
||||
|
||||
public static function makeInvoiceFilename($invoice_number){
|
||||
return $invoice_number."-MIVITA-Rechnung.pdf";
|
||||
}
|
||||
|
||||
public static function makeDeliveryFilename($invoice_number){
|
||||
return $invoice_number."-MIVITA-Lieferschein.pdf";
|
||||
}
|
||||
|
||||
public static function isInvoice(ShoppingOrder $shopping_order){
|
||||
return $shopping_order->isInvoice();
|
||||
}
|
||||
|
||||
public static function sendInvoiceMail($shopping_order, $user_invoice){
|
||||
$bcc = [];
|
||||
$billing_email = $shopping_order->shopping_user->billing_email;
|
||||
if(!$billing_email){
|
||||
if($shopping_order->mode === 'test'){
|
||||
$billing_email = config('app.checkout_test_mail');
|
||||
}else{
|
||||
$billing_email = config('app.checkout_mail');
|
||||
}
|
||||
}
|
||||
if($shopping_order->mode === 'test'){
|
||||
$bcc[] = config('app.checkout_test_mail');
|
||||
}else{
|
||||
$bcc[] = config('app.checkout_mail');
|
||||
}
|
||||
Mail::to($billing_email)->bcc($bcc)->send(new MailInvoice($shopping_order, $user_invoice));
|
||||
}
|
||||
}
|
||||
188
app/Services/MyPDFMerger.php
Normal file
188
app/Services/MyPDFMerger.php
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
//use FPDI in myMerge v2
|
||||
//use FPDF;
|
||||
//use FPDI;
|
||||
|
||||
class MyPDFMerger
|
||||
{
|
||||
private $_files; //['form.pdf'] ["1,2,4, 5-19"]
|
||||
private $_fpdi;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
/* if(!class_exists("FPDF")) {
|
||||
require_once(__DIR__.'/fpdf/fpdf.php');
|
||||
}
|
||||
if(!class_exists("FPDI")) {
|
||||
require_once(__DIR__.'/fpdi/fpdi.php');
|
||||
}*/
|
||||
}
|
||||
|
||||
public function addPDF($filepath, $pages = 'all')
|
||||
{
|
||||
if (file_exists($filepath)) {
|
||||
if (strtolower($pages) != 'all') {
|
||||
$pages = $this->_rewritepages($pages);
|
||||
}
|
||||
|
||||
$this->_files[] = array($filepath, $pages);
|
||||
} else {
|
||||
throw new \exception("Could not locate PDF on '$filepath'");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function myMerge($outputmode = 'browser', $outputpath = 'newfile.pdf', $theme = false)
|
||||
{
|
||||
if (!isset($this->_files) || !is_array($this->_files)): throw new \exception("No PDFs to merge."); endif;
|
||||
|
||||
$fpdi = new \setasign\Fpdi\Fpdi();
|
||||
$first = 1;
|
||||
|
||||
//
|
||||
//merger operations
|
||||
foreach ($this->_files as $file) {
|
||||
$filename = $file[0];
|
||||
$filepages = $file[1];
|
||||
|
||||
|
||||
$count = $fpdi->setSourceFile($filename);
|
||||
|
||||
//add the pages
|
||||
if ($filepages == 'all') {
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$count = $fpdi->setSourceFile($filename);
|
||||
$template = $fpdi->importPage($i);
|
||||
$size = $fpdi->getTemplateSize($template);
|
||||
$orientation = ($size['height'] > $size['width']) ? 'P' : 'L';
|
||||
|
||||
$fpdi->AddPage($orientation, array($size['width'], $size['height']));
|
||||
if($theme){
|
||||
$fpdi->setSourceFile('pdf/'.$theme.'-'.$first.'.pdf');
|
||||
if($first == 1){
|
||||
$first = 2;
|
||||
}
|
||||
$backId = $fpdi->importPage(1);
|
||||
$fpdi->useTemplate($backId);
|
||||
|
||||
}
|
||||
$fpdi->useTemplate($template);
|
||||
}
|
||||
} else {
|
||||
foreach ($filepages as $page) {
|
||||
$count = $fpdi->setSourceFile($filename);
|
||||
if (!$template = $fpdi->importPage($page)): throw new \exception("Could not load page '$page' in PDF '$filename'. Check that the page exists."); endif;
|
||||
$size = $fpdi->getTemplateSize($template);
|
||||
$orientation = ($size['h'] > $size['w']) ? 'P' : 'L';
|
||||
|
||||
$fpdi->AddPage($orientation, array($size['w'], $size['h']));
|
||||
if($theme){
|
||||
$fpdi->setSourceFile('pdf/'.$theme.'-'.$first.'.pdf');
|
||||
if($first == 1){
|
||||
$first = 2;
|
||||
}
|
||||
$backId = $fpdi->importPage(1);
|
||||
$fpdi->useTemplate($backId);
|
||||
}
|
||||
|
||||
$fpdi->useTemplate($template);
|
||||
}
|
||||
}
|
||||
//after first file (invoice) on bpaper
|
||||
$slug = false;
|
||||
}
|
||||
|
||||
//output operations
|
||||
$mode = $this->_switchmode($outputmode);
|
||||
|
||||
if ($mode == 'S') {
|
||||
return $fpdi->Output($outputpath, 'S');
|
||||
} else {
|
||||
if ($fpdi->Output($outputpath, $mode) == '') {
|
||||
return true;
|
||||
} else {
|
||||
throw new \exception("Error outputting PDF to '$outputmode'.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* FPDI uses single characters for specifying the output location. Change our more descriptive string into proper format.
|
||||
* @param $mode
|
||||
* @return Character
|
||||
*/
|
||||
private function _switchmode($mode)
|
||||
{
|
||||
switch (strtolower($mode)) {
|
||||
case 'download':
|
||||
return 'D';
|
||||
break;
|
||||
case 'browser':
|
||||
return 'I';
|
||||
break;
|
||||
case 'file':
|
||||
return 'F';
|
||||
break;
|
||||
case 'string':
|
||||
return 'S';
|
||||
break;
|
||||
default:
|
||||
return 'I';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes our provided pages in the form of 1,3,4,16-50 and creates an array of all pages
|
||||
* @param $pages
|
||||
* @return array
|
||||
* @throws exception
|
||||
*/
|
||||
private function _rewritepages($pages)
|
||||
{
|
||||
$pages = str_replace(' ', '', $pages);
|
||||
$part = explode(',', $pages);
|
||||
|
||||
//parse hyphens
|
||||
foreach ($part as $i) {
|
||||
$ind = explode('-', $i);
|
||||
|
||||
if (count($ind) == 2) {
|
||||
$x = $ind[0]; //start page
|
||||
$y = $ind[1]; //end page
|
||||
|
||||
if ($x > $y): throw new \exception("Starting page, '$x' is greater than ending page '$y'.");
|
||||
return false; endif;
|
||||
|
||||
//add middle pages
|
||||
while ($x <= $y): $newpages[] = (int)$x;
|
||||
$x++; endwhile;
|
||||
} else {
|
||||
$newpages[] = (int)$ind[0];
|
||||
}
|
||||
}
|
||||
|
||||
return $newpages;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
$pdf = new PDFMerger;
|
||||
|
||||
$pdf->addPDF('samplepdfs/one.pdf', '1, 3, 4')
|
||||
->addPDF('samplepdfs/two.pdf', '1-2')
|
||||
->addPDF('samplepdfs/three.pdf', 'all')
|
||||
->merge('file', 'samplepdfs/TEST2.pdf');
|
||||
|
||||
//REPLACE 'file' WITH 'browser', 'download', 'string', or 'file' for output options
|
||||
//You do not need to give a file path for browser, string, or download - just the name.
|
||||
*/
|
||||
|
|
@ -2,11 +2,12 @@
|
|||
namespace App\Services;
|
||||
|
||||
|
||||
use App\User;
|
||||
use App\Mail\MailCheckout;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
|
||||
class Payment
|
||||
{
|
||||
|
|
@ -16,15 +17,15 @@ class Payment
|
|||
'appointed' => "offen",
|
||||
'failed' => "abbruch",
|
||||
'extern' => "extern",
|
||||
'invoice_open' => "Re. offen",
|
||||
'invoice_paid' => "Re. bezahlt",
|
||||
'invoice_open' => "offen",
|
||||
'invoice_paid' => "bezahlt",
|
||||
'invoice_non' => "keine Zahlung",
|
||||
'NULL' => 'keine Zahlung',
|
||||
];
|
||||
|
||||
public static $txaction_invoice = [
|
||||
'invoice_open' => "Re. offen",
|
||||
'invoice_paid' => "Re. bezahlt",
|
||||
'invoice_open' => "Rechnung offen",
|
||||
'invoice_paid' => "Rechnung bezahlt",
|
||||
'invoice_non' => 'keine Zahlung',
|
||||
];
|
||||
|
||||
|
|
@ -70,6 +71,11 @@ class Payment
|
|||
return '<span class="badge badge-pill badge-'.self::getFormattedTxactionColor($shopping_payment->txaction).'">'.self::getFormattedTxaction($shopping_payment->txaction).'</span>';
|
||||
}
|
||||
|
||||
/*
|
||||
Wir bei Zahlung aufgerufen.
|
||||
Betätigung durch Payone oder Zahlung auf MIVITA Rechnung
|
||||
$paid = Status der Zahlung, Payone = true, MIVITA Rechnung = false
|
||||
*/
|
||||
|
||||
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){
|
||||
$send_link = false;
|
||||
|
|
@ -128,6 +134,12 @@ class Payment
|
|||
$shopping_order->homeparty->completed = 1;
|
||||
$shopping_order->homeparty->save();
|
||||
}
|
||||
//make Invoice and
|
||||
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if(!$shopping_order->isInvoice()){
|
||||
$invoice_repo->createAndSalesVolume();
|
||||
}
|
||||
return $send_link;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class PaymentHelper
|
|||
|
||||
public function setProduct($product){
|
||||
Yard::instance('shopping')->destroy();
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, ['image' => "", 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, false, false, ['image' => "", 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points]);
|
||||
}
|
||||
|
||||
public function initELVPayment($user){
|
||||
|
|
@ -122,7 +122,7 @@ class PaymentHelper
|
|||
'auth_user_id' => $shopping_user->auth_user_id,
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'user_shop_id' => 1,
|
||||
'payment_for' => Util::getUserPaymentFor(),
|
||||
'payment_for' => $shopping_user->getOrderPaymentFor(),
|
||||
'total' => Yard::instance('shopping')->total(2, '.', ''),
|
||||
'subtotal' => Yard::instance('shopping')->subtotal(2, '.', ''),
|
||||
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
|
||||
|
|
@ -140,6 +140,8 @@ class PaymentHelper
|
|||
$items = Yard::instance('shopping')->getContentByOrder();
|
||||
foreach ($items as $item) {
|
||||
if (!ShoppingOrderItem::where('shopping_order_id', $shopping_order->id)->where('row_id', $item->rowId)->count()){
|
||||
$price_net = Yard::instance('shopping')->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
$data = [
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
|
|
@ -147,13 +149,18 @@ class PaymentHelper
|
|||
'comp' => $item->options->comp,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => Yard::instance('shopping')->rowPriceNet($item, 3, '.', ''),
|
||||
'price_net' => $price_net,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'tax' => $tax,
|
||||
'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id),
|
||||
'discount' => $shopping_order->getUserDiscount(),
|
||||
'points' => $item->options->points,
|
||||
'slug' => $item->options->slug
|
||||
];
|
||||
$shopping_order_item = ShoppingOrderItem::create($data);
|
||||
}
|
||||
}
|
||||
$shopping_order->makeTaxSplit();
|
||||
return $shopping_order;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,10 +10,8 @@ use App\Models\ShippingCountry;
|
|||
class Util
|
||||
{
|
||||
|
||||
|
||||
|
||||
private static $postRoute = 'base.';
|
||||
|
||||
|
||||
public static function getToken()
|
||||
{
|
||||
return hash_hmac('sha256', str_random(40), config('app.key'));
|
||||
|
|
@ -57,15 +55,30 @@ class Util
|
|||
|
||||
}
|
||||
|
||||
public static function _thousands_separator(){
|
||||
return \App::getLocale() === "en" ? ',' : '.';
|
||||
}
|
||||
|
||||
public static function _decimal_separator(){
|
||||
return \App::getLocale() === "en" ? '.' : ',';
|
||||
}
|
||||
|
||||
|
||||
public static function reFormatNumber($value){
|
||||
return (float) str_replace(',', '.', self::_format_number($value));
|
||||
}
|
||||
|
||||
public static function formatNumber($value, $dec=2){
|
||||
if(\App::getLocale() === "en"){
|
||||
return number_format($value, $dec, '.', ',');
|
||||
return number_format($value, $dec, self::_decimal_separator(), self::_thousands_separator());
|
||||
|
||||
}
|
||||
|
||||
public static function cleanNumberFormat($num = 0, $dec = 2, $fullzero = false){
|
||||
|
||||
if($fullzero && $num == 0){
|
||||
return number_format($num, $dec, self::_decimal_separator(), self::_thousands_separator());
|
||||
}
|
||||
return number_format($value, $dec, ',', '.');
|
||||
return rtrim(rtrim(number_format($num, $dec, self::_decimal_separator(), self::_thousands_separator()),'0'), self::_decimal_separator());
|
||||
}
|
||||
|
||||
public static function utf8ize( $mixed ) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ use Illuminate\Session\SessionManager;
|
|||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Gloudemans\Shoppingcart\Contracts\Buyable;
|
||||
|
||||
|
||||
class Yard extends Cart
|
||||
{
|
||||
private $shipping_price = 0;
|
||||
|
|
@ -27,6 +26,8 @@ class Yard extends Cart
|
|||
private $user_country_id;
|
||||
private $user_country;
|
||||
private $shopping_data = [];
|
||||
private $events;
|
||||
|
||||
|
||||
public function __construct(SessionManager $session, Dispatcher $events)
|
||||
{
|
||||
|
|
@ -71,6 +72,8 @@ class Yard extends Cart
|
|||
$this->user_country = $this->getYardExtra('user_country');
|
||||
}
|
||||
|
||||
$this->events = $events;
|
||||
|
||||
|
||||
parent::__construct($session, $events);
|
||||
|
||||
|
|
@ -90,7 +93,7 @@ class Yard extends Cart
|
|||
{
|
||||
return config('cart.tax');
|
||||
}
|
||||
|
||||
|
||||
public function putYardExtra($key, $value){
|
||||
|
||||
$content = $this->getYContent();
|
||||
|
|
@ -363,7 +366,7 @@ class Yard extends Cart
|
|||
* @param string $thousandSeperator
|
||||
* @return string
|
||||
*/
|
||||
public function total($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
public function total($decimals = NULL, $decimalPoint = NULL, $thousandSeperator = NULL, $withFees = true)
|
||||
{
|
||||
$content = $this->getContent();
|
||||
$total = $content->reduce(function ($total, CartItem $cartItem) {
|
||||
|
|
@ -381,7 +384,7 @@ class Yard extends Cart
|
|||
* @param string $thousandSeperator
|
||||
* @return float
|
||||
*/
|
||||
public function tax($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
public function tax($decimals = NULL, $decimalPoint = NULL, $thousandSeperator = NULL, $withFees = true)
|
||||
{
|
||||
$content = $this->getContent();
|
||||
|
||||
|
|
@ -584,4 +587,40 @@ class Yard extends Cart
|
|||
|
||||
return number_format($value, $decimals, $decimalPoint, $thousandSeperator);
|
||||
}
|
||||
|
||||
|
||||
public function myStore($identifier, array $eventOptions = [])
|
||||
{
|
||||
|
||||
// Remove any existing identifiers
|
||||
// Although possibly first or update could work in future
|
||||
$this
|
||||
->getConnection()
|
||||
->table($this->getTableName())
|
||||
->where('identifier', $identifier)
|
||||
->delete();
|
||||
|
||||
// Insert into the database with the new cart
|
||||
$content = $this->getContent();
|
||||
$this->getConnection()->table($this->getTableName())->insert([
|
||||
'identifier' => $identifier,
|
||||
'instance' => $this->currentInstance(),
|
||||
'content' => serialize($content)
|
||||
]);
|
||||
$eventOptions = array_merge([
|
||||
'cartInstance' => $this->currentInstance(),
|
||||
], $eventOptions);
|
||||
|
||||
$this->events->dispatch('cart.stored', $eventOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the cart with the given identifier.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @return void
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -68,4 +68,12 @@ if (! function_exists('reFormatNumber')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (! function_exists('cleanNumberFormat')) {
|
||||
function cleanNumberFormat($number)
|
||||
{
|
||||
return !$number ? $number : Util::cleanNumberFormat($number);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue