Mail Weiterleitung / verlauf / Notizen Buchnungen
This commit is contained in:
parent
f1a1baa913
commit
644ec93c53
47 changed files with 663 additions and 59 deletions
|
|
@ -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