From 5e3bd3a1baa42a636ec1c0f01fc3243fe35300c2 Mon Sep 17 00:00:00 2001 From: Kevin Adametz Date: Wed, 15 Sep 2021 19:11:38 +0200 Subject: [PATCH] Teilnehmer extra, Emails Anfragen Order --- .../Controllers/API/BookingController.php | 14 +++--- app/Http/Controllers/BookingController.php | 5 --- .../Controllers/Settings/EmailsController.php | 1 - app/Repositories/BookingRepository.php | 11 ++--- app/Repositories/LeadMailRepository.php | 1 - app/Services/Booking.php | 25 ++++++++++- app/Services/Lead.php | 26 +++++++++-- app/Services/Model.php | 9 ++++ app/Services/Placeholder.php | 41 ++++++++++++++++-- .../views/booking/_detail_mails.blade.php | 37 +++++++++++----- .../booking/_detail_participant.blade.php | 2 + resources/views/lead/_detail_lead.blade.php | 2 +- resources/views/lead/_detail_mails.blade.php | 31 ++++++++++++- .../lead/modal-show-mail-inner.blade.php | 10 ++--- .../views/settings/emails/index.blade.php | 7 ++- .../Einreisebestimmungen_de_AT-AU.pdf | Bin 0 -> 39274 bytes .../Einreisebestimmungen_de_AT-IL,JO.pdf | Bin 0 -> 86975 bytes .../Einreisebestimmungen_de_DE-AU.pdf | Bin 0 -> 39254 bytes .../Einreisebestimmungen_de_US-EG.pdf | Bin 0 -> 49600 bytes 19 files changed, 174 insertions(+), 48 deletions(-) create mode 100644 storage/app/public/pdf/passolution/Einreisebestimmungen_de_AT-AU.pdf create mode 100644 storage/app/public/pdf/passolution/Einreisebestimmungen_de_AT-IL,JO.pdf create mode 100644 storage/app/public/pdf/passolution/Einreisebestimmungen_de_DE-AU.pdf create mode 100644 storage/app/public/pdf/passolution/Einreisebestimmungen_de_US-EG.pdf diff --git a/app/Http/Controllers/API/BookingController.php b/app/Http/Controllers/API/BookingController.php index b5c64c8..3469766 100755 --- a/app/Http/Controllers/API/BookingController.php +++ b/app/Http/Controllers/API/BookingController.php @@ -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'], ]); - } + } } diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index f425340..3bee785 100755 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -124,11 +124,6 @@ class BookingController extends Controller return redirect(route('booking_detail', [$booking->id])."#collapseBookingParticipant"); } - - - - - if($id === "new") { $booking = new Booking(); }else{ diff --git a/app/Http/Controllers/Settings/EmailsController.php b/app/Http/Controllers/Settings/EmailsController.php index b32e380..bd30731 100755 --- a/app/Http/Controllers/Settings/EmailsController.php +++ b/app/Http/Controllers/Settings/EmailsController.php @@ -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 ]; diff --git a/app/Repositories/BookingRepository.php b/app/Repositories/BookingRepository.php index 853d80b..d9fcb6a 100644 --- a/app/Repositories/BookingRepository.php +++ b/app/Repositories/BookingRepository.php @@ -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; } diff --git a/app/Repositories/LeadMailRepository.php b/app/Repositories/LeadMailRepository.php index 2d65282..9bd4184 100644 --- a/app/Repositories/LeadMailRepository.php +++ b/app/Repositories/LeadMailRepository.php @@ -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'; diff --git a/app/Services/Booking.php b/app/Services/Booking.php index d2d4e28..43e0433 100644 --- a/app/Services/Booking.php +++ b/app/Services/Booking.php @@ -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')){ diff --git a/app/Services/Lead.php b/app/Services/Lead.php index 1532bd8..5868452 100644 --- a/app/Services/Lead.php +++ b/app/Services/Lead.php @@ -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){ diff --git a/app/Services/Model.php b/app/Services/Model.php index 10d64a1..6c988ef 100644 --- a/app/Services/Model.php +++ b/app/Services/Model.php @@ -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; diff --git a/app/Services/Placeholder.php b/app/Services/Placeholder.php index 9c3d926..cadfac8 100644 --- a/app/Services/Placeholder.php +++ b/app/Services/Placeholder.php @@ -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:
"; + //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 = []; @@ -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:
"; + 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 = []; diff --git a/resources/views/booking/_detail_mails.blade.php b/resources/views/booking/_detail_mails.blade.php index 3f56751..b8fe5ab 100755 --- a/resources/views/booking/_detail_mails.blade.php +++ b/resources/views/booking/_detail_mails.blade.php @@ -71,19 +71,36 @@
{{$booking->countCustomerMailsBy($customer_mail_dir->pos)}}
+ @if($booking->travel_country) - @foreach($booking->travel_country->getMailDirs($customer_mail_dir->pos) as $mail_dir_id) - @php ($mail_dir_name = \App\Services\Booking::getCustomerMailName($customer_mail_dir, $mail_dir_id)) - -
- {{$mail_dir_name}} -
-
{{$booking->countCustomerMailsBy($customer_mail_dir->pos, $mail_dir_id)}}
-
- @endforeach + @php (\App\Services\Booking::setOutputDirs($customer_mail_dir->pos, 0)) + @foreach($booking->travel_country->getMailDirs($customer_mail_dir->pos) as $mail_sdir_id) + @php ($mail_dir_name = \App\Services\Booking::getCustomerMailName($customer_mail_dir, $mail_sdir_id)) + +
+ {{$mail_dir_name}} +
+
{{$booking->countCustomerMailsBy($customer_mail_dir->pos, $mail_sdir_id)}}
+
+ @php (\App\Services\Booking::setOutputDirs($customer_mail_dir->pos, $mail_sdir_id)) + @endforeach + @if($mail_dirs_not_outputs = \App\Services\Booking::getMailDirNotInOutput($booking->id, $customer_mail_dir->pos)) + @foreach($mail_dirs_not_outputs as $mail_sdir_id) + @php ($mail_dir_name = \App\Services\Booking::getCustomerMailName($customer_mail_dir, $mail_sdir_id)) + +
+ {{$mail_dir_name}} +
+
{{$booking->countCustomerMailsBy($customer_mail_dir->pos, $mail_sdir_id)}}
+
+ @php (\App\Services\Booking::setOutputDirs($customer_mail_dir->pos, $mail_sdir_id)) + @endforeach + @endif @endif @endforeach + @foreach($booking::$customer_mail_dirs as $dir_id => $customer_mail_dir) @php($badge = "badge-outline-primary") + @if($booking->participant_firstname) {{ Form::select('participant_salutation_id', \App\Services\Model::getSalutationArray(false) , $booking->participant_salutation_id, array('class'=>'custom-select', 'id'=>'participant_salutation_id')) }} @@ -42,6 +43,7 @@   + @endif @if($booking->participants) @foreach($booking->participants as $item) diff --git a/resources/views/lead/_detail_lead.blade.php b/resources/views/lead/_detail_lead.blade.php index 8c1a0e2..0f17bc5 100644 --- a/resources/views/lead/_detail_lead.blade.php +++ b/resources/views/lead/_detail_lead.blade.php @@ -45,7 +45,7 @@
- {{ Form::select('travelcountry_id', \App\Services\Model::getTravelCountryArray(true) , $lead->travelcountry_id, array('class'=>'custom-select')) }} + {{ Form::select('travelcountry_id', \App\Services\Model::getTravelCountryCRMArray(true) , $lead->travelcountry_id, array('class'=>'custom-select')) }}
diff --git a/resources/views/lead/_detail_mails.blade.php b/resources/views/lead/_detail_mails.blade.php index 1f86c0f..dc6e5af 100644 --- a/resources/views/lead/_detail_mails.blade.php +++ b/resources/views/lead/_detail_mails.blade.php @@ -13,7 +13,7 @@
- - - {{-- TODO load subdirs by pos id - @if($lead_mail->booking->travel_country) - @foreach(\App\Services\Booking::getCustomerMailDirs() as $lead_mail_dir) + @if($lead_mail->lead->travel_country) + @foreach(\App\Services\Lead::getCustomerMailDirs() as $lead_mail_dir) @if($lead_mail_dir->pos > 0) @endif @endforeach @endif - --}}
{!! Form::close() !!} diff --git a/resources/views/settings/emails/index.blade.php b/resources/views/settings/emails/index.blade.php index 337f014..12d010c 100755 --- a/resources/views/settings/emails/index.blade.php +++ b/resources/views/settings/emails/index.blade.php @@ -233,7 +233,7 @@