Gutschriften Anpassungen
This commit is contained in:
parent
3754f1c571
commit
e670b92f5d
28 changed files with 303 additions and 99 deletions
|
|
@ -7,7 +7,7 @@ use App\Models\HomepartyUser;
|
|||
use App\Models\Product;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingUser;
|
||||
|
||||
use App\Models\UserCredit;
|
||||
use App\User;
|
||||
use Request;
|
||||
|
||||
|
|
@ -73,6 +73,13 @@ class ModalController extends Controller
|
|||
$ret = view("admin.modal.add_pay_credit", compact('value', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-credit-status'){
|
||||
$value = UserCredit::find($data['id']); //current user form order
|
||||
$ret = view("admin.modal.user-credit-status", compact('value', 'data'))->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*if($data['action'] === 'homeparty-add-product') {
|
||||
$homeparty = Homeparty::find($data['id']);
|
||||
$homeparty_user = HomepartyUser::find($data['user_id']);
|
||||
|
|
|
|||
|
|
@ -67,17 +67,27 @@ class PaymentCreditController extends Controller
|
|||
|
||||
public function create(){
|
||||
$data = Request::all();
|
||||
if(!isset($data['userid'])){
|
||||
abort(404);
|
||||
}
|
||||
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 setActiveYears(){
|
||||
|
|
@ -127,10 +137,18 @@ class PaymentCreditController extends Controller
|
|||
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', 'user_margins'])
|
||||
->rawColumns(['shipping_order', 'total', 'credit', 'status', 'user_margins'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -92,6 +92,7 @@ class PaymentInvoiceController extends Controller
|
|||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('invoice_number', 'invoice_number $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ class AdminToolsController extends Controller
|
|||
|
||||
public function index($action)
|
||||
{
|
||||
|
||||
|
||||
dd($action);
|
||||
switch ($action) {
|
||||
case 'pay_credits':
|
||||
# code...
|
||||
|
|
@ -56,7 +57,10 @@ class AdminToolsController extends Controller
|
|||
|
||||
public function store($action)
|
||||
{
|
||||
|
||||
|
||||
dd($action);
|
||||
|
||||
$data = [];
|
||||
switch ($action) {
|
||||
case 'pay_credits':
|
||||
|
|
|
|||
|
|
@ -32,14 +32,12 @@ class MailCheckout extends Mailable
|
|||
|
||||
if($this->txaction === 'paid'){
|
||||
$this->subject = __('email.checkout_subject_paid')." ";
|
||||
$this->subject .= ".gruene-seele.bio";
|
||||
}elseif($this->txaction === 'extern'){
|
||||
$this->subject = __('email.checkout_subject_extern').": ";
|
||||
$this->subject .= $shopping_order->member->account->m_first_name." ".$shopping_order->member->account->m_last_name." - ";
|
||||
$this->subject .= $shopping_order->shopping_user->billing_firstname." ".$shopping_order->shopping_user->billing_lastname;
|
||||
}else{
|
||||
$this->subject = __('email.checkout_subject')." ";
|
||||
$this->subject .= ".gruene-seele.bio";
|
||||
}
|
||||
|
||||
/*if($shopping_order->user_shop){
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ class ShoppingOrder extends Model
|
|||
'weight',
|
||||
'paid',
|
||||
'invoice',
|
||||
'invoice_number',
|
||||
'txaction',
|
||||
'wp_invoice_path',
|
||||
'wp_notice',
|
||||
|
|
|
|||
|
|
@ -127,12 +127,12 @@ class UserAccount extends Model
|
|||
'm_account', 'm_salutation', 'm_first_name', 'm_last_name', 'm_notes', 'company', 'salutation', 'first_name', 'last_name', 'address', 'address_2', 'zipcode', 'city', 'country_id', 'pre_phone_id', 'phone', 'pre_mobil_id', 'mobil',
|
||||
'tax_number', 'tax_identification_number', 'taxable_sales', 'same_as_billing',
|
||||
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_pre_phone_id', 'shipping_phone',
|
||||
'birthday', 'website', 'facebook', 'facebook_fanpage', 'instagram', 'notice'
|
||||
'birthday', 'website', 'facebook', 'facebook_fanpage', 'instagram', 'notice', 'payment_data'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'payment_data' => 'array',
|
||||
'notice' => 'array',
|
||||
'notice' => 'array'
|
||||
];
|
||||
|
||||
use SoftDeletes;
|
||||
|
|
@ -194,6 +194,10 @@ class UserAccount extends Model
|
|||
return Carbon::parse($this->attributes['accept_contract'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
public function getPaymentData($key)
|
||||
{
|
||||
return isset($this->payment_data[$key]) ? $this->payment_data[$key] : '';
|
||||
}
|
||||
|
||||
public function getCountryAttrAs($attr, $as = false){
|
||||
if($this->country){
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ class UserCredit extends Model
|
|||
|
||||
protected $fillable = [
|
||||
'auth_user_id',
|
||||
'credit_number',
|
||||
'net',
|
||||
'tax_rate',
|
||||
'tax',
|
||||
|
|
@ -77,6 +78,20 @@ class UserCredit extends Model
|
|||
'status'
|
||||
];
|
||||
|
||||
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');
|
||||
|
|
@ -112,5 +127,14 @@ class UserCredit extends Model
|
|||
{
|
||||
return formatNumber($this->attributes['total']);
|
||||
}
|
||||
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,11 +58,12 @@ class CreditRepository extends BaseRepository {
|
|||
'filename' => $filename,
|
||||
'dir' => $dir,
|
||||
'disk' => 'public',
|
||||
'invoice_number' => $credit_number,
|
||||
'credit_number' => $credit_number,
|
||||
'credit_date' => $credit_date,
|
||||
];
|
||||
$user_credit = UserCredit::create([
|
||||
'auth_user_id' => $this->model->id,
|
||||
'credit_number' => $credit_number,
|
||||
'net' => $user_credits->net,
|
||||
'tax_rate' => $user_credits->tax_rate,
|
||||
'tax' => $user_credits->tax,
|
||||
|
|
@ -78,10 +79,7 @@ class CreditRepository extends BaseRepository {
|
|||
Credit::sendCreditMail($user_credit);
|
||||
}
|
||||
$this->finishUserCredit($user_credit);
|
||||
|
||||
return true;
|
||||
//return $pdf->stream('invoice.pdf');
|
||||
//return $this->output($path.$dir, $filename);
|
||||
}
|
||||
|
||||
private function finishUserCredit($user_credit){
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ class InvoiceRepository extends BaseRepository {
|
|||
'invoice_date' => $invoice_date,
|
||||
];
|
||||
$this->model->invoice = $data_file;
|
||||
$this->model->invoice_number = $invoice_number;
|
||||
$this->model->save();
|
||||
|
||||
if($invoice_send_mail){
|
||||
|
|
|
|||
|
|
@ -16,23 +16,23 @@ class Credit
|
|||
|
||||
|
||||
public static function makeNextCreditNumber(){
|
||||
$invoice_number = self::getCreditNumber();
|
||||
$invoice_number = $invoice_number+1;
|
||||
Setting::setContentBySlug('credit-number', $invoice_number, 'int');
|
||||
return $invoice_number;
|
||||
$credit_number = self::getCreditNumber();
|
||||
$credit_number = $credit_number+1;
|
||||
Setting::setContentBySlug('credit-number', $credit_number, 'int');
|
||||
return $credit_number;
|
||||
}
|
||||
|
||||
public static function createCreditNumber($invoice_number, $invoice_date){
|
||||
$prefix = "GS".\Carbon::parse($invoice_date)->format('Ym');
|
||||
return $prefix.$invoice_number;
|
||||
public static function createCreditNumber($credit_number, $credit_date){
|
||||
$prefix = "GS".\Carbon::parse($credit_date)->format('Ym');
|
||||
return $prefix.$credit_number;
|
||||
}
|
||||
|
||||
public static function getCreditStorageDir($invoice_date){
|
||||
return "/credit/".\Carbon::parse($invoice_date)->format('Y/m/');
|
||||
public static function getCreditStorageDir($credit_date){
|
||||
return "/credit/".\Carbon::parse($credit_date)->format('Y/m/');
|
||||
}
|
||||
|
||||
public static function makeCreditFilename($invoice_number){
|
||||
return "Gutschrift-".$invoice_number.".pdf";
|
||||
public static function makeCreditFilename($credit_number){
|
||||
return "Gutschrift-".$credit_number.".pdf";
|
||||
}
|
||||
|
||||
public static function isCredit(UserCredit $user_credit){
|
||||
|
|
@ -64,7 +64,6 @@ class Credit
|
|||
public static function sendCreditMail(UserCredit $user_credit){
|
||||
$bcc = [];
|
||||
$email = $user_credit->user->email;
|
||||
$email = "kevin.adametz@me.com";
|
||||
if(!$email){
|
||||
if($user_credit->user->mode === 'test'){
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -394,6 +394,18 @@ class HTMLHelper
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAnyOptions($id, $options = [], $all=true){#
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
}
|
||||
foreach ($options as $key=>$value){
|
||||
$attr = ($key == $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$key.'" '.$attr.'>'.$value.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getOptionRange($select, $from=1, $to=50){
|
||||
$values = range($from, $to);
|
||||
$ret = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue