127 lines
No EOL
4.2 KiB
PHP
127 lines
No EOL
4.2 KiB
PHP
<?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 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;
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $pdf_content;
|
|
}
|
|
} |