Fewo Mails / Booking Country Services
This commit is contained in:
parent
b9c26d06d0
commit
48a6eb2282
154 changed files with 7761 additions and 1643 deletions
|
|
@ -9,6 +9,7 @@ use App\Models\Booking;
|
|||
use App\Models\CMSContent;
|
||||
use App\Models\CustomerFile;
|
||||
use App\Models\CustomerMail;
|
||||
use App\Models\EmailTemplate;
|
||||
use App\Services\Placeholder;
|
||||
use App\Services\Util;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
|
@ -98,7 +99,6 @@ class CustomerMailRepository extends BaseRepository {
|
|||
|
||||
public function store($booking, $data, $mail_from, $is_answer = false, $reply_id = NULL, $sent_at=false){
|
||||
|
||||
$data['travel_country_id'] = isset($data['travel_country_id']) && $data['travel_country_id']>0 ? $data['travel_country_id'] : NULL;
|
||||
if(isset($data['save_customer_mail_id'])){
|
||||
$customer_mail = CustomerMail::find($data['save_customer_mail_id']);
|
||||
$customer_mail->fill([
|
||||
|
|
@ -114,7 +114,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
'subject' => $data['subject'],
|
||||
'message' => $data['message'],
|
||||
'dir' => isset($data['dir']) ? $data['dir'] : 0,
|
||||
'travel_country_id' => $data['travel_country_id'],
|
||||
'subdir' => isset($data['subdir']) ? $data['subdir'] : 0,
|
||||
'draft' => $data['draft'],
|
||||
'sent_at' => $sent_at ? $sent_at : now(),
|
||||
])->save();
|
||||
|
|
@ -132,7 +132,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
'subject' => $data['subject'],
|
||||
'message' => $data['message'],
|
||||
'dir' => isset($data['dir']) ? $data['dir'] : 0,
|
||||
'travel_country_id' => $data['travel_country_id'],
|
||||
'subdir' => isset($data['subdir']) ? $data['subdir'] : 0,
|
||||
'draft' => $data['draft'],
|
||||
'sent_at' => $sent_at ? $sent_at : now(),
|
||||
]);
|
||||
|
|
@ -178,36 +178,29 @@ class CustomerMailRepository extends BaseRepository {
|
|||
}
|
||||
|
||||
private static function prepareContactMails($value){
|
||||
|
||||
if(isset($value->customers) && $value->customer_mail_dir > 0){
|
||||
if(isset($value->customers)){ //&& $value->customer_mail_dir !== NULL
|
||||
$first_mail = "";
|
||||
if($value->customer_mail_dir == 1 && $value->customer_mail_country > 0){
|
||||
//Agentur / Land
|
||||
$travel_country = \App\Models\Sym\TravelCountry::find($value->customer_mail_country);
|
||||
if($travel_country && $travel_country->contact_emails && count($travel_country->contact_emails) > 0){
|
||||
$contact_emails = $travel_country->contact_emails;
|
||||
$first_mail = array_shift($contact_emails);
|
||||
if(count($contact_emails) > 0){
|
||||
if($value->customer_mail_dir < 10){ // && $value->customer_mail_subdir > 0
|
||||
$customer_mail_dir = \App\Services\Booking::getCustomerMailDir($value->customer_mail_dir);
|
||||
$contact_emails = \App\Services\Booking::getCustomerMailEmails($customer_mail_dir, $value->customer_mail_subdir);
|
||||
if($value->customer_mail_dir == 0){
|
||||
$value->recipient = Util::_implodeLines($contact_emails);
|
||||
return $value;
|
||||
}else{
|
||||
if($contact_emails && count($contact_emails) > 0) {
|
||||
$first_mail = array_shift($contact_emails);
|
||||
if (count($contact_emails) > 0) {
|
||||
$value->recipient = Util::_implodeLines($contact_emails);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($value->customer_mail_dir == 2){
|
||||
//Airline
|
||||
$airline = Airline::whereName('Xemail')->first();
|
||||
if($airline && $airline->contact_emails && count($airline->contact_emails) > 0){
|
||||
$contact_emails = $airline->contact_emails;
|
||||
$first_mail = array_shift($contact_emails);
|
||||
if(count($contact_emails) > 0){
|
||||
$value->recipient = Util::_implodeLines($contact_emails);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
foreach ($value->customers as $key=>$val){
|
||||
$val['email'] = $first_mail;
|
||||
$value->customers[$key] = $val;
|
||||
}
|
||||
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -222,6 +215,8 @@ class CustomerMailRepository extends BaseRepository {
|
|||
$value->cc = "";
|
||||
$value->bcc = "";
|
||||
$value->lead_title_id = "";
|
||||
$value->filter_email_templates_directories = EmailTemplate::join('email_template_dirs', 'email_template_dir_id', '=', 'email_template_dirs.id')->get()->pluck('name', 'id')->unique()->toArray();
|
||||
|
||||
/*Ansicht*/
|
||||
if ($data['action'] === "show-customer-mail") {
|
||||
if (isset($data['customer_mail_id']) && $customer_mail = CustomerMail::find($data['customer_mail_id'])) {
|
||||
|
|
@ -262,12 +257,14 @@ class CustomerMailRepository extends BaseRepository {
|
|||
if($customer_mail->reply_id){
|
||||
$value->title = "E-Mail Antwort an Kunden senden";
|
||||
$value->subtitle = "Dem Kunden wird eine E-Mail zugesendet, die im System als Antwort gespeichert wird.";
|
||||
$value->customer_mail = $customer_mail;
|
||||
|
||||
}
|
||||
$value->s_placeholder = "Betreff der E-Mail";
|
||||
$value->m_placeholder = "Nachricht der E-Mail";
|
||||
$value->url = $data['url'];
|
||||
$value->customer_mail_dir = $customer_mail->dir ? $customer_mail->dir : 0;
|
||||
$value->customer_mail_country = $customer_mail->travel_country_id ? $customer_mail->travel_country_id : 0;
|
||||
$value->customer_mail_subdir = $customer_mail->subdir ? $customer_mail->subdir : 0;
|
||||
|
||||
return view("customer.mail.modal-new-mail", compact('data', 'value'))->render();
|
||||
|
||||
|
|
@ -307,7 +304,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
}
|
||||
$value->url = $data['url'];
|
||||
$value->customer_mail_dir = isset($data['customer_mail_dir']) ? $data['customer_mail_dir'] : 0;
|
||||
$value->customer_mail_country = isset($data['customer_mail_country']) ? $data['customer_mail_country'] : 0;
|
||||
$value->customer_mail_subdir = isset($data['customer_mail_subdir']) ? $data['customer_mail_subdir'] : 0;
|
||||
|
||||
$value = self::prepareContactMails($value);
|
||||
return view("customer.mail.modal-new-mail", compact('data', 'value'))->render();
|
||||
|
|
@ -337,7 +334,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
$value->url = $data['url'];
|
||||
$value->show = 'reply';
|
||||
$value->customer_mail_dir = isset($data['customer_mail_dir']) ? $data['customer_mail_dir'] : 0;
|
||||
$value->customer_mail_country = isset($data['customer_mail_country']) ? $data['customer_mail_country'] : 0;
|
||||
$value->customer_mail_subdir = isset($data['customer_mail_subdir']) ? $data['customer_mail_subdir'] : 0;
|
||||
|
||||
$value = self::prepareContactMails($value);
|
||||
return view("customer.mail.modal-new-mail", compact('data', 'value'))->render();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue