Teilnehmer extra, Emails Anfragen Order

This commit is contained in:
Kevin Adametz 2021-09-15 19:11:38 +02:00
parent a718baf971
commit 5e3bd3a1ba
19 changed files with 174 additions and 48 deletions

View file

@ -90,12 +90,17 @@ class BookingController extends Controller
'end_date' => $travel_booking->selected_end_date->format('Y-m-d'),
'website_id' => 1,
'travel_number' => isset($travel_booking->selected_travel['travel_number']) ? $travel_booking->selected_travel['travel_number'] : null,
'participant_name' => isset($travel_booking->participants[0]['last_name']) ? $travel_booking->participants[0]['last_name'] : null,
/*'participant_name' => isset($travel_booking->participants[0]['last_name']) ? $travel_booking->participants[0]['last_name'] : null,
'participant_firstname' => isset($travel_booking->participants[0]['first_name']) ? $travel_booking->participants[0]['first_name'] : null,
'participant_birthdate' => isset($travel_booking->participants[0]['birthday']) ? date( "Y-m-d", strtotime($travel_booking->participants[0]['birthday'])) : null,
'participant_salutation_id' => isset($travel_booking->participants[0]['gender']) ? $travel_booking->participants[0]['gender'] : null,
'nationality_id' => isset($travel_booking->participants[0]['nationality']) ? $travel_booking->participants[0]['nationality'] : null,
'travel_company_id' => isset($travel_booking->service_items[0]['travel_company_id']) ? $travel_booking->service_items[0]['travel_company_id'] : null,
'nationality_id' => isset($travel_booking->participants[0]['nationality']) ? $travel_booking->participants[0]['nationality'] : null,*/
'participant_name' => null,
'participant_firstname' => null,
'participant_birthdate' => null,
'participant_salutation_id' => null,
'nationality_id' => null,
'travel_company_id' => null,
'price' => $travel_booking->price,
'price_total' => $travel_booking->price_total,
'deposit_total' => $travel_booking->deposit_total,
@ -110,7 +115,6 @@ class BookingController extends Controller
//createTraveler
if($travel_booking->participants){
foreach ($travel_booking->participants as $key => $participant){
if($key > 0){
Participant::create([
'booking_id' => $booking->id,
'participant_name' => $participant['last_name'],
@ -120,7 +124,7 @@ class BookingController extends Controller
'participant_child' => $participant['child'],
'nationality_id' =>$participant['nationality'],
]);
}
}
}

View file

@ -124,11 +124,6 @@ class BookingController extends Controller
return redirect(route('booking_detail', [$booking->id])."#collapseBookingParticipant");
}
if($id === "new") {
$booking = new Booking();
}else{

View file

@ -43,7 +43,6 @@ class EmailsController extends Controller
'fewo_email_files' => CMSContent::where('identifier', '=', $this->identifier_fewo_file)->get()->sortByDesc('pos'),
'customer_fewo_mail_dirs' => BookingFewo::getCustomerMailDirs(),
'lead_email_files' => CMSContent::where('identifier', '=', $this->identifier_lead_file)->get()->sortByDesc('pos'),
'customer_lead_mail_dirs' => Lead::getCustomerMailDirs(),
'step' => $step
];

View file

@ -206,11 +206,12 @@ class BookingRepository extends BaseRepository {
}
}
//main
$this->model->participant_salutation_id = isset($data['participant_salutation_id']) ? $data['participant_salutation_id'] : 1;
$this->model->participant_name = isset($data['participant_name']) ? $data['participant_name'] : "";
$this->model->participant_firstname = isset($data['participant_firstname']) ? $data['participant_firstname'] : "";
$this->model->nationality_id = isset($data['nationality_id']) ? $data['nationality_id'] : 1;
$this->model->participant_birthdate = isset($data['participant_birthdate']) ? _reformat_date($data['participant_birthdate']) : 1;
$this->model->participant_salutation_id = isset($data['participant_salutation_id']) ? $data['participant_salutation_id'] : null;
$this->model->participant_name = isset($data['participant_name']) ? $data['participant_name'] : null;
$this->model->participant_firstname = isset($data['participant_firstname']) ? $data['participant_firstname'] : null;
$this->model->nationality_id = isset($data['nationality_id']) ? $data['nationality_id'] : null;
$this->model->participant_birthdate = isset($data['participant_birthdate']) ? _reformat_date($data['participant_birthdate']) : null;
$this->model->save();
return $this->model;
}

