20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
|
|
@ -32,12 +32,12 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property ShoppingOrder $shopping_order
|
||||
* @package App\Models
|
||||
* @property string|null $filename
|
||||
* @property string|null $dir
|
||||
* @property string|null $delivery_filename
|
||||
* @property string|null $delivery_dir
|
||||
* @property string|null $disk
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice newQuery()
|
||||
* @method static \Illuminate\Database\Query\Builder|UserInvoice onlyTrashed()
|
||||
|
|
@ -66,143 +66,285 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|UserInvoice whereYear($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|UserInvoice withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|UserInvoice withoutTrashed()
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserInvoice extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'user_invoices';
|
||||
use SoftDeletes;
|
||||
|
||||
protected $casts = [
|
||||
'shopping_order_id' => 'int',
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'number' => 'int',
|
||||
'paid' => 'bool',
|
||||
'cancellation' => 'bool',
|
||||
'cancellation_id' => 'int',
|
||||
'status' => 'int',
|
||||
'infos' => 'array',
|
||||
];
|
||||
protected $table = 'user_invoices';
|
||||
|
||||
protected $dates = [
|
||||
'date',
|
||||
'paid_date',
|
||||
'cancellation_date'
|
||||
];
|
||||
protected $casts = [
|
||||
'shopping_order_id' => 'int',
|
||||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'number' => 'int',
|
||||
'paid' => 'bool',
|
||||
'cancellation' => 'bool',
|
||||
'cancellation_id' => 'int',
|
||||
'status' => 'int',
|
||||
'infos' => 'array',
|
||||
];
|
||||
|
||||
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'
|
||||
];
|
||||
protected $dates = [
|
||||
'date',
|
||||
'paid_date',
|
||||
'cancellation_date',
|
||||
];
|
||||
|
||||
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'
|
||||
];
|
||||
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 $statusTypes = [
|
||||
0 => '-',
|
||||
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',
|
||||
12 => 'storniert Shop',
|
||||
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'warning',
|
||||
1 => 'success',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
11 => 'danger',
|
||||
12 => 'danger',
|
||||
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 getMonthName($month)
|
||||
public function shopping_order()
|
||||
{
|
||||
return isset(self::$monthNames[$month]) ? self::$monthNames[$month] : $month;
|
||||
return $this->belongsTo(ShoppingOrder::class);
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
|
||||
public function getDateAttribute($value)
|
||||
{
|
||||
return $this->attributes['date'] ? Carbon::parse($this->attributes['date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
public function setDateAttribute($value)
|
||||
{
|
||||
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : null;
|
||||
}
|
||||
|
||||
public function getDownloadPath($full = false){
|
||||
if(!$full){
|
||||
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 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){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt den Download-Pfad für die lokalisierte Rechnung zurück.
|
||||
* Bei 'de' oder nicht vorhandener Locale-Version wird das Original zurückgegeben.
|
||||
*
|
||||
* @param string|null $locale Sprachcode (de, en, es)
|
||||
* @param bool $full Vollständiger Dateisystempfad oder relativer Pfad
|
||||
* @return string
|
||||
*/
|
||||
public function getDownloadPathLocale($locale = null, $full = false)
|
||||
{
|
||||
// Bei Deutsch oder keiner Angabe: Original zurückgeben
|
||||
if (! $locale || $locale === 'de') {
|
||||
return $this->getDownloadPath($full);
|
||||
}
|
||||
|
||||
// Dateiname mit Locale-Suffix
|
||||
$filename = str_replace('.pdf', '-'.$locale.'.pdf', $this->filename);
|
||||
$path = $this->dir.$filename;
|
||||
|
||||
// Prüfen ob Locale-Version existiert, sonst Fallback auf DE
|
||||
if (! \Storage::disk($this->disk)->exists($path)) {
|
||||
return $this->getDownloadPath($full);
|
||||
}
|
||||
|
||||
return $full ? \Storage::disk($this->disk)->path($path) : $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt den Download-Pfad für den lokalisierten Lieferschein zurück.
|
||||
* Bei 'de' oder nicht vorhandener Locale-Version wird das Original zurückgegeben.
|
||||
*
|
||||
* @param string|null $locale Sprachcode (de, en, es)
|
||||
* @param bool $full Vollständiger Dateisystempfad oder relativer Pfad
|
||||
* @return string
|
||||
*/
|
||||
public function getDownloadPathDeliveryLocale($locale = null, $full = false)
|
||||
{
|
||||
// Bei Deutsch oder keiner Angabe: Original zurückgeben
|
||||
if (! $locale || $locale === 'de') {
|
||||
return $this->getDownloadPathDelivery($full);
|
||||
}
|
||||
|
||||
// Dateiname mit Locale-Suffix
|
||||
$filename = str_replace('.pdf', '-'.$locale.'.pdf', $this->delivery_filename);
|
||||
$path = $this->delivery_dir.$filename;
|
||||
|
||||
// Prüfen ob Locale-Version existiert, sonst Fallback auf DE
|
||||
if (! \Storage::disk($this->disk)->exists($path)) {
|
||||
return $this->getDownloadPathDelivery($full);
|
||||
}
|
||||
|
||||
return $full ? \Storage::disk($this->disk)->path($path) : $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt den lokalisierten Dateinamen für die Rechnung zurück.
|
||||
*
|
||||
* @param string|null $locale
|
||||
* @return string
|
||||
*/
|
||||
public function getFilenameLocale($locale = null)
|
||||
{
|
||||
if (! $locale || $locale === 'de') {
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
$filename = str_replace('.pdf', '-'.$locale.'.pdf', $this->filename);
|
||||
$path = $this->dir.$filename;
|
||||
|
||||
// Fallback auf Original wenn nicht vorhanden
|
||||
if (! \Storage::disk($this->disk)->exists($path)) {
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt alle verfügbaren lokalisierten Versionen der Rechnung zurück (außer DE).
|
||||
*
|
||||
* @return array Array mit Sprachcodes, z.B. ['en', 'es']
|
||||
*/
|
||||
public function getAvailableLocales(): array
|
||||
{
|
||||
$availableTemplates = config('localization.availableTemplates', ['de']);
|
||||
$locales = [];
|
||||
|
||||
foreach ($availableTemplates as $locale) {
|
||||
if ($locale === 'de') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filename = str_replace('.pdf', '-'.$locale.'.pdf', $this->filename);
|
||||
$path = $this->dir.$filename;
|
||||
|
||||
if (\Storage::disk($this->disk)->exists($path)) {
|
||||
$locales[] = $locale;
|
||||
}
|
||||
}
|
||||
|
||||
return $locales;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft ob eine lokalisierte Version für die angegebene Sprache existiert.
|
||||
*/
|
||||
public function hasLocale(string $locale): bool
|
||||
{
|
||||
if ($locale === 'de') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$filename = str_replace('.pdf', '-'.$locale.'.pdf', $this->filename);
|
||||
$path = $this->dir.$filename;
|
||||
|
||||
return \Storage::disk($this->disk)->exists($path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue