'#geehrte:r#',
'salutation' => '#Anrede#',
'title' => '#Titel#',
'first_name' => '#Vorname#',
'last_name' => '#Nachname#',
'country' => '#Reiseland#',
'program' => '#Programm#',
'start_date' => '#Anreisedatum#',
'end_date' => '#Abreisedatum#',
'participants' => '#Teilnehmer#',
'booking_date' => '#Buchungsdatum#',
'airline' => '#Airline#',
'extra_services' => '#zugebuchte_Leistungen#',
'net_price_travel' => '#Nettopreise_Rundreise#',
'net_price_extra_services' => '#Nettopreise_zugebuchte_Leistungen#',
'booked_rooms' => '#Gebuchte_Zimmer#',
'myjack_nr' => "#MyJackNr#",
'filekey' => "#Filekey#",
'flight_info' => "#Airline_Fluginfo#",
'check_in' => "#Airline_Checkin#",
'baggage' => "#Airline_Gepaeck#",
'country_visum' => '#Reiseland_Visum#',
'country_contact' => '#Reiseland_Kontakt#',
];
public static $placeholder_lead = [
'dear' => '#geehrte:r#',
'salutation' => '#Anrede#',
'title' => '#Titel#',
'first_name' => '#Vorname#',
'last_name' => '#Nachname#',
'country' => '#Reiseland#',
'program' => '#Programm#',
'start_date' => '#Anreisedatum#',
'end_date' => '#Abreisedatum#',
'participants' => '#Teilnehmer#',
'booking_date' => '#Buchungsdatum#',
];
public static $placeholder_fewo= [
'dear' => '#geehrte:r#',
'salutation' => '#Anrede#',
'title' => '#Titel#',
'first_name' => '#Vorname#',
'last_name' => '#Nachname#',
'program' => '#Programm#',
'start_date' => '#Anreisedatum#',
'end_date' => '#Abreisedatum#',
'booking_date' => '#Buchungsdatum#',
];
public static function getOptionsSummernote($key){
/*
[{value:'blockChainId', content:'blockChainId'},
{value:'attachement', content:'attachement'},
{value:'address', content:'address'}]*/
$ret = "";
switch ($key) {
case 'booking':
$placehoder = self::$placeholder_booking;
break;
case 'lead':
$placehoder = self::$placeholder_lead;
break;
case 'fewo':
$placehoder = self::$placeholder_fewo;
break;
default:
$placehoder = self::$placeholder_booking;
break;
}
foreach ($placehoder as $key => $value) {
$value = str_replace('#', '', $value);
$ret .= "'".$value."',";
}
return $ret;
}
public static function getOptionsQuill($key){
$ret = "";
switch ($key) {
case 'booking':
$placehoder = self::$placeholder_booking;
break;
case 'lead':
$placehoder = self::$placeholder_lead;
break;
case 'fewo':
$placehoder = self::$placeholder_fewo;
break;
default:
$placehoder = self::$placeholder_booking;
break;
}
foreach ($placehoder as $key => $value) {
$value = str_replace('#', '', $value);
$ret .= "{id: '".$value."', label: '".$value."'},"."\n";
}
return $ret;
}
public static function getBookingOptions(){
$ret = "";
foreach (self::$placeholder_booking as $key => $value) {
$value = str_replace('#', '', $value);
$ret .= ''."\n";
}
return $ret;
}
public static function getLeadOptions(){
$ret = "";
foreach (self::$placeholder_lead as $key => $value) {
$value = str_replace('#', '', $value);
$ret .= ''."\n";
}
return $ret;
}
public static function getFewoOptions(){
$ret = "";
foreach (self::$placeholder_fewo as $key => $value) {
$value = str_replace('#', '', $value);
$ret .= ''."\n";
}
return $ret;
}
public static function replaceBooking(Booking $booking, $content)
{
$dear = $booking->customer->getSalutationDear();
$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->getSalutationName() : '-';
$filekey = $booking->filekey;
$flight_info = "";
$check_in = "";
$baggage = "";
$country_visum = "";
$country_contact = "";
$start_date = $booking->getStartDateFormat();
$end_date = $booking->getEndDateFormat();
$booking_date = $booking->getBookingDateFormat();
$airline = $booking->airline ? $booking->airline->name_full : '-';
$extra_services = self::getBookingPlaceholdersBy('extra_services', $booking);
$net_price_travel = self::getBookingPlaceholdersBy('net_price_travel', $booking);
$net_price_extra_services = self::getBookingPlaceholdersBy('net_price_extra_services', $booking);
$booked_rooms = self::getBookingPlaceholdersBy('booked_rooms', $booking);
$myjack_nr = $booking->merlin_order_number;
$participants = "Teilnehmer:in
";
//first
if($booking->participant_firstname){
$participants .= $booking->participant_salutation_id ? \App\Services\Model::getSalutationById($booking->participant_salutation_id)." " : '';
$participants .= $booking->participant_firstname." ".$booking->participant_name;
$participants .= $booking->participant_birthdate ? ' | '._format_date($booking->participant_birthdate) : '';
$participants .= $booking->travel_nationality ? ' | '.$booking->travel_nationality->name : '';
$participants .= '
';
}
if($booking->participants->count()){
foreach($booking->participants as $participant){
$participants .= $participant->salutation ? $participant->salutation->name." " : '';
$participants .= $participant->participant_firstname." ".$participant->participant_name;
$participants .= $participant->participant_birthdate ? ' | '._format_date($participant->participant_birthdate) : '';
$participants .= $participant->travel_nationality ? ' | '.$participant->travel_nationality->name : '';
$participants .= $participant->participant_child ? ' | Kind' : '';
$participants .= '
';
}
}
$search = [];
$replace = [];
foreach (self::$placeholder_booking as $key => $value) {
$search[] = $value;
$replace[] = isset(${$key}) ? ${$key} : "";
}
$content = str_replace($search, $replace, $content);
$content = preg_replace('/(.*?)<\/placeholder>/', '$1', $content);
$content = preg_replace('/(.*?)<\/span>/', '$1', $content);
return $content;
}
public static function replaceBookingFewo(TravelUserBookingFewo $booking_fewo, $content)
{
$dear = $booking_fewo->travel_user->getSalutationDear();
$first_name = $booking_fewo->travel_user->first_name;
$last_name = $booking_fewo->travel_user->last_name;
$title = $booking_fewo->travel_user->title;
$program = $booking_fewo->fewo_lodging_id ? $booking_fewo->fewo_lodging->name : "-";
$salutation = $booking_fewo->travel_user->getSalutationName();
$start_date = $booking_fewo->from_date;
$end_date = $booking_fewo->to_date;
$booking_date = $booking_fewo->booking_date;
$search = [];
$replace = [];
foreach (self::$placeholder_fewo as $key => $value) {
$search[] = $value;
$replace[] = ${$key};
}
$content = str_replace($search, $replace, $content);
$content = preg_replace('/(.*?)<\/placeholder>/', '$1', $content);
$content = preg_replace('/(.*?)<\/span>/', '$1', $content);
return $content;
}
public static function replaceLead(Lead $lead, $content)
{
$dear = $lead->customer->getSalutationDear();
$first_name = $lead->customer->firstname;
$last_name = $lead->customer->name;
$title = $lead->customer->title;
$country = $lead->travelcountry_id ? $lead->travel_country->name : "-";
$program = $lead->travelagenda_id ? $lead->travel_agenda->name : "-";
$salutation = $lead->customer->getSalutationName();
$start_date = $lead->travelperiod_start ? _format_date($lead->travelperiod_start) : '-';
$end_date = $lead->travelperiod_end ? _format_date($lead->travelperiod_end) : '-';
$booking_date = $lead->request_date ? _format_date($lead->request_date) : '-';
$participants = "";
if($lead->lead_participants->count()){
$participants = "Teilnehmer:in
";
foreach($lead->lead_participants as $participant){
$participants .= $participant->salutation ? $participant->salutation->name." " : '';
$participants .= $participant->participant_firstname." ".$participant->participant_name;
$participants .= $participant->participant_birthdate ? ' | '._format_date($participant->participant_birthdate) : '';
//$participants .= $participant->participant_child ? ' | Kind' : ' | Erwachsener';
//$participants .= $participant->travel_nationality ? ' | '.$participant->travel_nationality->name : '';
$participants .= '
';
}
}
$search = [];
$replace = [];
foreach (self::$placeholder_lead as $key => $value) {
$search[] = $value;
$replace[] = ${$key};
}
$content = str_replace($search, $replace, $content);
$content = preg_replace('/(.*?)<\/placeholder>/', '$1', $content);
$content = preg_replace('/(.*?)<\/span>/', '$1', $content);
return $content;
}
private static function getBookingPlaceholdersBy($key, $booking){
if($booking->new_drafts){
$booked_rooms = '';
$extra_services = '';
$net_price_travel = 0;
$net_price_extra_services = 0;
foreach($booking->booking_draft_items as $booking_draft_item){
//41 zugebuchte Leistungen
//32 Aufpreis Kategorie
if(in_array($booking_draft_item->draft_type_id, [32, 41])){
}
//24 Rundreise
if($booking_draft_item->draft_type_id == 24){
}
//30 Grundpreis Reise (Zimmer)
if($booking_draft_item->draft_type_id == 30){
$booked_rooms .= self::cleanText($booking_draft_item->service)." | ".$booking_draft_item->adult." Erw. ".($booking_draft_item->children ? " | ".$booking_draft_item->children." Kin." : '')."
";
$prices = $booking_draft_item->getItemPrice();
$net_price_travel += $prices['adult'];
$net_price_travel += $prices['children'];
}
}
switch ($key) {
case 'extra_services':
return "zugebuchte Leistungen:
".$extra_services;
break;
case 'net_price_travel':
return "Nettopreis Rundreise: ".Util::_number_format($net_price_travel)." Euro";
break;
case 'net_price_extra_services':
return "Nettopreise zugebuchte Leistungen:
".$net_price_extra_services;
break;
case 'booked_rooms':
return "Gebuchte Zimmer:
".$booked_rooms;
break;
}
}
}
private static function cleanText($text){
$text = str_replace('pro Person im', '', $text);
return $text;
}
}