95 lines
No EOL
3.5 KiB
PHP
95 lines
No EOL
3.5 KiB
PHP
<?php
|
|
namespace App\Services;
|
|
|
|
use App\Models\Booking;
|
|
use App\Models\TravelUserBookingFewo;
|
|
|
|
class Placeholder
|
|
{
|
|
|
|
public static $booking = [
|
|
'dear' => '#geehrte/r#',
|
|
'salutation' => '#Anrede#',
|
|
'title' => '#Titel#',
|
|
'first_name' => '#Vorname#',
|
|
'last_name' => '#Nachname#',
|
|
'country' => '#Reiseland#',
|
|
'program' => '#Programm#',
|
|
'start_date' => '#Anreisedatum#',
|
|
'end_date' => '#Abreisedatum#',
|
|
'booking_date' => '#Buchungsdatum#',
|
|
'airline' => '#Airline#'
|
|
];
|
|
|
|
public static function getBookingQuill(){
|
|
$ret = "";
|
|
foreach (self::$booking as $key => $value) {
|
|
$value = str_replace('#', '', $value);
|
|
$ret .= "{id: '".$value."', label: '".$value."'},"."\n";
|
|
}
|
|
return $ret;
|
|
}
|
|
public static function getBookingOptions(){
|
|
$ret = "";
|
|
foreach (self::$booking as $key => $value) {
|
|
$value = str_replace('#', '', $value);
|
|
$ret .= '<option value="'.$value.'">'.$value.'</option>'."\n";
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
public static function replaceBooking(Booking $booking, $content)
|
|
{
|
|
$dear = $booking->customer->salutation_id == 1 ? 'geehrter' : 'geehrte';
|
|
$first_name = $booking->customer->firstname;
|
|
$last_name = $booking->customer->name;
|
|
$title = $booking->customer->title;
|
|
$country = $booking->travel_country_id ? $booking->travel_country->name : "-";
|
|
$program = $booking->travelagenda_id ? $booking->travel_agenda->name : "-";
|
|
$salutation = isset($booking->customer->salutation) ? $booking->customer->salutation->name : '';
|
|
$start_date = $booking->getStartDateFormat();
|
|
$end_date = $booking->getEndDateFormat();
|
|
$booking_date = $booking->getBookingDateFormat();
|
|
$airline = $booking->airline ? $booking->airline->name_full : '-';
|
|
$search = [];
|
|
$replace = [];
|
|
|
|
foreach (self::$booking as $key => $value) {
|
|
$search[] = $value;
|
|
$replace[] = ${$key};
|
|
}
|
|
$content = str_replace($search, $replace, $content);
|
|
$content = preg_replace('/<placeholder.*?>(.*?)<\/placeholder>/', '$1', $content);
|
|
$content = preg_replace('/<span contenteditable="false">(.*?)<\/span>/', '$1', $content);
|
|
return $content;
|
|
}
|
|
|
|
public static function replaceBookingFewo(TravelUserBookingFewo $booking_fewo, $content)
|
|
{
|
|
$dear = $booking_fewo->travel_user->salutation_id == 1 ? 'geehrter' : 'geehrte';
|
|
$first_name = $booking_fewo->travel_user->first_name;
|
|
$last_name = $booking_fewo->travel_user->last_name;
|
|
$title = $booking_fewo->travel_user->title;
|
|
$country = "";
|
|
$program = $booking_fewo->fewo_lodging_id ? $booking_fewo->fewo_lodging->name : "-";
|
|
$salutation = $booking_fewo->travel_user->salutation_id == 1 ? 'Herr' : 'Frau';
|
|
$start_date = $booking_fewo->from_date;
|
|
$end_date = $booking_fewo->to_date;
|
|
$booking_date = $booking_fewo->booking_date;
|
|
$airline = "";
|
|
$search = [];
|
|
$replace = [];
|
|
|
|
foreach (self::$booking as $key => $value) {
|
|
$search[] = $value;
|
|
$replace[] = ${$key};
|
|
}
|
|
$content = str_replace($search, $replace, $content);
|
|
$content = preg_replace('/<placeholder.*?>(.*?)<\/placeholder>/', '$1', $content);
|
|
$content = preg_replace('/<span contenteditable="false">(.*?)<\/span>/', '$1', $content);
|
|
return $content;
|
|
}
|
|
|
|
|
|
|
|
} |