View file

@ -371,7 +371,6 @@ class LeadMailRepository extends BaseRepository {
$value->subtitle = "Die E-Mail wird im System gespeichert.";
if($data['id'] === 'reply-save'){
$value->subtitle = "Die E-Mail wird im System als Antwort gespeichert.";
}
$value->url = $data['url'];
$value->show = 'reply';

View file

@ -2,18 +2,39 @@
namespace App\Services;
use App\Models\Airline;
use App\Models\CMSContent;
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 setOutputDirs($dir, $subdir){
self::$output_dirs[$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 $ret;
}
public static function getCustomerMailDirs(){
$customer_mail_dirs = CMSContent::where('identifier', '=', 'customer-mail-dirs')->get()->sortBy('pos');
return $customer_mail_dirs;
@ -23,7 +44,7 @@ class Booking
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')){

View file

@ -4,23 +4,43 @@ 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 setOutputDirs($dir, $subdir){
self::$output_dirs[$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-lead-mail-dirs')->get()->sortBy('pos');
$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-lead-mail-dirs')->where('pos', '=', $id)->first();
return CMSContent::where('identifier', '=', 'customer-mail-dirs')->where('pos', '=', $id)->first();
}
public static function getCustomerMailName($lead_mail_dir, $mail_dir_id){

View file

@ -27,6 +27,11 @@ class Model
}
public static function getTravelCountryCRMArray($emtpy = false){
$TravelCountry = TravelCountry::where('active_backend', 1)->orderBy('name')->get()->pluck('name', 'crm_id');
return $emtpy ? $TravelCountry->prepend('-', 0) : $TravelCountry;
}
public static function getTravelCategoryArray($emtpy = false){
$TravelCategory = TravelCategory::orderBy('name')->get()->pluck('name', 'id');
return $emtpy ? $TravelCategory->prepend('-', 0) : $TravelCategory;
@ -72,6 +77,10 @@ class Model
return $emtpy ? $Salutation->prepend('-', 0) : $Salutation;
}
public static function getSalutationById($id){
$Salutation = Salutation::find($id);
return $Salutation ? $Salutation->name : '';
}
public static function getTravelNationalityArray($emtpy = false){
$TravelNationality = TravelNationality::where('active', true)->orderBy('name')->get()->pluck('name', 'id');
return $emtpy ? $TravelNationality->prepend('-', 0) : $TravelNationality;

View file

@ -19,6 +19,7 @@ class Placeholder
'program' => '#Programm#',
'start_date' => '#Anreisedatum#',
'end_date' => '#Abreisedatum#',
'participants' => '#Teilnehmer#',
'booking_date' => '#Buchungsdatum#',
'airline' => '#Airline#'
];
@ -54,6 +55,26 @@ class Placeholder
$end_date = $booking->getEndDateFormat();
$booking_date = $booking->getBookingDateFormat();
$airline = $booking->airline ? $booking->airline->name_full : '-';
$participants = "Teilnehmer:<br>";
//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 .= '<br>';
}
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 .= '<br>';
}
}
$search = [];
$replace = [];
@ -79,6 +100,7 @@ class Placeholder
$start_date = $booking_fewo->from_date;
$end_date = $booking_fewo->to_date;
$booking_date = $booking_fewo->booking_date;
$participants = "";
$airline = "";
$search = [];
$replace = [];
@ -103,10 +125,23 @@ class Placeholder
$program = "";
$salutation = $lead->customer->salutation_id == 1 ? 'Herr' : 'Frau';
$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) : '';;
$end_date = $lead->travelperiod_end ? _format_date($lead->travelperiod_end) : '';
$booking_date = $lead->request_date ? _format_date($lead->request_date) : '';
$participants = "";
$airline = "";
if($lead->lead_participants->count()){
$participants = "Teilnehmer:<br>";
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 .= '<br>';
}
}
$search = [];
$replace = [];