Mail Weiterleitung / verlauf / Notizen Buchnungen
This commit is contained in:
parent
f1a1baa913
commit
644ec93c53
47 changed files with 663 additions and 59 deletions
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue