Gutschriften manuell hinzufügen, Yard 0& tax
This commit is contained in:
parent
e670b92f5d
commit
c02fffd883
24 changed files with 497 additions and 68 deletions
|
|
@ -43,7 +43,6 @@ class MembershipController extends Controller
|
||||||
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_order')->get()->last();
|
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_order')->get()->last();
|
||||||
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->get()->last();
|
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->get()->last();
|
||||||
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
|
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
|
'products' => Product::where('active', true)->where('show_at', '=', 3)->orderBy('pos', 'ASC')->get(),
|
||||||
|
|
@ -100,8 +99,8 @@ class MembershipController extends Controller
|
||||||
$image = $product->images->first()->slug;
|
$image = $product->images->first()->slug;
|
||||||
}
|
}
|
||||||
$qty = Request::get('qty') ? Request::get('qty') : 1;
|
$qty = Request::get('qty') ? Request::get('qty') : 1;
|
||||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, $product->tax, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||||
|
Yard::instance('shopping')->setGlobalTaxRate(0);
|
||||||
/*
|
/*
|
||||||
do {
|
do {
|
||||||
$identifier = Util::getToken();
|
$identifier = Util::getToken();
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,10 @@ class ModalController extends Controller
|
||||||
$value = [];
|
$value = [];
|
||||||
$ret = view("admin.modal.add_pay_credit", compact('value', 'data'))->render();
|
$ret = view("admin.modal.add_pay_credit", compact('value', 'data'))->render();
|
||||||
}
|
}
|
||||||
|
if($data['action'] === 'add-user-credit'){
|
||||||
|
$value = [];
|
||||||
|
$ret = view("admin.modal.add_credit", compact('value', 'data'))->render();
|
||||||
|
}
|
||||||
|
|
||||||
if($data['action'] === 'user-credit-status'){
|
if($data['action'] === 'user-credit-status'){
|
||||||
$value = UserCredit::find($data['id']); //current user form order
|
$value = UserCredit::find($data['id']); //current user form order
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,19 @@
|
||||||
|
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Models\UserCreditMargin as ModelsUserCreditMargin;
|
||||||
use Carbon;
|
use Carbon;
|
||||||
use Request;
|
use Request;
|
||||||
use App\User;
|
use App\User;
|
||||||
|
use App\Services\Util;
|
||||||
use App\Services\Credit;
|
use App\Services\Credit;
|
||||||
|
use App\Services\Payment;
|
||||||
use App\Models\UserCredit;
|
use App\Models\UserCredit;
|
||||||
use App\Models\ShoppingOrderMargin;
|
use App\Models\ShoppingOrderMargin;
|
||||||
|
use App\Models\UserCreditMargin;
|
||||||
use App\Repositories\CreditRepository;
|
use App\Repositories\CreditRepository;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class PaymentCreditController extends Controller
|
class PaymentCreditController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -30,39 +36,40 @@ class PaymentCreditController extends Controller
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->setActiveYears();
|
$data = $this->makeData();
|
||||||
$date1 = Carbon::parse('01.01.'.$this->activeYear." 00:00:00")->format('Y-m-d H:i:s');
|
return view('admin.payment.credit.index', $data);
|
||||||
$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();
|
|
||||||
|
|
||||||
|
|
||||||
$data = [
|
public function store(){
|
||||||
'years' => $this->rangeYears,
|
$data = Request::all();
|
||||||
'active_year' => $this->activeYear,
|
|
||||||
'ShoppingOrderMargins' => $ShoppingOrderMargins,
|
if(isset($data['action']) && $data['action'] === 'add-user-credit'){
|
||||||
'ShoppingOrderMarginPendings' => $ShoppingOrderMarginPendings,
|
$add_credit_error = false;
|
||||||
];
|
if(!isset($data['member_id']) || !$user = User::find($data['member_id'])){
|
||||||
return view('admin.payment.credit.index', $data);
|
$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(){
|
public function create(){
|
||||||
|
|
@ -86,8 +93,67 @@ class PaymentCreditController extends Controller
|
||||||
return back();
|
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(){
|
private function setActiveYears(){
|
||||||
|
|
@ -96,6 +162,20 @@ class PaymentCreditController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(){
|
public function datatable(){
|
||||||
|
|
||||||
$this->setActiveYears();
|
$this->setActiveYears();
|
||||||
|
|
@ -121,6 +201,12 @@ class PaymentCreditController extends Controller
|
||||||
$ret .= $user_margin->firstname."/".$user_margin->lastname."/".$user_margin->reference."/".$user_margin->created_at."<br>";
|
$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;
|
return $ret;
|
||||||
})
|
})
|
||||||
/* ->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
|
/* ->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ namespace App\Http\Controllers;
|
||||||
use Carbon;
|
use Carbon;
|
||||||
use Request;
|
use Request;
|
||||||
use App\User;
|
use App\User;
|
||||||
use Validator;
|
|
||||||
use App\Services\Util;
|
use App\Services\Util;
|
||||||
use App\Models\UserPayCredit;
|
use App\Models\UserPayCredit;
|
||||||
use App\Services\Payment;
|
use App\Services\Payment;
|
||||||
|
|
@ -43,7 +42,6 @@ class PaymentPayCreditController extends Controller
|
||||||
|
|
||||||
if(isset($data['action']) && $data['action'] === 'add-user-pay-credit'){
|
if(isset($data['action']) && $data['action'] === 'add-user-pay-credit'){
|
||||||
|
|
||||||
$validator = Validator::make(Request::all(), []);
|
|
||||||
$add_credit_error = false;
|
$add_credit_error = false;
|
||||||
if(!isset($data['member_id']) || !$user = User::find($data['member_id'])){
|
if(!isset($data['member_id']) || !$user = User::find($data['member_id'])){
|
||||||
$add_credit_error = 'Vertriebspartner nicht gefunden';
|
$add_credit_error = 'Vertriebspartner nicht gefunden';
|
||||||
|
|
@ -67,7 +65,7 @@ class PaymentPayCreditController extends Controller
|
||||||
$credit = number_format($credit, 2, '.', '');
|
$credit = number_format($credit, 2, '.', '');
|
||||||
|
|
||||||
Payment::addUserPayCredits($user, $credit, 3, $data['message']);
|
Payment::addUserPayCredits($user, $credit, 3, $data['message']);
|
||||||
\Session()->flash('alert-success', "Guthaben aufgeladen");
|
\Session()->flash('alert-success', "Einkaufsguthaben aufgeladen");
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(route('admin_payments_paycredit'));
|
return redirect(route('admin_payments_paycredit'));
|
||||||
|
|
@ -87,7 +85,6 @@ class PaymentPayCreditController extends Controller
|
||||||
}else{
|
}else{
|
||||||
\Session()->flash('alert-error', "Guthaben kann nicht gelöscht werden");
|
\Session()->flash('alert-error', "Guthaben kann nicht gelöscht werden");
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(route('admin_payments_paycredit'));
|
return redirect(route('admin_payments_paycredit'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -295,19 +295,18 @@ class CheckoutController extends Controller
|
||||||
$pay->setPersonalData();
|
$pay->setPersonalData();
|
||||||
return $pay->ResponseData($identifier);
|
return $pay->ResponseData($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function final($transactionId, $reference, $identifier) {
|
public function final($transactionId, $reference, $identifier) {
|
||||||
|
|
||||||
$payt = PaymentTransaction::findOrFail($transactionId);
|
$payt = PaymentTransaction::findOrFail($transactionId);
|
||||||
if($payt->shopping_payment->reference != $reference){
|
if($payt->shopping_payment->reference != $reference){
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Yard::instance('shopping')->destroy();
|
Yard::instance('shopping')->destroy();
|
||||||
$this->destroy();
|
$this->destroy();
|
||||||
|
|
||||||
|
|
@ -552,8 +551,9 @@ class CheckoutController extends Controller
|
||||||
|
|
||||||
$shopping_order->txaction = 'open';
|
$shopping_order->txaction = 'open';
|
||||||
$shopping_order->save();
|
$shopping_order->save();
|
||||||
|
|
||||||
if($shopping_payment){
|
if($shopping_payment){
|
||||||
|
|
||||||
if($payt->status === 'vor'){
|
if($payt->status === 'vor'){
|
||||||
$shopping_payment->txaction = 'open';
|
$shopping_payment->txaction = 'open';
|
||||||
$shopping_order->txaction = 'open';
|
$shopping_order->txaction = 'open';
|
||||||
|
|
@ -563,7 +563,7 @@ class CheckoutController extends Controller
|
||||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||||
$shopping_payment->txaction = 'open';
|
$shopping_payment->txaction = 'open';
|
||||||
$shopping_order->txaction = 'open';
|
$shopping_order->txaction = 'open';
|
||||||
}
|
}
|
||||||
$shopping_payment->save();
|
$shopping_payment->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -576,6 +576,7 @@ class CheckoutController extends Controller
|
||||||
];
|
];
|
||||||
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
|
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ class Product extends Model
|
||||||
}
|
}
|
||||||
public function setTaxAttribute( $value ) {
|
public function setTaxAttribute( $value ) {
|
||||||
|
|
||||||
$this->attributes['tax'] = $value ? Util::reFormatNumber($value) : null;
|
$this->attributes['tax'] = $value != "" ? Util::reFormatNumber($value) : null;
|
||||||
}
|
}
|
||||||
public function setPriceOldAttribute( $value ) {
|
public function setPriceOldAttribute( $value ) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
* @property \Illuminate\Support\Carbon|null $shipped_at
|
* @property \Illuminate\Support\Carbon|null $shipped_at
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereInvoice($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereInvoice($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereShippedAt($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereShippedAt($value)
|
||||||
|
* @property string|null $invoice_number
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereInvoiceNumber($value)
|
||||||
*/
|
*/
|
||||||
class ShoppingOrder extends Model
|
class ShoppingOrder extends Model
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @property-read User|null $m_sponsor
|
* @property-read User|null $m_sponsor
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPaid($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPaid($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPendingTo($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin wherePartnerCommissionPendingTo($value)
|
||||||
|
* @property int|null $user_credit_id
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderMargin whereUserCreditId($value)
|
||||||
*/
|
*/
|
||||||
class ShoppingOrderMargin extends Model
|
class ShoppingOrderMargin extends Model
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUpdatedAt($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUpdatedAt($value)
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUserMargins($value)
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereUserMargins($value)
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
|
* @property string|null $credit_number
|
||||||
|
* @property string|null $date
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereCreditNumber($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCredit whereDate($value)
|
||||||
*/
|
*/
|
||||||
class UserCredit extends Model
|
class UserCredit extends Model
|
||||||
{
|
{
|
||||||
|
|
@ -60,7 +64,8 @@ class UserCredit extends Model
|
||||||
'cancellation' => 'bool',
|
'cancellation' => 'bool',
|
||||||
'status' => 'int',
|
'status' => 'int',
|
||||||
'credit' => 'array',
|
'credit' => 'array',
|
||||||
'user_margins' => 'object'
|
'user_margins' => 'object',
|
||||||
|
'user_credits' => 'object'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
|
@ -73,6 +78,7 @@ class UserCredit extends Model
|
||||||
'date',
|
'date',
|
||||||
'credit',
|
'credit',
|
||||||
'user_margins',
|
'user_margins',
|
||||||
|
'user_credits',
|
||||||
'paid_out',
|
'paid_out',
|
||||||
'cancellation',
|
'cancellation',
|
||||||
'status'
|
'status'
|
||||||
|
|
|
||||||
76
app/Models/UserCreditMargin.php
Normal file
76
app/Models/UserCreditMargin.php
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Reliese Model.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class UserCreditMargin
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property int $user_id
|
||||||
|
* @property float|null $credit
|
||||||
|
* @property string|null $message
|
||||||
|
* @property int $status
|
||||||
|
* @property Carbon|null $created_at
|
||||||
|
* @property Carbon|null $updated_at
|
||||||
|
* @property User $user
|
||||||
|
* @package App\Models
|
||||||
|
* @property bool|null $paid
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereCredit($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereMessage($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin wherePaid($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereStatus($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditMargin whereUserId($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class UserCreditMargin extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
public $statusType = [
|
||||||
|
1 => 'manually added margin',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $table = 'user_credit_margins';
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'user_id' => 'int',
|
||||||
|
'credit' => 'float',
|
||||||
|
'status' => 'int',
|
||||||
|
'paid' => 'bool',
|
||||||
|
'user_credit_id' => 'int',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'credit',
|
||||||
|
'message',
|
||||||
|
'status',
|
||||||
|
'paid',
|
||||||
|
'user_credit_id',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('App\User','user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteTime(){
|
||||||
|
$time = '+100 min';
|
||||||
|
if(Carbon::parse($this->created_at)->modify($time)->gt(Carbon::now())){
|
||||||
|
return Carbon::now()->diffInMinutes(Carbon::parse($this->created_at)->modify($time));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class UserPayCredit
|
* Class UserPayCredit
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property int $user_id
|
* @property int $user_id
|
||||||
* @property float|null $credit
|
* @property float|null $credit
|
||||||
|
|
@ -22,11 +22,23 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
* @property int|null $shopping_order_id
|
* @property int|null $shopping_order_id
|
||||||
* @property Carbon|null $created_at
|
* @property Carbon|null $created_at
|
||||||
* @property Carbon|null $updated_at
|
* @property Carbon|null $updated_at
|
||||||
*
|
|
||||||
* @property ShoppingOrder|null $shopping_order
|
* @property ShoppingOrder|null $shopping_order
|
||||||
* @property User $user
|
* @property User $user
|
||||||
*
|
|
||||||
* @package App\Models
|
* @package App\Models
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit newModelQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit newQuery()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit query()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereCreatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereCredit($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereMessage($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereNewCreditTotal($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereOldCreditTotal($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereShoppingOrderId($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereStatus($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereUpdatedAt($value)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereUserId($value)
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class UserPayCredit extends Model
|
class UserPayCredit extends Model
|
||||||
{
|
{
|
||||||
|
|
@ -34,6 +46,8 @@ class UserPayCredit extends Model
|
||||||
public $statusType = [
|
public $statusType = [
|
||||||
1 => 'add from payment',
|
1 => 'add from payment',
|
||||||
2 => 'deduction from payment',
|
2 => 'deduction from payment',
|
||||||
|
3 => 'manually added credit',
|
||||||
|
|
||||||
];
|
];
|
||||||
protected $table = 'user_pay_credits';
|
protected $table = 'user_pay_credits';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ class CreditRepository extends BaseRepository {
|
||||||
'date' => $credit_date,
|
'date' => $credit_date,
|
||||||
'credit' => $credit_file,
|
'credit' => $credit_file,
|
||||||
'user_margins' => $user_credits->margins,
|
'user_margins' => $user_credits->margins,
|
||||||
|
'user_credits' => $user_credits->credits,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -91,15 +92,21 @@ class CreditRepository extends BaseRepository {
|
||||||
$ShoppingOrderMargin->partner_commission_paid = true;
|
$ShoppingOrderMargin->partner_commission_paid = true;
|
||||||
$ShoppingOrderMargin->user_credit_id = $user_credit->id;
|
$ShoppingOrderMargin->user_credit_id = $user_credit->id;
|
||||||
$ShoppingOrderMargin->save();
|
$ShoppingOrderMargin->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$UserCreditMargins = UserMarign::getUserCreditMarginByID($this->model->id);
|
||||||
|
foreach($UserCreditMargins as $UserCreditMargin){
|
||||||
|
$UserCreditMargin->paid = true;
|
||||||
|
$UserCreditMargin->user_credit_id = $user_credit->id;
|
||||||
|
$UserCreditMargin->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private function makeUserCredit(){
|
private function makeUserCredit(){
|
||||||
|
|
||||||
$ret = new \stdClass();
|
$ret = new \stdClass();
|
||||||
$ret->net = 0;
|
$ret->net = 0;
|
||||||
|
$ret->margins = [];
|
||||||
|
$ret->credits = [];
|
||||||
$ShoppingOrderMargins = UserMarign::getOrderFromPartnerCommissionByID($this->model->id);
|
$ShoppingOrderMargins = UserMarign::getOrderFromPartnerCommissionByID($this->model->id);
|
||||||
foreach($ShoppingOrderMargins as $ShoppingOrderMargin){
|
foreach($ShoppingOrderMargins as $ShoppingOrderMargin){
|
||||||
$margin = new \stdClass();
|
$margin = new \stdClass();
|
||||||
|
|
@ -112,12 +119,24 @@ class CreditRepository extends BaseRepository {
|
||||||
$ret->margins[] = $margin;
|
$ret->margins[] = $margin;
|
||||||
$ret->net += $ShoppingOrderMargin->net_partner_commission;
|
$ret->net += $ShoppingOrderMargin->net_partner_commission;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$UserCreditMargins = UserMarign::getUserCreditMarginByID($this->model->id);
|
||||||
|
foreach($UserCreditMargins as $UserCreditMargin){
|
||||||
|
$credit = new \stdClass();
|
||||||
|
$credit->id = $UserCreditMargin->id;
|
||||||
|
$credit->net = $UserCreditMargin->credit;
|
||||||
|
$credit->message = $UserCreditMargin->message;
|
||||||
|
$credit->created_at = $UserCreditMargin->created_at->format("d.m.Y");
|
||||||
|
$ret->credits[] = $credit;
|
||||||
|
$ret->net += $UserCreditMargin->credit;
|
||||||
|
}
|
||||||
|
|
||||||
/* taxable_sales //user tax
|
/* taxable_sales //user tax
|
||||||
1 //umsatzsteuerpflichtig
|
1 //umsatzsteuerpflichtig
|
||||||
2 // nicht umsatzsteuerpflichtig
|
2 // nicht umsatzsteuerpflichtig
|
||||||
*/
|
*/
|
||||||
if($this->model->account){
|
if($this->model->account){
|
||||||
$ret->taxable = $this->model->account->taxable_sales == 2 ? false : false;
|
$ret->taxable = $this->model->account->taxable_sales == 2 ? false : true;
|
||||||
if($ret->taxable){
|
if($ret->taxable){
|
||||||
$ret->tax_rate = config('app.main_tax_number');
|
$ret->tax_rate = config('app.main_tax_number');
|
||||||
$ret->total = round($ret->net * config('app.main_tax'), 2);
|
$ret->total = round($ret->net * config('app.main_tax'), 2);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ class ProductRepository extends BaseRepository {
|
||||||
$data['active'] = isset($data['active']) ? 1 : 0;
|
$data['active'] = isset($data['active']) ? 1 : 0;
|
||||||
$data['single_commission'] = isset($data['single_commission']) ? 1 : 0;
|
$data['single_commission'] = isset($data['single_commission']) ? 1 : 0;
|
||||||
$data['amount_commission'] = isset($data['amount_commission']) ? 1 : 0;
|
$data['amount_commission'] = isset($data['amount_commission']) ? 1 : 0;
|
||||||
|
|
||||||
if($data['id'] === "new"){
|
if($data['id'] === "new"){
|
||||||
$this->model = Product::create($data);
|
$this->model = Product::create($data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use App\Mail\MailCheckout;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\ShoppingOrder;
|
use App\Models\ShoppingOrder;
|
||||||
use App\Models\ShoppingPayment;
|
use App\Models\ShoppingPayment;
|
||||||
|
use App\Models\UserCreditMargin;
|
||||||
use App\Models\UserPayCredit;
|
use App\Models\UserPayCredit;
|
||||||
use App\User;
|
use App\User;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
@ -93,7 +94,6 @@ class Payment
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addUserPayCredits(User $user, $credit, $status, $message, $shopping_order_id = null){
|
public static function addUserPayCredits(User $user, $credit, $status, $message, $shopping_order_id = null){
|
||||||
|
|
||||||
UserPayCredit::create([
|
UserPayCredit::create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'credit' => $credit,
|
'credit' => $credit,
|
||||||
|
|
@ -105,7 +105,16 @@ class Payment
|
||||||
]);
|
]);
|
||||||
$user->payment_credit = $user->payment_credit + $credit;
|
$user->payment_credit = $user->payment_credit + $credit;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function addUserCreditMargin(User $user, $credit, $status, $message){
|
||||||
|
UserCreditMargin::create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'credit' => $credit,
|
||||||
|
'message' => $message,
|
||||||
|
'status' => $status,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){
|
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){
|
||||||
|
|
@ -121,7 +130,6 @@ class Payment
|
||||||
foreach($shopping_order->shopping_order_items as $shopping_order_item){
|
foreach($shopping_order->shopping_order_items as $shopping_order_item){
|
||||||
if($shopping_order_item->product){
|
if($shopping_order_item->product){
|
||||||
if($shopping_order_item->product->action){
|
if($shopping_order_item->product->action){
|
||||||
|
|
||||||
$user = User::findOrFail($shopping_order->auth_user_id);
|
$user = User::findOrFail($shopping_order->auth_user_id);
|
||||||
$user->save();
|
$user->save();
|
||||||
$send_link = true;
|
$send_link = true;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ namespace App\Services;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\ShoppingOrderMargin;
|
use App\Models\ShoppingOrderMargin;
|
||||||
|
use App\Models\UserCreditMargin;
|
||||||
use App\User;
|
use App\User;
|
||||||
use Carbon;
|
use Carbon;
|
||||||
|
|
||||||
|
|
@ -101,11 +102,10 @@ class UserMarign
|
||||||
if($format){
|
if($format){
|
||||||
$sum_net_amount = Util::formatNumber($sum_net_amount);
|
$sum_net_amount = Util::formatNumber($sum_net_amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sum_net_amount;
|
return $sum_net_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getMontlyPartnerCommissionOpenByID($user_id, $date = null, $format = false){
|
public static function getMontlyPartnerCommissionOpenByID($user_id, $date = null, $format = false, $addUserCreditMargin = false){
|
||||||
|
|
||||||
$sum_net_amount = ShoppingOrderMargin::whereMSponsorId($user_id)
|
$sum_net_amount = ShoppingOrderMargin::whereMSponsorId($user_id)
|
||||||
->wherePaid(true)
|
->wherePaid(true)
|
||||||
|
|
@ -113,6 +113,13 @@ class UserMarign
|
||||||
->wherePartnerCommissionPaid(false)
|
->wherePartnerCommissionPaid(false)
|
||||||
->where('partner_commission_pending_to', '<', Carbon::now())
|
->where('partner_commission_pending_to', '<', Carbon::now())
|
||||||
->sum('net_partner_commission');
|
->sum('net_partner_commission');
|
||||||
|
if($addUserCreditMargin){
|
||||||
|
$sum_net_credit = UserCreditMargin::whereUserId($user_id)
|
||||||
|
->wherePaid(false)
|
||||||
|
->sum('credit');
|
||||||
|
$sum_net_amount += $sum_net_credit;
|
||||||
|
}
|
||||||
|
|
||||||
if($format){
|
if($format){
|
||||||
$sum_net_amount = Util::formatNumber($sum_net_amount);
|
$sum_net_amount = Util::formatNumber($sum_net_amount);
|
||||||
}
|
}
|
||||||
|
|
@ -170,6 +177,15 @@ class UserMarign
|
||||||
return $ShoppingOrderMargins;
|
return $ShoppingOrderMargins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getUserCreditMarginByID($user_id){
|
||||||
|
|
||||||
|
$UserCreditMargin = UserCreditMargin::whereUserId($user_id)
|
||||||
|
->wherePaid(false)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return $UserCreditMargin;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getOrderFromPartnerCommissionPendingByID($user_id){
|
public static function getOrderFromPartnerCommissionPendingByID($user_id){
|
||||||
|
|
||||||
$ShoppingOrderMargins = ShoppingOrderMargin::whereMSponsorId($user_id)
|
$ShoppingOrderMargins = ShoppingOrderMargin::whereMSponsorId($user_id)
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,13 @@ class Yard extends Cart
|
||||||
private $yard_commission;
|
private $yard_commission;
|
||||||
private $yard_margin;
|
private $yard_margin;
|
||||||
|
|
||||||
private $global_tax_rate = 19;
|
private $global_tax_rate = 0;
|
||||||
|
|
||||||
public function __construct(SessionManager $session, Dispatcher $events)
|
public function __construct(SessionManager $session, Dispatcher $events)
|
||||||
{
|
{
|
||||||
$this->ysession = $session;
|
$this->ysession = $session;
|
||||||
$this->yinstance = sprintf('%s.%s', 'cart', 'shipping_extras');
|
$this->yinstance = sprintf('%s.%s', 'cart', 'shipping_extras');
|
||||||
|
|
||||||
if($this->getYardExtra('shipping_price')){
|
if($this->getYardExtra('shipping_price')){
|
||||||
$this->shipping_price = (float) ($this->getYardExtra('shipping_price'));
|
$this->shipping_price = (float) ($this->getYardExtra('shipping_price'));
|
||||||
}
|
}
|
||||||
|
|
@ -80,6 +81,11 @@ class Yard extends Cart
|
||||||
if($this->getYardExtra('yard_margin')){
|
if($this->getYardExtra('yard_margin')){
|
||||||
$this->yard_margin = $this->getYardExtra('yard_margin');
|
$this->yard_margin = $this->getYardExtra('yard_margin');
|
||||||
}
|
}
|
||||||
|
if($this->getYardExtra('global_tax_rate') || $this->getYardExtra('global_tax_rate') === 0.0){
|
||||||
|
$this->global_tax_rate = $this->getYardExtra('global_tax_rate');
|
||||||
|
}else{
|
||||||
|
$this->global_tax_rate = config('cart.tax');
|
||||||
|
}
|
||||||
|
|
||||||
/*if($this->getYardExtra('num_comp')){
|
/*if($this->getYardExtra('num_comp')){
|
||||||
$this->num_comp = $this->getYardExtra('num_comp');
|
$this->num_comp = $this->getYardExtra('num_comp');
|
||||||
|
|
@ -104,6 +110,13 @@ class Yard extends Cart
|
||||||
{
|
{
|
||||||
return config('cart.tax');
|
return config('cart.tax');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setGlobalTaxRate($value){
|
||||||
|
|
||||||
|
$this->global_tax_rate = floatval($value);
|
||||||
|
$this->putYardExtra('global_tax_rate', $this->global_tax_rate);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function putYardExtra($key, $value){
|
public function putYardExtra($key, $value){
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ class CreateUserCreditsTable extends Migration
|
||||||
$table->date('date')->nullable();
|
$table->date('date')->nullable();
|
||||||
$table->text('credit')->nullable();
|
$table->text('credit')->nullable();
|
||||||
$table->text('user_margins')->nullable();
|
$table->text('user_margins')->nullable();
|
||||||
|
$table->text('user_credits')->nullable();
|
||||||
|
|
||||||
$table->boolean('paid_out')->default(false);
|
$table->boolean('paid_out')->default(false);
|
||||||
$table->boolean('cancellation')->default(false);
|
$table->boolean('cancellation')->default(false);
|
||||||
$table->unsignedTinyInteger('status')->index()->default(0);
|
$table->unsignedTinyInteger('status')->index()->default(0);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateUserCreditMarginsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('user_credit_margins', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
|
||||||
|
$table->unsignedInteger('user_id');
|
||||||
|
|
||||||
|
$table->decimal('credit', 13, 2)->nullable();
|
||||||
|
$table->text('message')->nullable();
|
||||||
|
$table->unsignedTinyInteger('status')->index()->default(0);
|
||||||
|
$table->boolean('paid')->default(false);
|
||||||
|
$table->unsignedBigInteger('user_credit_id')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('user_id')
|
||||||
|
->references('id')
|
||||||
|
->on('users');
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('user_credit_margins');
|
||||||
|
}
|
||||||
|
}
|
||||||
45
resources/views/admin/modal/add_credit.blade.php
Normal file
45
resources/views/admin/modal/add_credit.blade.php
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
{!! Form::open(['url' => route('admin_payments_credit'), 'class' => 'modal-content', 'enctype' => 'multipart/form-data']) !!}
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">
|
||||||
|
{{ __('Gutschrift') }}
|
||||||
|
<span class="font-weight-light">hinzufügen</span>
|
||||||
|
</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" name="action" value="{{$data['action']}}">
|
||||||
|
<input type="hidden" name="id" value="{{$data['id']}}">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-12">
|
||||||
|
<label for="member_id" class="form-label">{{ __('Vertriebspartner auswählen') }}*</label>
|
||||||
|
<select class="selectpicker" name="member_id" data-style="btn-light" data-live-search="true" required>
|
||||||
|
{!! HTMLHelper::getMembersOptions(0, true) !!}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-12">
|
||||||
|
<label class="form-label" for="credit">{{ __('Betrag') }} netto*</label>
|
||||||
|
{{ Form::text('credit', '', array('placeholder'=>__('in Euro'), 'class'=>'form-control', 'required'=>true)) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-12">
|
||||||
|
<label class="form-label" for="message">{{ __('Mitteilung') }}*</label>
|
||||||
|
{{ Form::textarea('message', '' , array('placeholder'=>__('Mitteilung'), 'class'=>'form-control', 'rows'=>4, 'required'=>true)) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">schließen</button>
|
||||||
|
<button type="submit" class="btn btn-primary">{{__('Gutschrift hinzufügen')}}</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{!! Form::close() !!}
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$( document ).ready(function() {
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
@ -20,12 +20,12 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-12">
|
<div class="form-group col-12">
|
||||||
<label class="form-label" for="credit">{{ __('Betrag') }}</label>
|
<label class="form-label" for="credit">{{ __('Betrag') }}*</label>
|
||||||
{{ Form::text('credit', '', array('placeholder'=>__('in Euro'), 'class'=>'form-control', 'required'=>true)) }}
|
{{ Form::text('credit', '', array('placeholder'=>__('in Euro'), 'class'=>'form-control', 'required'=>true)) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-12">
|
<div class="form-group col-12">
|
||||||
<label class="form-label" for="message">{{ __('Mitteilung') }}</label>
|
<label class="form-label" for="message">{{ __('Mitteilung') }}*</label>
|
||||||
{{ Form::textarea('message', '' , array('placeholder'=>__('Mitteilung'), 'class'=>'form-control', 'rows'=>4, 'required'=>true)) }}
|
{{ Form::textarea('message', '' , array('placeholder'=>__('Mitteilung'), 'class'=>'form-control', 'rows'=>4, 'required'=>true)) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,12 @@
|
||||||
<td><a class="btn btn-secondary btn-xs" href="{{ route('admin_sales_users_detail', [$user_pay_credit->shopping_order_id]) }}"><i class="ion ion-md-eye"></i></a></td>
|
<td><a class="btn btn-secondary btn-xs" href="{{ route('admin_sales_users_detail', [$user_pay_credit->shopping_order_id]) }}"><i class="ion ion-md-eye"></i></a></td>
|
||||||
@else
|
@else
|
||||||
@if($user_pay_credit->status === 3 && $deleteTime = $user_pay_credit->deleteTime())
|
@if($user_pay_credit->status === 3 && $deleteTime = $user_pay_credit->deleteTime())
|
||||||
<td><div class="no-line-break"><a class="btn btn-danger btn-xs" href="{{ route('admin_payments_paycredit_delete', [$user_pay_credit->id]) }}"><i class="ion ion-ios-trash"></i></a> noch {{ $deleteTime }} min.</div>
|
<td>
|
||||||
|
<div class="no-line-break">
|
||||||
|
<a class="btn btn-danger btn-xs" href="{{ route('admin_payments_paycredit_delete', [$user_pay_credit->id]) }}" onclick="return confirm('Wirklich löschen?');">
|
||||||
|
<i class="ion ion-ios-trash"></i>
|
||||||
|
</a> noch {{ $deleteTime }} min.
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@else
|
@else
|
||||||
<td>-</td>
|
<td>-</td>
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,37 @@
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.td-entry-table-margin {
|
||||||
|
padding-bottom: 6px;
|
||||||
|
border-bottom: 1px solid rgb(221, 221, 221);
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h6 class="card-header">
|
<h6 class="card-header">
|
||||||
Zahlungen / offene Gutschriften
|
Zahlungen / offene Gutschriften
|
||||||
|
|
||||||
|
<div class="float-right">
|
||||||
|
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
|
||||||
|
data-id="new"
|
||||||
|
data-action="add-user-credit"
|
||||||
|
data-back="{{url()->current()}}"
|
||||||
|
data-route="{{ route('modal_load') }}"><span class="far fa-plus-circle"></span> Gutschrift hinzufügen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</h6>
|
</h6>
|
||||||
|
|
||||||
|
@if(isset($add_credit_error) && $add_credit_error)
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="alert alert-danger p-2 mt-2">
|
||||||
|
<ul>
|
||||||
|
<li>{{ $add_credit_error }}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="card-datatable table-responsive pt-0">
|
<div class="card-datatable table-responsive pt-0">
|
||||||
<table class="datatables-style table table-striped table-bordered">
|
<table class="datatables-style table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
@ -14,7 +41,7 @@
|
||||||
<th>{{__('Nachname') }}</th>
|
<th>{{__('Nachname') }}</th>
|
||||||
<th>{{__('E-Mail') }}</th>
|
<th>{{__('E-Mail') }}</th>
|
||||||
<th>{{__('Betrag') }}</th>
|
<th>{{__('Betrag') }}</th>
|
||||||
<th>{{__('Aus Bestellung')}}</th>
|
<th>{{__('aus Bestellung / Gutschrift')}}</th>
|
||||||
<th>{{__('#')}}</th>
|
<th>{{__('#')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
@ -24,19 +51,34 @@
|
||||||
<td>{{ $ShoppingOrderMargin->first_name }}</td>
|
<td>{{ $ShoppingOrderMargin->first_name }}</td>
|
||||||
<td>{{ $ShoppingOrderMargin->last_name }}</td>
|
<td>{{ $ShoppingOrderMargin->last_name }}</td>
|
||||||
<td>{{ $ShoppingOrderMargin->email }}</td>
|
<td>{{ $ShoppingOrderMargin->email }}</td>
|
||||||
<td>{!! \App\Services\UserMarign::getMontlyPartnerCommissionOpenByID($ShoppingOrderMargin->user_id, null, true) !!} €</td>
|
<td>{!! \App\Services\UserMarign::getMontlyPartnerCommissionOpenByID($ShoppingOrderMargin->user_id, null, true, true) !!} €</td>
|
||||||
<td>
|
<td>
|
||||||
@foreach (\App\Services\UserMarign::getOrderFromPartnerCommissionByID($ShoppingOrderMargin->user_id) as $order)
|
@foreach (\App\Services\UserMarign::getOrderFromPartnerCommissionByID($ShoppingOrderMargin->user_id) as $order)
|
||||||
@if($order->shopping_order)
|
@if($order->shopping_order)
|
||||||
<a href="{{ route('admin_sales_customers_detail', [$order->shopping_order->id]) }}">
|
<div class="td-entry-table-margin"><a href="{{ route('admin_sales_customers_detail', [$order->shopping_order->id]) }}">
|
||||||
{{$order->shopping_order->shopping_user->billing_firstname }}
|
{{$order->shopping_order->shopping_user->billing_firstname }}
|
||||||
{{$order->shopping_order->shopping_user->billing_lastname }}
|
{{$order->shopping_order->shopping_user->billing_lastname }}
|
||||||
/ {{ $order->shopping_order->getLastShoppingPayment('reference') }}
|
/ {{ $order->shopping_order->getLastShoppingPayment('reference') }}
|
||||||
/ {{ $order->shopping_order->getFormattedTotalWithoutCredit()." €" }}
|
/ {{ $order->shopping_order->getFormattedTotalWithoutCredit()." €" }}
|
||||||
/ {{ $order->shopping_order->created_at->format("d.m.Y") }}
|
/ {{ $order->shopping_order->created_at->format("d.m.Y") }}
|
||||||
</a> <br>
|
</a>
|
||||||
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@foreach (\App\Services\UserMarign::getUserCreditMarginByID($ShoppingOrderMargin->user_id) as $creditMaring)
|
||||||
|
<div class="td-entry-table-margin">
|
||||||
|
<i class="fa fa-plus-circle text-secondary"></i>
|
||||||
|
{!! nl2br($creditMaring->message) !!}
|
||||||
|
/ {{ $creditMaring->created_at->format("d.m.Y") }}
|
||||||
|
@if($deleteTime = $creditMaring->deleteTime())
|
||||||
|
/ <span class="no-line-break">
|
||||||
|
<a class="btn btn-danger btn-xs" href="{{ route('admin_payments_credit_delete', [$creditMaring->id, 'user_credit_margin']) }}" onclick="return confirm('Wirklich löschen?');">
|
||||||
|
<i class="ion ion-ios-trash"></i>
|
||||||
|
</a> noch {{ $deleteTime }} min.
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-credit"
|
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-credit"
|
||||||
|
|
@ -49,6 +91,39 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@foreach ($onlyUserCreditMargins as $user_id => $onlyUserCreditMargin)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $onlyUserCreditMargin['first_name'] }}</td>
|
||||||
|
<td>{{ $onlyUserCreditMargin['last_name'] }}</td>
|
||||||
|
<td>{{ $onlyUserCreditMargin['email'] }}</td>
|
||||||
|
<td>{!! formatNumber($onlyUserCreditMargin['sum']) !!} €</td>
|
||||||
|
<td>
|
||||||
|
@foreach ($onlyUserCreditMargin['entries'] as $key => $creditMaring)
|
||||||
|
<div class="td-entry-table-margin">
|
||||||
|
<i class="fa fa-plus-circle text-secondary"></i>
|
||||||
|
{!! nl2br($creditMaring->message) !!}
|
||||||
|
/ {{ $creditMaring->created_at->format("d.m.Y") }}
|
||||||
|
@if($deleteTime = $creditMaring->deleteTime())
|
||||||
|
/ <span class="no-line-break">
|
||||||
|
<a class="btn btn-danger btn-xs" href="{{ route('admin_payments_credit_delete', [$creditMaring->id, 'user_credit_margin']) }}" onclick="return confirm('Wirklich löschen?');">
|
||||||
|
<i class="ion ion-ios-trash"></i>
|
||||||
|
</a> noch {{ $deleteTime }} min.
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-credit"
|
||||||
|
data-userid="{{ $onlyUserCreditMargin['user_id'] }}"
|
||||||
|
data-email="{{ $onlyUserCreditMargin['email'] }}"
|
||||||
|
data-back="{{url()->current()}}"
|
||||||
|
data-action="create_credit">
|
||||||
|
<span class="far fa-file-invoice-dollar"></span> <strong>Gutschrift erstellen</strong>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -82,14 +157,15 @@
|
||||||
<td>
|
<td>
|
||||||
@foreach (\App\Services\UserMarign::getOrderFromPartnerCommissionPendingByID($ShoppingOrderMarginPending->user_id) as $order)
|
@foreach (\App\Services\UserMarign::getOrderFromPartnerCommissionPendingByID($ShoppingOrderMarginPending->user_id) as $order)
|
||||||
@if($order->shopping_order)
|
@if($order->shopping_order)
|
||||||
|
<div class="td-entry-table-margin"><a href="{{ route('admin_sales_customers_detail', [$order->shopping_order->id]) }}">
|
||||||
<a href="{{ route('admin_sales_customers_detail', [$order->shopping_order->id]) }}">
|
<a href="{{ route('admin_sales_customers_detail', [$order->shopping_order->id]) }}">
|
||||||
{{$order->shopping_order->shopping_user->billing_firstname }}
|
{{$order->shopping_order->shopping_user->billing_firstname }}
|
||||||
{{$order->shopping_order->shopping_user->billing_lastname }}
|
{{$order->shopping_order->shopping_user->billing_lastname }}
|
||||||
/ {{ $order->shopping_order->getLastShoppingPayment('reference') }}
|
/ {{ $order->shopping_order->getLastShoppingPayment('reference') }}
|
||||||
/ {{$order->shopping_order->getFormattedTotalWithoutCredit()." €" }}
|
/ {{$order->shopping_order->getFormattedTotalWithoutCredit()." €" }}
|
||||||
/ {{ $order->shopping_order->created_at->format("d.m.Y") }}
|
/ {{ $order->shopping_order->created_at->format("d.m.Y") }}
|
||||||
|
</a>
|
||||||
</a> <br>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -130,7 +206,7 @@
|
||||||
<th>{{__('Betrag') }}</th>
|
<th>{{__('Betrag') }}</th>
|
||||||
<th>{{__('Datum') }}</th>
|
<th>{{__('Datum') }}</th>
|
||||||
<th>{{__('Zahlung')}}</th>
|
<th>{{__('Zahlung')}}</th>
|
||||||
<th>{{__('aus Bestellung')}}</th>
|
<th>{{__('aus Bestellung / Gutschrift')}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
|
||||||
|
|
@ -343,6 +343,17 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
@foreach($user_credits->credits as $credit)
|
||||||
|
<tr class="item">
|
||||||
|
<td class="small text-left">
|
||||||
|
{!! nl2br($credit->message) !!} / {{ $credit->created_at }}
|
||||||
|
</td>
|
||||||
|
<td class="text-right small">
|
||||||
|
{{ \App\Services\Util::formatNumber($credit->net) }} €*
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr class="fullline">
|
<tr class="fullline">
|
||||||
|
|
|
||||||
|
|
@ -287,9 +287,11 @@ Route::group(['middleware' => ['admin']], function()
|
||||||
|
|
||||||
//payments
|
//payments
|
||||||
Route::get('/admin/payments/credit', 'PaymentCreditController@index')->name('admin_payments_credit');
|
Route::get('/admin/payments/credit', 'PaymentCreditController@index')->name('admin_payments_credit');
|
||||||
Route::post('/admin/payments/credit', 'PaymentCreditController@index')->name('admin_payments_credit');
|
Route::post('/admin/payments/credit', 'PaymentCreditController@store')->name('admin_payments_credit');
|
||||||
Route::get('/admin/payments/credit/datatable', 'PaymentCreditController@datatable')->name('admin_payments_credit_datatable');
|
Route::get('/admin/payments/credit/datatable', 'PaymentCreditController@datatable')->name('admin_payments_credit_datatable');
|
||||||
Route::post('/admin/payments/credit/create', 'PaymentCreditController@create')->name('admin_payments_credit_create');
|
Route::post('/admin/payments/credit/create', 'PaymentCreditController@create')->name('admin_payments_credit_create');
|
||||||
|
Route::get('/admin/payments/credit/delete/{id}/{del?}', 'PaymentCreditController@delete')->name('admin_payments_credit_delete');
|
||||||
|
|
||||||
|
|
||||||
Route::get('/admin/payments/paycredit', 'PaymentPayCreditController@index')->name('admin_payments_paycredit');
|
Route::get('/admin/payments/paycredit', 'PaymentPayCreditController@index')->name('admin_payments_paycredit');
|
||||||
Route::post('/admin/payments/paycredit', 'PaymentPayCreditController@store')->name('admin_payments_paycredit');
|
Route::post('/admin/payments/paycredit', 'PaymentPayCreditController@store')->name('admin_payments_paycredit');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue