WIP: Sicherheitsnetz vor Phase-1-R\u00fcckbau
Enth\u00e4lt gemischt: Laravel-10-Upgrade + Phase 1 (Contacts-Modul, Duplicats-Commands, Soft-Delete+Merge-Fields) + Phase 2 Code-Umstellungen (inquiry_id, $table='contacts'/'inquiries') + Offers-Modul (Migrationen, Models, offer_id in Booking, offer-Disk in filesystems.php). Phase 2 + Offers werden im folgenden Commit nach dev/backups/phase2-offers-2026-04-17/ verschoben, damit der Workspace auf Phase-1-only (= Test-System-Stand) reduziert ist und direkt auf Live deploybar wird. Tarball-Backup zus\u00e4tzlich unter: ../backups-safety/workspace-pre-phase1-rollback-2026-04-17.tar.gz Made-with: Cursor
This commit is contained in:
parent
389d5d1820
commit
e3dc1afd8e
165 changed files with 21914 additions and 3516 deletions
|
|
@ -1,127 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Airline;
|
||||
use App\Models\Insurance;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\CustomerMail;
|
||||
use App\Models\TravelCompany;
|
||||
|
||||
class Booking
|
||||
{
|
||||
|
||||
private static $output_dirs = [];
|
||||
|
||||
public static function contentFiles(){
|
||||
$booking_email_files = CMSContent::where('identifier', '=', 'booking-email-file')->get()->sortByDesc('pos')->pluck('slug', 'id');
|
||||
return $booking_email_files;
|
||||
public static function contentFiles(): \Illuminate\Support\Collection
|
||||
{
|
||||
return CMSContent::where('identifier', '=', 'booking-email-file')
|
||||
->get()
|
||||
->sortByDesc('pos')
|
||||
->pluck('slug', 'id');
|
||||
}
|
||||
|
||||
public static function setOutputDirs($dir, $subdir){
|
||||
self::$output_dirs[$dir][] = $subdir;
|
||||
public static function setOutputDirs(string $dir, string $subdir): void
|
||||
{
|
||||
MailDirService::setOutputDir($dir, $subdir);
|
||||
}
|
||||
|
||||
public static function getMailDirNotInOutput($booking_id, $dir){
|
||||
$is_o_dirs = isset(self::$output_dirs[$dir]) ? self::$output_dirs[$dir] : [];
|
||||
$ret = [];
|
||||
$CustomerMails = CustomerMail::whereBookingId($booking_id)->whereDir($dir)->get();
|
||||
if($CustomerMails){
|
||||
foreach($CustomerMails as $CustomerMail){
|
||||
if(!in_array($CustomerMail->subdir, $is_o_dirs)){
|
||||
$ret[] = $CustomerMail->subdir;
|
||||
}
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getMailDirNotInOutput(int $bookingId, string $dir): array
|
||||
{
|
||||
$mails = CustomerMail::whereBookingId($bookingId)->whereDir($dir)->get();
|
||||
return MailDirService::getMailDirsNotInOutput($mails, $dir);
|
||||
}
|
||||
|
||||
public static function getCustomerMailDirs(): \Illuminate\Database\Eloquent\Collection
|
||||
{
|
||||
return MailDirService::getCustomerMailDirs();
|
||||
}
|
||||
|
||||
public static function getCustomerMailDir(int $id): ?\App\Models\CMSContent
|
||||
{
|
||||
return MailDirService::getCustomerMailDir($id);
|
||||
}
|
||||
|
||||
public static function getCustomerMailName(\App\Models\CMSContent $mailDir, int $mailDirId): string
|
||||
{
|
||||
return MailDirService::getCustomerMailName($mailDir, $mailDirId);
|
||||
}
|
||||
|
||||
public static function getCustomerMailEmails(\App\Models\CMSContent $mailDir, int $mailDirId): array|string
|
||||
{
|
||||
return MailDirService::getCustomerMailEmails($mailDir, $mailDirId);
|
||||
}
|
||||
|
||||
public static function getBookingInstructionPDFName(\App\Models\FewoLodging $fewo): string
|
||||
{
|
||||
return "HINWEISE-FERIENWOHNUNG-" . $fewo->pdf_name . ".pdf";
|
||||
}
|
||||
|
||||
public static function getBookingCMSContent(\App\Models\CMSContent $content, string $identifier): \Illuminate\Database\Eloquent\Collection
|
||||
{
|
||||
return CMSContent::where('identifier', '=', $identifier)
|
||||
->where('integer', $content->id)
|
||||
->get()
|
||||
->sortBy('pos');
|
||||
}
|
||||
|
||||
public static function getBookingCMSContentForPDF(string $identifierContent, string $identifier): array
|
||||
{
|
||||
$pdfContent = [];
|
||||
$contents = CMSContent::where('identifier', '=', $identifierContent)->get()->sortBy('pos');
|
||||
|
||||
foreach ($contents as $content) {
|
||||
if ($content->decimal > 0) {
|
||||
$pdfContent[] = $content;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCustomerMailDirs(){
|
||||
$customer_mail_dirs = CMSContent::where('identifier', '=', 'customer-mail-dirs')->get()->sortBy('pos');
|
||||
return $customer_mail_dirs;
|
||||
}
|
||||
|
||||
|
||||
public static function getCustomerMailDir($id){
|
||||
return CMSContent::where('identifier', '=', 'customer-mail-dirs')->where('pos', '=', $id)->first();
|
||||
}
|
||||
|
||||
public static function getCustomerMailName($customer_mail_dir, $mail_dir_id){
|
||||
|
||||
switch ($customer_mail_dir->getArrayContent('model')){
|
||||
case 'TravelCountry':
|
||||
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
|
||||
break;
|
||||
case 'Airline':
|
||||
$model = Airline::find($mail_dir_id);
|
||||
break;
|
||||
case 'Insurance':
|
||||
$model = Insurance::find($mail_dir_id);
|
||||
break;
|
||||
case 'TravelCompany':
|
||||
$model = TravelCompany::find($mail_dir_id);
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
if($model){
|
||||
if($customer_mail_dir->getArrayContent('model') === 'TravelCountry'){
|
||||
return $model->mail_dir_name;
|
||||
}
|
||||
return $model->name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function getCustomerMailEmails($customer_mail_dir, $mail_dir_id){
|
||||
|
||||
switch ($customer_mail_dir->getArrayContent('model')){
|
||||
case 'TravelCountry':
|
||||
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
|
||||
break;
|
||||
case 'Airline':
|
||||
$model = Airline::find($mail_dir_id);
|
||||
break;
|
||||
case 'Insurance':
|
||||
$model = Insurance::find($mail_dir_id);
|
||||
break;
|
||||
case 'TravelCompany':
|
||||
$model = TravelCompany::find($mail_dir_id);
|
||||
break;
|
||||
default:
|
||||
//direkt from CMSContent
|
||||
return $customer_mail_dir->getArrayContent('emails');
|
||||
}
|
||||
|
||||
if($model){
|
||||
return $model->contact_emails;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getBookingInstructionPDFName($fewo){
|
||||
return "HINWEISE-FERIENWOHNUNG-".$fewo->pdf_name.".pdf";
|
||||
}
|
||||
|
||||
public static function getBookingCMSContent($content, $identifier){
|
||||
return CMSContent::where('identifier', '=', $identifier)->where('integer', $content->id)->get()->sortBy('pos');
|
||||
}
|
||||
|
||||
public static function getBookingCMSContentForPDF($identifier_content, $identifier){
|
||||
$pdf_content = [];
|
||||
$contents = CMSContent::where('identifier', '=', $identifier_content)->get()->sortBy('pos');
|
||||
foreach ($contents as $content){
|
||||
if($content->decimal > 0){ //in_pdf
|
||||
$pdf_content[] = $content;
|
||||
}
|
||||
if($fewo_contents = self::getBookingCMSContent($content, $identifier)){
|
||||
foreach ($fewo_contents as $fewo_content){
|
||||
if($fewo_content->decimal > 0){ //in_pdf
|
||||
$pdf_content[] = $fewo_content;
|
||||
}
|
||||
foreach (self::getBookingCMSContent($content, $identifier) as $fewoContent) {
|
||||
if ($fewoContent->decimal > 0) {
|
||||
$pdfContent[] = $fewoContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $pdf_content;
|
||||
|
||||
return $pdfContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class BookingImport
|
|||
$data = [
|
||||
'booking_date' => $travel_booking->created->format('Y-m-d'),
|
||||
'customer_id' => $customer->id,
|
||||
'lead_id' => $lead->id,
|
||||
'inquiry_id' => $lead->id,
|
||||
'new_drafts' => $travel_booking->drafts === null ? 0 : 1,
|
||||
'sf_guard_user_id' => 15,
|
||||
'branch_id' => 4,
|
||||
|
|
|
|||
|
|
@ -1,124 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Airline;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\Insurance;
|
||||
use App\Models\LeadMail;
|
||||
use App\Models\TravelCompany;
|
||||
|
||||
class Lead
|
||||
{
|
||||
private static $output_dirs = [];
|
||||
|
||||
public static function contentFiles(){
|
||||
$lead_files = CMSContent::where('identifier', '=', 'lead-email-file')->get()->sortByDesc('pos')->pluck('slug', 'id');
|
||||
return $lead_files;
|
||||
public static function contentFiles(): \Illuminate\Support\Collection
|
||||
{
|
||||
return CMSContent::where('identifier', '=', 'lead-email-file')
|
||||
->get()
|
||||
->sortByDesc('pos')
|
||||
->pluck('slug', 'id');
|
||||
}
|
||||
|
||||
public static function setOutputDirs($dir, $subdir){
|
||||
self::$output_dirs[$dir][] = $subdir;
|
||||
public static function setOutputDirs(string $dir, string $subdir): void
|
||||
{
|
||||
MailDirService::setOutputDir($dir, $subdir);
|
||||
}
|
||||
|
||||
public static function getMailDirNotInOutput($lead_id, $dir){
|
||||
$is_o_dirs = isset(self::$output_dirs[$dir]) ? self::$output_dirs[$dir] : [];
|
||||
$ret = [];
|
||||
$LeadMails = LeadMail::whereLeadId($lead_id)->whereDir($dir)->get();
|
||||
if($LeadMails){
|
||||
foreach($LeadMails as $LeadMail){
|
||||
if(!in_array($LeadMail->subdir, $is_o_dirs)){
|
||||
$ret[] = $LeadMail->subdir;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCustomerMailDirs(){
|
||||
$customer_mail_dirs = CMSContent::where('identifier', '=', 'customer-mail-dirs')->get()->sortBy('pos');
|
||||
return $customer_mail_dirs;
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getMailDirNotInOutput(int $leadId, string $dir): array
|
||||
{
|
||||
$mails = LeadMail::whereLeadId($leadId)->whereDir($dir)->get();
|
||||
return MailDirService::getMailDirsNotInOutput($mails, $dir);
|
||||
}
|
||||
|
||||
public static function getCustomerMailDir($id){
|
||||
return CMSContent::where('identifier', '=', 'customer-mail-dirs')->where('pos', '=', $id)->first();
|
||||
public static function getCustomerMailDirs(): \Illuminate\Database\Eloquent\Collection
|
||||
{
|
||||
return MailDirService::getCustomerMailDirs();
|
||||
}
|
||||
|
||||
public static function getCustomerMailName($lead_mail_dir, $mail_dir_id){
|
||||
|
||||
switch ($lead_mail_dir->getArrayContent('model')){
|
||||
case 'TravelCountry':
|
||||
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
|
||||
break;
|
||||
case 'Airline':
|
||||
$model = Airline::find($mail_dir_id);
|
||||
break;
|
||||
case 'Insurance':
|
||||
$model = Insurance::find($mail_dir_id);
|
||||
break;
|
||||
case 'TravelCompany':
|
||||
$model = TravelCompany::find($mail_dir_id);
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
if($model){
|
||||
if($lead_mail_dir->getArrayContent('model') === 'TravelCountry'){
|
||||
return $model->mail_dir_name;
|
||||
}
|
||||
return $model->name;
|
||||
}
|
||||
return "";
|
||||
public static function getCustomerMailDir(int $id): ?\App\Models\CMSContent
|
||||
{
|
||||
return MailDirService::getCustomerMailDir($id);
|
||||
}
|
||||
|
||||
public static function getCustomerMailEmails($lead_mail_dir, $mail_dir_id){
|
||||
|
||||
switch ($lead_mail_dir->getArrayContent('model')){
|
||||
case 'TravelCountry':
|
||||
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
|
||||
break;
|
||||
case 'Airline':
|
||||
$model = Airline::find($mail_dir_id);
|
||||
break;
|
||||
case 'Insurance':
|
||||
$model = Insurance::find($mail_dir_id);
|
||||
break;
|
||||
case 'TravelCompany':
|
||||
$model = TravelCompany::find($mail_dir_id);
|
||||
break;
|
||||
default:
|
||||
//direkt from CMSContent
|
||||
return $lead_mail_dir->getArrayContent('emails');
|
||||
}
|
||||
|
||||
if($model){
|
||||
return $model->contact_emails;
|
||||
}
|
||||
return [];
|
||||
public static function getCustomerMailName(\App\Models\CMSContent $mailDir, int $mailDirId): string
|
||||
{
|
||||
return MailDirService::getCustomerMailName($mailDir, $mailDirId);
|
||||
}
|
||||
|
||||
/*public static function getFeWoInstructionPDFName($fewo){
|
||||
return "HINWEISE-FERIENWOHNUNG-".$fewo->pdf_name.".pdf";
|
||||
public static function getCustomerMailEmails(\App\Models\CMSContent $mailDir, int $mailDirId): array|string
|
||||
{
|
||||
return MailDirService::getCustomerMailEmails($mailDir, $mailDirId);
|
||||
}
|
||||
public static function getFeWoCMSContent($content, $identifier_fewo){
|
||||
return CMSContent::where('identifier', '=', $identifier_fewo)->where('integer', $content->id)->get()->sortBy('pos');
|
||||
}
|
||||
|
||||
public static function getFeWoCMSContentForPDF($identifier_content, $identifier_fewo){
|
||||
$pdf_content = [];
|
||||
$contents = CMSContent::where('identifier', '=', $identifier_content)->get()->sortBy('pos');
|
||||
foreach ($contents as $content){
|
||||
if($content->decimal > 0){ //in_pdf
|
||||
$pdf_content[] = $content;
|
||||
}
|
||||
if($fewo_contents = BookingFewo::getFeWoCMSContent($content, $identifier_fewo)){
|
||||
foreach ($fewo_contents as $fewo_content){
|
||||
if($fewo_content->decimal > 0){ //in_pdf
|
||||
$pdf_content[] = $fewo_content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $pdf_content;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
92
app/Services/MailDirService.php
Normal file
92
app/Services/MailDirService.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Airline;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\Insurance;
|
||||
use App\Models\TravelCompany;
|
||||
|
||||
class MailDirService
|
||||
{
|
||||
private static array $outputDirs = [];
|
||||
|
||||
public static function setOutputDir(string $dir, string $subdir): void
|
||||
{
|
||||
self::$outputDirs[$dir][] = $subdir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getCustomerMailDirs(): \Illuminate\Database\Eloquent\Collection
|
||||
{
|
||||
return CMSContent::where('identifier', '=', 'customer-mail-dirs')->get()->sortBy('pos');
|
||||
}
|
||||
|
||||
public static function getCustomerMailDir(int $id): ?CMSContent
|
||||
{
|
||||
return CMSContent::where('identifier', '=', 'customer-mail-dirs')->where('pos', '=', $id)->first();
|
||||
}
|
||||
|
||||
public static function getCustomerMailName(CMSContent $mailDir, int $mailDirId): string
|
||||
{
|
||||
$model = self::resolveModel($mailDir, $mailDirId);
|
||||
|
||||
if ($model === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($mailDir->getArrayContent('model') === 'TravelCountry') {
|
||||
return $model->mail_dir_name ?? '';
|
||||
}
|
||||
|
||||
return $model->name ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string>|string
|
||||
*/
|
||||
public static function getCustomerMailEmails(CMSContent $mailDir, int $mailDirId): array|string
|
||||
{
|
||||
$model = self::resolveModel($mailDir, $mailDirId);
|
||||
|
||||
if ($model === null) {
|
||||
// Default: emails come directly from CMSContent
|
||||
return $mailDir->getArrayContent('emails') ?? [];
|
||||
}
|
||||
|
||||
return $model->contact_emails ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns subdirs from a mail collection that were not already in the output.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Collection $mails Collection of CustomerMail or LeadMail
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getMailDirsNotInOutput(iterable $mails, string $dir): array
|
||||
{
|
||||
$processed = self::$outputDirs[$dir] ?? [];
|
||||
$result = [];
|
||||
|
||||
foreach ($mails as $mail) {
|
||||
if (!in_array($mail->subdir, $processed, true)) {
|
||||
$result[] = $mail->subdir;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private static function resolveModel(CMSContent $mailDir, int $mailDirId): mixed
|
||||
{
|
||||
return match ($mailDir->getArrayContent('model')) {
|
||||
'TravelCountry' => \App\Models\Sym\TravelCountry::find($mailDirId),
|
||||
'Airline' => Airline::find($mailDirId),
|
||||
'Insurance' => Insurance::find($mailDirId),
|
||||
'TravelCompany' => TravelCompany::find($mailDirId),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -221,7 +221,7 @@ class Passolution
|
|||
if(!Storage::disk('public')->exists( $this->pdf_dir )){
|
||||
Storage::disk('public')->makeDirectory($this->pdf_dir); //creates directory
|
||||
}
|
||||
$this->pdf_path = Storage::disk('public')->getAdapter()->getPathPrefix();
|
||||
$this->pdf_path = Storage::disk('public')->path('');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Services;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Util
|
||||
{
|
||||
|
||||
|
|
@ -51,18 +53,17 @@ class Util
|
|||
public static function _format_date($date, $to = 'date')
|
||||
{
|
||||
if ($to === 'datetime') {
|
||||
return \Carbon::parse($date)->format(\Util::formatDateTimeDB());
|
||||
return Carbon::parse($date)->format(self::formatDateTimeDB());
|
||||
}
|
||||
//date
|
||||
return \Carbon::parse($date)->format(\Util::formatDateDB());
|
||||
return Carbon::parse($date)->format(self::formatDateDB());
|
||||
}
|
||||
|
||||
public static function _reformat_date($date, $to = 'date')
|
||||
{
|
||||
if ($to === 'datetime') {
|
||||
return \Carbon::parse($date)->format('Y-m-d - H:i');
|
||||
return Carbon::parse($date)->format('Y-m-d - H:i');
|
||||
}
|
||||
return \Carbon::parse($date)->format('Y-m-d');
|
||||
return Carbon::parse($date)->format('Y-m-d');
|
||||
}
|
||||
|
||||
public static function _format_number($value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue