Mail Weiterleitung / verlauf / Notizen Buchnungen
This commit is contained in:
parent
f1a1baa913
commit
644ec93c53
47 changed files with 663 additions and 59 deletions
|
|
@ -4,6 +4,8 @@ namespace App\Repositories;
|
|||
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingNotice;
|
||||
use Auth;
|
||||
use App\Models\BookingCompanyService;
|
||||
use App\Models\BookingCountryService;
|
||||
use App\Models\BookingProviderService;
|
||||
|
|
@ -21,6 +23,20 @@ class BookingRepository extends BaseRepository {
|
|||
return $this->model;
|
||||
}
|
||||
|
||||
|
||||
public function updateNotice($id, $data){
|
||||
|
||||
$this->model = Booking::findOrFail($id);
|
||||
BookingNotice::create([
|
||||
'booking_id' => $this->model->id,
|
||||
'from_user_id' => Auth::user()->id,
|
||||
'to_user_id' => isset($this->model->sf_guard_user->user_id) ? $this->model->sf_guard_user->user_id : null,
|
||||
'message' => isset($data['booking_notice']) ? $data['booking_notice'] : "",
|
||||
]
|
||||
);
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function updateBooking($id, $data){
|
||||
|
||||
$this->model = Booking::findOrFail($id);
|
||||
|
|
|
|||
|
|
@ -67,6 +67,37 @@ class CustomerFewoMailRepository extends BaseRepository {
|
|||
}
|
||||
}
|
||||
}
|
||||
public function forwardMail($customer_mail, $data){
|
||||
//send or draft
|
||||
//$data['action']
|
||||
if(isset($data['customer_mail_forward_email']) && !empty($data['customer_mail_forward_email'])) {
|
||||
$to_mails = [];
|
||||
if(strpos($data['customer_mail_forward_email'], ',')){
|
||||
$to_mails = array_map('trim', explode(',', $data['customer_mail_forward_email']));
|
||||
}else{
|
||||
$to_mails[] = $data['customer_mail_forward_email'];
|
||||
}
|
||||
$customer_files = $customer_mail->customer_files;
|
||||
$full_message = $this->prepareMessageFull($customer_mail);
|
||||
try {
|
||||
//
|
||||
Mail::to($to_mails)
|
||||
->bcc($customer_mail->bcc ?: [])
|
||||
->send(new MailSendInfo($customer_mail->subject, $full_message, $customer_files));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
// Never reached
|
||||
$forward = array();
|
||||
$forward[now()->format("d.m.Y H:i:s")] = ['fail'=> true, 'to'=> $data['customer_mail_forward_email'], 'error'=>$e->getMessage()];
|
||||
$customer_mail->setForwardMessage($forward);
|
||||
return false;
|
||||
}
|
||||
$forward = array();
|
||||
$forward[now()->format("d.m.Y H:i:s")] = ['sent'=> true, 'to'=> $data['customer_mail_forward_email']];
|
||||
$customer_mail->setForwardMessage($forward);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function replyStore($data){
|
||||
if(isset($data['travel_user_booking_fewo_id']) && $booking_fewo = TravelUserBookingFewo::find($data['travel_user_booking_fewo_id'])) {
|
||||
|
|
@ -149,12 +180,14 @@ class CustomerFewoMailRepository extends BaseRepository {
|
|||
$to_mails = array_merge($to_mails, $customer_mail->recipient);
|
||||
}
|
||||
$customer_files = $customer_mail->customer_files;
|
||||
$full_message = $this->prepareMessageFull($customer_mail);
|
||||
|
||||
try {
|
||||
//
|
||||
Mail::to($to_mails)
|
||||
->cc($customer_mail->cc ?: [])
|
||||
->bcc($customer_mail->bcc ?: [])
|
||||
->send(new MailSendInfo($customer_mail->subject, $customer_mail->message, $customer_files));
|
||||
->send(new MailSendInfo($customer_mail->subject, $full_message, $customer_files));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
// Never reached
|
||||
|
|
@ -168,6 +201,22 @@ class CustomerFewoMailRepository extends BaseRepository {
|
|||
$customer_mail->save();
|
||||
return true;
|
||||
}
|
||||
private function prepareMessageFull($customer_mail, $deep = 0){
|
||||
$ret = "";
|
||||
if($deep === 0){
|
||||
$ret .= $customer_mail->message;
|
||||
}else{
|
||||
$ret .= "--------------------------------\n";
|
||||
$ret .= $customer_mail->is_answer ? "Antwort von: " : "Gesendet an: ";
|
||||
$ret .= "<".$customer_mail->email."> ".$customer_mail->sent_at."\n";
|
||||
$ret .= "<strong>".$customer_mail->subject."</strong>\n";
|
||||
$ret .= $customer_mail->message;
|
||||
}
|
||||
if($customer_mail->customer_mail){
|
||||
$ret .= $this->prepareMessageFull($customer_mail->customer_mail, $deep+1);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function prepareContent($booking_fewo, $content){
|
||||
$content = Placeholder::replaceBookingFewo($booking_fewo, $content);
|
||||
|
|
@ -309,7 +358,7 @@ class CustomerFewoMailRepository extends BaseRepository {
|
|||
$value->draft = false;
|
||||
$value->booking = $booking_fewo;
|
||||
$value->message = "";
|
||||
$value->subject = "";
|
||||
$value->subject = " - (".$value->booking->invoice_number.")";
|
||||
$value->lead_title_id = " - (".$value->booking->invoice_number.")";
|
||||
$value->s_placeholder = "Betreff des Kunden";
|
||||
$value->m_placeholder = "Nachricht des Kunden";
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ class CustomerMailRepository extends BaseRepository {
|
|||
$file->identifier = 'mail';
|
||||
$file->save();
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] === 'send'){ //not at draft
|
||||
$this->sendMail($customer_mail);
|
||||
}
|
||||
|
|
@ -69,6 +68,38 @@ class CustomerMailRepository extends BaseRepository {
|
|||
}
|
||||
}
|
||||
|
||||
public function forwardMail($customer_mail, $data){
|
||||
//send or draft
|
||||
//$data['action']
|
||||
if(isset($data['customer_mail_forward_email']) && !empty($data['customer_mail_forward_email'])) {
|
||||
$to_mails = [];
|
||||
if(strpos($data['customer_mail_forward_email'], ',')){
|
||||
$to_mails = array_map('trim', explode(',', $data['customer_mail_forward_email']));
|
||||
}else{
|
||||
$to_mails[] = $data['customer_mail_forward_email'];
|
||||
}
|
||||
$customer_files = $customer_mail->customer_files;
|
||||
$full_message = $this->prepareMessageFull($customer_mail);
|
||||
try {
|
||||
//
|
||||
Mail::to($to_mails)
|
||||
->bcc($customer_mail->bcc ?: [])
|
||||
->send(new MailSendInfo($customer_mail->subject, $full_message, $customer_files));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
// Never reached
|
||||
$forward = array();
|
||||
$forward[now()->format("d.m.Y H:i:s")] = ['fail'=> true, 'to'=> $data['customer_mail_forward_email'], 'error'=>$e->getMessage()];
|
||||
$customer_mail->setForwardMessage($forward);
|
||||
return false;
|
||||
}
|
||||
$forward = array();
|
||||
$forward[now()->format("d.m.Y H:i:s")] = ['sent'=> true, 'to'=> $data['customer_mail_forward_email']];
|
||||
$customer_mail->setForwardMessage($forward);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function replyStore($data){
|
||||
if(isset($data['booking_id']) && $booking = Booking::find($data['booking_id'])) {
|
||||
//has Attachments
|
||||
|
|
@ -152,12 +183,13 @@ class CustomerMailRepository extends BaseRepository {
|
|||
$to_mails = array_merge($to_mails, $customer_mail->recipient);
|
||||
}
|
||||
$customer_files = $customer_mail->customer_files;
|
||||
$full_message = $this->prepareMessageFull($customer_mail);
|
||||
try {
|
||||
//
|
||||
Mail::to($to_mails)
|
||||
->cc($customer_mail->cc ?: [])
|
||||
->bcc($customer_mail->bcc ?: [])
|
||||
->send(new MailSendInfo($customer_mail->subject, $customer_mail->message, $customer_files));
|
||||
->send(new MailSendInfo($customer_mail->subject, $full_message, $customer_files));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
// Never reached
|
||||
|
|
@ -172,6 +204,23 @@ class CustomerMailRepository extends BaseRepository {
|
|||
return true;
|
||||
}
|
||||
|
||||
private function prepareMessageFull($customer_mail, $deep = 0){
|
||||
$ret = "";
|
||||
if($deep === 0){
|
||||
$ret .= $customer_mail->message;
|
||||
}else{
|
||||
$ret .= "--------------------------------\n";
|
||||
$ret .= $customer_mail->is_answer ? "Antwort von: " : "Gesendet an: ";
|
||||
$ret .= "<".$customer_mail->email."> ".$customer_mail->sent_at."\n";
|
||||
$ret .= "<strong>".$customer_mail->subject."</strong>\n";
|
||||
$ret .= $customer_mail->message;
|
||||
}
|
||||
if($customer_mail->customer_mail){
|
||||
$ret .= $this->prepareMessageFull($customer_mail->customer_mail, $deep+1);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function prepareContent($booking, $content){
|
||||
$content = Placeholder::replaceBooking($booking, $content);
|
||||
return $content;
|
||||
|
|
@ -217,6 +266,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
$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'])) {
|
||||
|
|
@ -315,7 +365,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
$value->draft = false;
|
||||
$value->booking = $booking;
|
||||
$value->message = "";
|
||||
$value->subject = "";
|
||||
$value->subject = " - (".$value->booking->lead_id.")";
|
||||
$value->lead_title_id = " - (".$value->booking->lead_id.")";
|
||||
$value->s_placeholder = "Betreff des Kunden";
|
||||
$value->m_placeholder = "Nachricht des Kunden";
|
||||
|
|
@ -335,6 +385,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
$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