60 lines
2.2 KiB
PHP
60 lines
2.2 KiB
PHP
<?php
|
|
namespace App\Services;
|
|
|
|
|
|
use App\Models\ShoppingOrder;
|
|
use App\Models\ShoppingPayment;
|
|
use App\User;
|
|
|
|
class Payment
|
|
{
|
|
|
|
public static $txaction_text = [
|
|
'paid' => "bezahlt",
|
|
'appointed' => "offen",
|
|
'failed' => "abbruch",
|
|
'extern' => "extern",
|
|
'NULL' => 'keine Zahlung',
|
|
];
|
|
|
|
public static $txaction_color = [
|
|
'paid' => "success",
|
|
'appointed' => "warning",
|
|
'failed' => "danger",
|
|
'extern' => "success",
|
|
];
|
|
|
|
|
|
public static function getFormattedTxaction($txaction){
|
|
if($txaction && isset(self::$txaction_text[$txaction])){
|
|
return self::$txaction_text[$txaction];
|
|
}
|
|
return self::$txaction_text['NULL'];
|
|
}
|
|
|
|
public static function getFormattedTxactionColor($txaction){
|
|
if($txaction && isset(self::$txaction_color[$txaction])){
|
|
return self::$txaction_color[$txaction];
|
|
}
|
|
return "warning";
|
|
}
|
|
|
|
public static function getShoppingOrderBadge(ShoppingOrder $shopping_order){
|
|
if($shopping_order->mode === 'test'){
|
|
return '<span class="badge badge-pill badge-default">'.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).'</span>';
|
|
}
|
|
if($shopping_order->mode === 'dev'){
|
|
return '<span class="badge badge-pill badge-default">'.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).'</span>';
|
|
}
|
|
return '<span class="badge badge-pill badge-'.self::getFormattedTxactionColor($shopping_order->txaction).'">'.self::getFormattedTxaction($shopping_order->txaction).'</span>';
|
|
}
|
|
|
|
public static function getShoppingPaymentBadge(ShoppingPayment $shopping_payment){
|
|
if($shopping_payment->mode === 'test'){
|
|
return '<span class="badge badge-pill badge-default">'.strtoupper($shopping_payment->mode).' - '.self::getFormattedTxaction($shopping_payment->txaction).'</span>';
|
|
}
|
|
return '<span class="badge badge-pill badge-'.self::getFormattedTxactionColor($shopping_payment->txaction).'">'.self::getFormattedTxaction($shopping_payment->txaction).'</span>';
|
|
}
|
|
|
|
|
|
}
|