diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 66ccc2d..73e6d19 100755
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Models\BookingNotice;
+use App\Models\LeadNotice;
use App\Models\SfGuardUser;
use App\Models\TravelUserBookingFewoNotice;
use App\User;
@@ -45,10 +46,14 @@ class HomeController extends Controller
$last_booking_notices = BookingNotice::orderBy('edit_at', 'DESC')->orderBy('created_at', 'DESC')->limit(10)->get();
$last_booking_fewo_notices = TravelUserBookingFewoNotice::orderBy('edit_at', 'DESC')->orderBy('created_at', 'DESC')->limit(10)->get();
+ $last_lead_notices = LeadNotice::orderBy('edit_at', 'DESC')->orderBy('created_at', 'DESC')->limit(10)->get();
+
+
$data = [
'user' => Auth::user(),
'last_booking_notices' => $last_booking_notices,
- 'last_booking_fewo_notices' => $last_booking_fewo_notices
+ 'last_booking_fewo_notices' => $last_booking_fewo_notices,
+ 'last_lead_notices' => $last_lead_notices
];
return view('home', $data);
}
diff --git a/app/Http/Controllers/LeadController.php b/app/Http/Controllers/LeadController.php
index 0539f5b..bf71e3d 100755
--- a/app/Http/Controllers/LeadController.php
+++ b/app/Http/Controllers/LeadController.php
@@ -7,6 +7,7 @@ use Request;
use App\Models\Lead;
use App\Models\LeadFile;
use App\Models\LeadNotice;
+use App\Models\StatusHistory;
use App\Repositories\LeadRepository;
use App\Repositories\CustomerRepository;
use App\Repositories\LeadFileRepository;
@@ -88,6 +89,26 @@ class LeadController extends Controller
return back();
}
+ public function getAjaxRequests(){
+
+ $data = Request::all();
+ if(Request::ajax()) {
+ if(isset($data['action']) && $data['action'] === "get_popover_lead_notice"){
+ $lead = Lead::findOrFail($data['lead_id']);
+ $ret = "";
+
+ if($lead->lead_notices->count()){
+ $lead_notice = $lead->lead_notices->first();
+ return $lead_notice->getSmallerMessage(500);
+ }
+ if($ret === ""){
+ return 'keine Notiz';
+ }
+ return $ret;
+ }
+ }
+ }
+
public function loadModal(){
$data = Request::all();
$ret = "";
@@ -100,12 +121,10 @@ class LeadController extends Controller
return response()->json(['response' => $data, 'html'=>$ret]);
}
- public function delete($id, $del="lead"){
+ public function delete($id, $del=false){
if($del === 'lead') {
$lead = Lead::findOrFail($id);
- dump($lead);
- dd('TODO check delete');
//Files
$leadFiles = LeadFile::where('lead_id', $lead->id)->get();
foreach ($leadFiles as $leadFile) {
@@ -114,12 +133,16 @@ class LeadController extends Controller
$fileRepo->delete();
$leadFile->delete();
}
+ //history
+ $leadHistories = StatusHistory::where('lead_id', $lead->id)->get();
+ foreach ($leadHistories as $leadHistory) {
+ $leadHistory->delete();
+ }
//Mails Files CASCADE
$lead->delete();
\Session()->flash('alert-success', __('Anfrage gelöscht'));
}
-
if($del === 'lead_notice'){
$leadNotice = LeadNotice::findOrFail($id);
$lead = $leadNotice->lead;
@@ -160,7 +183,22 @@ class LeadController extends Controller
})
->addColumn('status', function (Lead $lead) {
//umbuchen
- return $lead->getStatusBadge();
+ return $lead->getStatusBadge();
+ })
+ ->addColumn('lead_notice', function (Lead $lead) {
+ return $lead->lead_notices->count() ? '' :
+ '';
+ })
+ ->addColumn('last_lead_email', function (Lead $lead) {
+ //umbuchen
+ if($lead->lead_mails->count()){
+ $lead_mail = $lead->lead_mails_sent_at->last();
+ return ''.$lead_mail->sent_at.'';
+ }
+ return '-';
+ })
+ ->addColumn('action_delete', function (Lead $lead) {
+ return '';
})
->orderColumn('id', 'id $1')
->orderColumn('customer_id', 'customer_id $1')
@@ -176,7 +214,7 @@ class LeadController extends Controller
$query->where('customer_id', 'LIKE', '%'.$keyword.'%');
}
})
- ->rawColumns(['action_edit', 'customer_id', 'sf_guard_user_id', 'id', 'status'])
+ ->rawColumns(['action_edit', 'customer_id', 'sf_guard_user_id', 'id', 'status', 'last_lead_email', 'lead_notice', 'action_delete'])
->make(true);
}
diff --git a/app/Http/Controllers/LeadMailController.php b/app/Http/Controllers/LeadMailController.php
index 96b94d9..8eece0c 100644
--- a/app/Http/Controllers/LeadMailController.php
+++ b/app/Http/Controllers/LeadMailController.php
@@ -5,14 +5,14 @@ namespace App\Http\Controllers;
use Carbon;
use Request;
use Response;
+use App\Models\Lead;
use App\Services\Util;
use App\Models\LeadFile;
+use App\Models\LeadMail;
+
use App\Models\EmailTemplate;
-use App\Models\CustomerFewoFile;
-use App\Models\CustomerFewoMail;
use Illuminate\Support\Facades\URL;
use App\Models\TravelUserBookingFewo;
-use App\Models\TravelUserBookingFile;
use App\Repositories\LeadFileRepository;
use App\Repositories\LeadMailRepository;
use Illuminate\Database\Eloquent\Collection;
@@ -23,15 +23,15 @@ use App\Repositories\CustomerFewoMailRepository;
class LeadMailController extends Controller
{
- protected $customerMailRepo;
+ protected $leadMailRepo;
- public function __construct(LeadMailRepository $customerMailRepo)
+ public function __construct(LeadMailRepository $leadMailRepo)
{
$this->middleware('admin');
- $this->customerMailRepo = $customerMailRepo;
+ $this->leadMailRepo = $leadMailRepo;
}
- /* public function index()
+ /*public function index()
{
$data = [
@@ -42,48 +42,59 @@ class LeadMailController extends Controller
public function detail($id)
{
if($id === "new") {
- $customer_mail = new CustomerFewoMail();
+ $lead_mail = new LeadMail();
$id = 'new';
}else{
- $customer_mail = CustomerFewoMail::findOrFail($id);
- $id = $customer_mail->id;
+ $lead_mail = LeadMail::findOrFail($id);
+ $id = $lead_mail->id;
}
$data = [
- 'customer_mail' => $customer_mail,
+ 'lead_mail' => $lead_mail,
'id' => $id,
'back' => URL::previous(),
];
return view('customer.mail.detail', $data);
- }
+ }*/
public function store($id, $action=false)
{
$data = Request::all();
- $customer_mail = CustomerFewoMail::findOrFail($id);
+ $lead_mail = LeadMail::findOrFail($id);
- if($action === 'move-mail'){
+
+ if($action === 'move-mail-lead'){
+ $lead_mail = LeadMail::findOrFail($id);
$data['subdir'] = isset($data['subdir']) && $data['subdir'] ? $data['subdir'] : null;
- $customer_mail->dir = $data['dir'];
- $customer_mail->subdir = $data['subdir'];
- $customer_mail->save();
+ $lead_mail->dir = $data['dir'];
+ $lead_mail->subdir = $data['subdir'];
+ $lead_mail->save();
+ }
+
+ if($action === 'forward-mail-lead'){
+ $lead_mail = LeadMail::findOrFail($id);
+ $customerMailFewoRepo = new LeadMailRepository($lead_mail);
+ $customerMailFewoRepo->forwardMail($lead_mail, $data);
+ \Session()->flash('alert-success', __('E-Mail weitergeleitet'));
}
+
+
return back();
}
public function delete($id){
- $customer_mail = CustomerFewoMail::find($id);
- $customer_mail->dir = 12;
- $customer_mail->subdir = 0;
- $customer_mail->save();
+ $lead_mail = LeadMail::find($id);
+ $lead_mail->dir = 12;
+ $lead_mail->subdir = 0;
+ $lead_mail->save();
\Session()->flash('alert-success', __('Mail gelöscht'));
return back();
- }*/
+ }
public function loadModal(){
@@ -91,17 +102,16 @@ class LeadMailController extends Controller
$ret = "";
if(Request::ajax()) {
- /* if ($data['action'] === "new-customer-mail" || $data['action'] === "reply-customer-mail" || $data['action'] === "show-customer-mail" || $data['action'] === "edit-customer-mail"){
+ if ($data['action'] === "new-lead-mail" || $data['action'] === "reply-lead-mail" || $data['action'] === "show-lead-mail" || $data['action'] === "edit-lead-mail"){
$data['customers'] = [];
- if ($data['action'] === "new-customer-mail" && isset($data['travel_user_booking_fewo_id']) && $TravelUserBookingFewo = TravelUserBookingFewo::find($data['travel_user_booking_fewo_id'])) {
+ if ($data['action'] === "new-lead-mail" && isset($data['lead_id']) && $lead = Lead::find($data['lead_id'])) {
$tmp = [];
- $tmp['email'] = $TravelUserBookingFewo->travel_user ? $TravelUserBookingFewo->travel_user->email : "";
- $tmp['name'] = $TravelUserBookingFewo->travel_user ? $TravelUserBookingFewo->travel_user->first_name . " " . $TravelUserBookingFewo->travel_user->last_name . " | " : "- | ";
- $tmp['name'] .= $TravelUserBookingFewo->fewo_lodging_id ? $TravelUserBookingFewo->fewo_lodging->name . " | " : "- | ";
- $data['customers'][$TravelUserBookingFewo->id] = $tmp;
+ $tmp['email'] = $lead->customer ? $lead->customer->email : "";
+ $tmp['name'] = $lead->customer ? $lead->customer->firstname . " " . $lead->customer->name . " | " : "- | ";
+ $data['customers'][$lead->id] = $tmp;
}
- $ret = CustomerFewoMailRepository::loadModal($data);
- }*/
+ $ret = LeadMailRepository::loadModal($data);
+ }
if($data['action'] === "modal-upload-lead-file") {
$ret = view("lead.upload_modal", compact('data'))->render();
@@ -122,9 +132,9 @@ class LeadMailController extends Controller
}
- public function sendMail(CustomerFewoMailRepository $customerFewoMailRepository){
+ public function sendMail(LeadMailRepository $leadMailRepository){
$data = Request::all();
- $customerFewoMailRepository->sendAndStore($data);
+ $leadMailRepository->sendAndStore($data);
if($data['action'] == 'draft'){
\Session()->flash('alert-success', "Entwurf gespeichert!");
}else{
@@ -133,62 +143,14 @@ class LeadMailController extends Controller
return back();
}
- public function replyMail(CustomerFewoMailRepository $customerFewoMailRepository){
+ public function replyMail(LeadMailRepository $LeadMailRepository){
$data = Request::all();
- $customerFewoMailRepository->replyStore($data);
+ $LeadMailRepository->replyStore($data);
\Session()->flash('alert-success', "Mail gespeichert!");
return back();
}
- /*public function getCustomerFewoMails()
- {
- $query = CustomerFewoMail::with('booking')->with('customer')->select('customer_mails.*');
-
- return \DataTables::eloquent($query)
- ->addColumn('action_edit', function (CustomerFewoMail $customer_mail) {
- return '';
- })
- ->addColumn('id', function (CustomerFewoMail $customer_mail) {
- return ''.$customer_mail->id.'';
- })
- ->addColumn('booking', function (CustomerFewoMail $customer_mail) {
- $out = $customer_mail->booking->travel_country_id ? $customer_mail->booking->travel_country->name." | " : "- | ";
- $out .= $customer_mail->booking->travelagenda_id ? $customer_mail->booking->travel_agenda->name."" : "-";
- return $out;
- })
- ->addColumn('travel_user_booking_fewo_id', function (CustomerFewoMail $customer_mail) {
- return ''.$customer_mail->travel_user_booking_fewo_id.'';
- })
- ->addColumn('customer_id', function (CustomerFewoMail $customer_mail) {
- return ''.$customer_mail->customer_id.'';
- })
- ->addColumn('send', function (CustomerFewoMail $customer_mail) {
- return $customer_mail->send ? '' : '';
- })
- ->orderColumn('id', 'id $1')
- ->orderColumn('travel_user_booking_fewo_id', 'travel_user_booking_fewo_id $1')
- ->orderColumn('customer_id', 'customer_id $1')
- ->orderColumn('send', 'send $1')
-
- ->filterColumn('id', function($query, $keyword) {
- if($keyword != ""){
- $query->where('id', 'LIKE', '%'.$keyword.'%');
- }
- })
- ->filterColumn('customer_id', function($query, $keyword) {
- if($keyword != ""){
- $query->where('customer_id', 'LIKE', '%'.$keyword.'%');
- }
- })
- ->filterColumn('travel_user_booking_fewo_id', function($query, $keyword) {
- if($keyword != ""){
- $query->where('travel_user_booking_fewo_id', 'LIKE', '%'.$keyword.'%');
- }
- })
- ->rawColumns(['action_edit', 'send', 'customer_id', 'travel_user_booking_fewo_id', 'id'])
- ->make(true);
- }*/
-
+
public function getEmailTemplates()
{
$query = EmailTemplate::with('email_template_dir')->select('email_templates.*')->where('active', '=', true);
@@ -230,12 +192,12 @@ class LeadMailController extends Controller
public function uploadAttachment($id){
- $fileRepo = new CustomerFewoFileRepository(new CustomerFewoFile());
+ $fileRepo = new LeadFileRepository(new LeadFile());
if($id === 'tmp'){
- $fileRepo->_set('disk', 'travel_user');
+ $fileRepo->_set('disk', 'lead');
$fileRepo->_set('dir', '/attachment/'.date('Y/m').'/');
- $fileRepo->_set('travel_user_id', NULL);
- $fileRepo->_set('customer_fewo_mail_id', NULL);
+ $fileRepo->_set('lead_id', NULL);
+ $fileRepo->_set('lead_mail_id', NULL);
$fileRepo->_set('identifier', 'tmp');
return $fileRepo->uploadFile(Request::all());
}
@@ -252,9 +214,9 @@ class LeadMailController extends Controller
$status = false;
if(Request::ajax()){
if($data['action'] === 'toggle_important'){
- $customer_mail = CustomerFewoMail::find($data['id']);
- $customer_mail->important = ($customer_mail->important ? false : true);
- $customer_mail->save();
+ $lead_mail = LeadMail::find($data['id']);
+ $lead_mail->important = ($lead_mail->important ? false : true);
+ $lead_mail->save();
$status = 'success';
}
if($data['action'] === 'load_email_template'){
@@ -264,9 +226,9 @@ class LeadMailController extends Controller
$status = 'success';
}
if($data['action'] === 'delete_mail_attachment'){
- $customer_file = CustomerFewoFile::find($data['id']);
- $fileRepo = new CustomerFewoFileRepository($customer_file);
- $fileRepo->_set('disk', 'travel_user');
+ $lead_file = LeadFile::find($data['id']);
+ $fileRepo = new LeadFileRepository($lead_file);
+ $fileRepo->_set('disk', 'lead');
$ret = $fileRepo->delete();
$status = 'success';
}
@@ -281,11 +243,11 @@ class LeadMailController extends Controller
$contents = file_get_contents($data['target'], false, stream_context_create($arrContextOptions));
$mine = Util::getMimeFromHeader($http_response_header);
$extension = Util::getExtensionFromMime($mine);
- $fileRepo = new CustomerFewoFileRepository(new CustomerFewoFile());
- $fileRepo->_set('disk', 'travel_user');
+ $fileRepo = new LeadFileRepository(new LeadFile());
+ $fileRepo->_set('disk', 'lead');
$fileRepo->_set('dir', '/attachment/'.date('Y/m').'/');
- $fileRepo->_set('travel_user_id', NULL);
- $fileRepo->_set('customer_fewo_mail_id', NULL);
+ $fileRepo->_set('lead_id', NULL);
+ $fileRepo->_set('lead_mail_id', NULL);
$fileRepo->_set('identifier', 'tmp');
$fileRepo->_set('originalName', $data['name']);
$fileRepo->_set('mine', $mine);
@@ -298,17 +260,17 @@ class LeadMailController extends Controller
private function getSearchRequests()
{
- if (!Request::get('travel_user_booking_fewo_id')) {
+ if (!Request::get('lead_id')) {
return false;
}
- $query = CustomerFewoMail::where('travel_user_booking_fewo_id', '=', Request::get('travel_user_booking_fewo_id'));
- if (Request::get('customer_mail_dir') == 11) { //draft
+ $query = LeadMail::where('lead_id', '=', Request::get('lead_id'));
+ if (Request::get('lead_mail_dir') == 11) { //draft
$query->where('draft', '=', true)->where('dir', '!=', 12);
}else{
- $query->where('dir', '=', Request::get('customer_mail_dir')); //with('lead'
+ $query->where('dir', '=', Request::get('lead_mail_dir')); //with('lead'
}
- if (Request::get('customer_mail_subdir')) {
- $query->where('subdir', '=', Request::get('customer_mail_subdir'));
+ if (Request::get('lead_mail_subdir')) {
+ $query->where('subdir', '=', Request::get('lead_mail_subdir'));
}
return $query;
}
@@ -317,7 +279,7 @@ class LeadMailController extends Controller
$query = $this->getSearchRequests();
return \DataTables::eloquent($query)
- ->addColumn('checkbox', function (CustomerFewoMail $customer_mail) {
+ ->addColumn('checkbox', function (LeadMail $lead_mail) {
return '
';
})
- ->addColumn('important', function (CustomerFewoMail $customer_mail) {
- $icon = ($customer_mail->important ? 'ion-md-star' : 'ion-md-star-outline');
+ ->addColumn('important', function (LeadMail $lead_mail) {
+ $icon = ($lead_mail->important ? 'ion-md-star' : 'ion-md-star-outline');
return '';
+ data-url="'.route('lead_mail_ajax').'" data-id="'.$lead_mail->id.'" data-important="'.$lead_mail->important.'" data-action="toggle_important">';
})
- ->addColumn('subject', function (CustomerFewoMail $customer_mail) {
+ ->addColumn('subject', function (LeadMail $lead_mail) {
- $icon = $customer_mail->reply_id ? 'ion-ios-redo' : 'ion-ios-mail';
- $badge = $customer_mail->is_answer ? 'badge-next' : 'badge-secondary';
- $badge = $customer_mail->draft ? 'badge-default' : $badge;
- $to_icon = $customer_mail->draft ? '' : '';
- $action = $customer_mail->draft ? 'edit-customer-mail' : 'show-customer-mail';
- $id = $customer_mail->draft ? $customer_mail->id : 'new';
- $url = $customer_mail->draft ? route('customer_fewo_mail_send_mail') : '';
+ $icon = $lead_mail->reply_id ? 'ion-ios-redo' : 'ion-ios-mail';
+ $badge = $lead_mail->is_answer ? 'badge-next' : 'badge-secondary';
+ $badge = $lead_mail->draft ? 'badge-default' : $badge;
+ $to_icon = $lead_mail->draft ? '' : '';
+ $action = $lead_mail->draft ? 'edit-lead-mail' : 'show-lead-mail';
+ $id = $lead_mail->draft ? $lead_mail->id : 'new';
+ $url = $lead_mail->draft ? route('lead_mail_send_mail') : '';
return '
- '.$to_icon.''.$customer_mail->subject.'
- '.($customer_mail->customer_fewo_files->count() ? ' '.$customer_mail->customer_fewo_files->count().'' : '');
+ data-lead_mail_id="'.$lead_mail->id.'" data-route="'.route('lead_mail_modal_load').'">
+ '.$to_icon.''.$lead_mail->subject.'
+ '.($lead_mail->lead_files->count() ? ' '.$lead_mail->lead_files->count().'' : '');
})
- ->addColumn('date', function (CustomerFewoMail $customer_mail) {
- if($customer_mail->send){
- return ' '.$customer_mail->sent_at.'';
+ ->addColumn('date', function (LeadMail $lead_mail) {
+ if($lead_mail->send){
+ return ' '.$lead_mail->sent_at.'';
}
- return ' '.$customer_mail->sent_at.'';
+ return ' '.$lead_mail->sent_at.'';
})
- ->addColumn('action', function (CustomerFewoMail $customer_mail) {
+ ->addColumn('action', function (LeadMail $lead_mail) {
$ret = '';
- if(!$customer_mail->draft){
+ if(!$lead_mail->draft){
$ret = '
+ data-target="#modals-load-content" data-id="reply-send" data-model="LeadMail" data-action="new-lead-mail"
+ data-url="'.route('lead_mail_send_mail').'" data-redirect="back" data-lead_mail_id="'.$lead_mail->id.'"
+ data-lead_id="'.$lead_mail->lead_id.'" data-route="'.route('lead_mail_modal_load').'" data-lead_mail_dir="'.$lead_mail->dir.'" data-customer_subdir="'.$lead_mail->subdir.'">
+ data-target="#modals-load-content" data-id="reply-save" data-model="LeadMail" data-action="reply-lead-mail"
+ data-url="'.route('lead_mail_reply_mail').'" data-redirect="back" data-lead_mail_id="'.$lead_mail->id.'"
+ data-lead_id="'.$lead_mail->lead_id.'" data-route="'.route('lead_mail_modal_load').'" data-lead_mail_dir="'.$lead_mail->dir.'" data-lead_mail_subdir="'.$lead_mail->subdir.'">
';
}
- $ret .= '';
+ $ret .= '';
return ''.$ret.'
';
})
diff --git a/app/Http/Controllers/TravelUserBookingFewoController.php b/app/Http/Controllers/TravelUserBookingFewoController.php
index a764da6..471b1d9 100755
--- a/app/Http/Controllers/TravelUserBookingFewoController.php
+++ b/app/Http/Controllers/TravelUserBookingFewoController.php
@@ -195,6 +195,26 @@ class TravelUserBookingFewoController extends Controller
}
}
}
+
+
+ public function getAjaxRequests(){
+
+ $data = Request::all();
+ if(Request::ajax()) {
+ if(isset($data['action']) && $data['action'] === "get_popover_fewo_notice"){
+ $TravelUserBookingFewo = TravelUserBookingFewo::findOrFail($data['travel_user_booking_fewo_id']);
+ $ret = "";
+ if($TravelUserBookingFewo->booking_fewo_notices->count()){
+ $booking_fewo_notice = $TravelUserBookingFewo->booking_fewo_notices->first();
+ return $booking_fewo_notice->getSmallerMessage(500);
+ }
+ if($ret === ""){
+ return 'keine Notiz';
+ }
+ return $ret;
+ }
+ }
+ }
public function loadModal(){
$data = Request::all();
@@ -296,6 +316,10 @@ class TravelUserBookingFewoController extends Controller
$back .= "";
return $back;
})
+ ->addColumn('booking_fewo_notice', function (TravelUserBookingFewo $travel_user_booking_fewo) {
+ return $travel_user_booking_fewo->booking_fewo_notices->count() ? '' :
+ '';
+ })
->addColumn('action_delete', function (TravelUserBookingFewo $travel_user_booking_fewo) {
return '';
})
@@ -307,7 +331,7 @@ class TravelUserBookingFewoController extends Controller
});
}
})
- ->rawColumns(['action_edit', 'travel_user', 'is_calendar', 'is_mail', 'action_delete'])
+ ->rawColumns(['action_edit', 'travel_user', 'is_calendar', 'is_mail', 'booking_fewo_notice', 'action_delete'])
->make(true);
}
}
diff --git a/app/Models/Customer.php b/app/Models/Customer.php
index 6581652..c2e5e77 100644
--- a/app/Models/Customer.php
+++ b/app/Models/Customer.php
@@ -153,6 +153,11 @@ class Customer extends Model
{
return $this->hasMany(Lead::class);
}
+
+ public function getSalutation(){
+ return $this->salutation_id == 1 ? 'Herr' : 'Frau';
+ }
+
public function fullName()
{
if ($this->firstname) {
diff --git a/app/Models/Lead.php b/app/Models/Lead.php
index a81e2d3..77cfd99 100644
--- a/app/Models/Lead.php
+++ b/app/Models/Lead.php
@@ -154,6 +154,11 @@ class Lead extends Model
'participant_salutation_id'
];
+ public static $lead_mail_dirs = [
+ 11 => ['name' => 'Entwürfe', 'icon'=>'ion-md-create'],
+ 12 => ['name' => 'Papierkorb', 'icon'=>'ion-md-trash'],
+ ];
+
public function updateNextDueDate($date = false){
if(!$date){
@@ -325,4 +330,14 @@ class Lead extends Model
}
return '-';
}
+
+ public function countLeadMailsBy($dir, $subdir=false){
+ if($dir === 11){
+ return $this->lead_mails->where('draft', true)->where('dir', '!=', 12)->count();
+ }
+ if($subdir){
+ return $this->lead_mails->where('dir', $dir)->where('subdir', $subdir)->count();
+ }
+ return $this->lead_mails->where('dir', $dir)->count();
+ }
}
diff --git a/app/Models/LeadMail.php b/app/Models/LeadMail.php
index 4147930..9a7a87d 100644
--- a/app/Models/LeadMail.php
+++ b/app/Models/LeadMail.php
@@ -102,13 +102,37 @@ class LeadMail extends Model
return $this->belongsTo(Lead::class);
}
- public function customer_mail()
+ public function lead_mail()
{
- return $this->belongsTo(CustomerMail::class, 'reply_id');
+ return $this->belongsTo(LeadMail::class, 'reply_id');
}
public function lead_files()
{
return $this->hasMany(LeadFile::class);
}
+ public function getSentAtRaw(){
+ return $this->attributes['sent_at'];
+ }
+
+ public function getSentAtAttribute(){
+ if(!$this->attributes['sent_at']){ return ""; }
+ return Carbon::parse($this->attributes['sent_at'])->format(\Util::formatDateTimeDB());
+ }
+
+ public function getCreatedAtAttribute(){
+ if(!$this->attributes['created_at']){ return ""; }
+ return Carbon::parse($this->attributes['created_at'])->format(\Util::formatDateTimeDB());
+ }
+ public function setForwardMessage($forward = [])
+ {
+ if($forward && is_array($forward)){
+ if(isset($this->forward) && $this->forward){
+ $this->forward = array_merge($this->forward , $forward);
+ }else{
+ $this->forward = $forward;
+ }
+ $this->save();
+ }
+ }
}
diff --git a/app/Repositories/LeadFileRepository.php b/app/Repositories/LeadFileRepository.php
index 54623fc..92a9c32 100644
--- a/app/Repositories/LeadFileRepository.php
+++ b/app/Repositories/LeadFileRepository.php
@@ -9,16 +9,20 @@ class LeadFileRepository extends FileRepository {
protected $lead_file;
protected $lead_id;
+ protected $lead_mail_id;
protected $identifier;
public function __construct(LeadFile $model){
parent::__construct();
$this->model = $model;
+ $this->lead_mail_id = null;
+
}
public function save(){
$this->lead_file = LeadFile::create([
'lead_id' => $this->lead_id,
+ 'lead_mail_id' => $this->lead_mail_id,
'identifier' => $this->identifier,
'filename' => $this->allowed_filename,
'dir' => $this->dir,
diff --git a/app/Repositories/LeadMailRepository.php b/app/Repositories/LeadMailRepository.php
index 4cdbb40..2d65282 100644
--- a/app/Repositories/LeadMailRepository.php
+++ b/app/Repositories/LeadMailRepository.php
@@ -3,22 +3,22 @@
namespace App\Repositories;
+use App\Services\Util;
+use App\Models\LeadMail;
use App\Mail\MailSendInfo;
use App\Models\CMSContent;
-use App\Models\CustomerFewoFile;
-use App\Models\CustomerFewoMail;
use App\Models\EmailTemplate;
-use App\Models\TravelUserBookingFewo;
use App\Services\Placeholder;
-use App\Services\Util;
-use Illuminate\Database\Eloquent\Collection;
+use App\Models\LeadFile;
use Illuminate\Support\Facades\Mail;
+use App\Models\Lead;
+use Illuminate\Database\Eloquent\Collection;
class LeadMailRepository extends BaseRepository {
- public function __construct(CustomerFewoMail $model)
+ public function __construct(LeadMail $model)
{
$this->model = $model;
}
@@ -33,92 +33,92 @@ class LeadMailRepository extends BaseRepository {
//$data['action']
if(isset($data['send_mail_to']) && is_array($data['send_mail_to'])) {
//has Attachments
- $customer_files = [];
+ $lead_files = [];
if(isset($data['message_attachment_id']) && is_array($data['message_attachment_id'])){
foreach ($data['message_attachment_id'] as $message_attachment_id){
- if($CustomerFile = CustomerFewoFile::find($message_attachment_id)){
- $customer_files[] = $CustomerFile;
+ if($LeadFile = LeadFile::find($message_attachment_id)){
+ $lead_files[] = $LeadFile;
}
}
}
- foreach ($data['send_mail_to'] as $booking_fewo_id => $on) {
- $booking_fewo = TravelUserBookingFewo::find($booking_fewo_id);
- if ($booking_fewo->travel_user) {
+ foreach ($data['send_mail_to'] as $lead_id => $on) {
+ $lead = Lead::find($lead_id);
+ if ($lead->customer) {
$data['draft'] = (isset($data['action']) && $data['action'] === 'draft' ? true : false);
if(!$data['draft']){
- $data['message'] = $this->prepareContent($booking_fewo, $data['message']);
- $data['subject'] = $this->prepareContent($booking_fewo, $data['subject']);
+ $data['message'] = $this->prepareContent($lead, $data['message']);
+ $data['subject'] = $this->prepareContent($lead, $data['subject']);
}
- $reply_id = isset($data['customer_mail_id']) ? $data['customer_mail_id'] : NULL;
- $email = isset($data['send_mail_to_mail'][$booking_fewo_id]) ? $data['send_mail_to_mail'][$booking_fewo_id] : $booking_fewo->travel_user->email;
- $customer_mail = $this->store($booking_fewo, $data, $email, false, $reply_id);
- foreach ($customer_files as $file) {
- $file->travel_user_id = $booking_fewo->travel_user_id;
- $file->customer_fewo_mail_id = $customer_mail->id;
+ $reply_id = isset($data['lead_mail_id']) ? $data['lead_mail_id'] : NULL;
+ $email = isset($data['send_mail_to_mail'][$lead_id]) ? $data['send_mail_to_mail'][$lead_id] : $lead->customer->email;
+ $lead_mail = $this->store($lead, $data, $email, false, $reply_id);
+ foreach ($lead_files as $file) {
+ $file->lead_id = $lead->id;
+ $file->lead_mail_id = $lead_mail->id;
$file->identifier = 'mail';
$file->save();
}
if(isset($data['action']) && $data['action'] === 'send'){ //not at draft
- $this->sendMail($customer_mail);
+ $this->sendMail($lead_mail);
}
}
}
}
}
- public function forwardMail($customer_mail, $data){
+ public function forwardMail($lead_mail, $data){
//send or draft
//$data['action']
- if(isset($data['customer_mail_forward_email']) && !empty($data['customer_mail_forward_email'])) {
+ if(isset($data['lead_mail_forward_email']) && !empty($data['lead_mail_forward_email'])) {
$to_mails = [];
- if(strpos($data['customer_mail_forward_email'], ',')){
- $to_mails = array_map('trim', explode(',', $data['customer_mail_forward_email']));
+ if(strpos($data['lead_mail_forward_email'], ',')){
+ $to_mails = array_map('trim', explode(',', $data['lead_mail_forward_email']));
}else{
- $to_mails[] = $data['customer_mail_forward_email'];
+ $to_mails[] = $data['lead_mail_forward_email'];
}
- $customer_files = $customer_mail->customer_files;
- $full_message = $this->prepareMessageFull($customer_mail);
+ $lead_files = $lead_mail->lead_files;
+ $full_message = $this->prepareMessageFull($lead_mail);
try {
//
Mail::to($to_mails)
- ->bcc($customer_mail->bcc ?: [])
- ->send(new MailSendInfo($customer_mail->subject, $full_message, $customer_files));
+ ->bcc($lead_mail->bcc ?: [])
+ ->send(new MailSendInfo($lead_mail->subject, $full_message, $lead_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);
+ $forward[now()->format("d.m.Y H:i:s")] = ['fail'=> true, 'to'=> $data['lead_mail_forward_email'], 'error'=>$e->getMessage()];
+ $lead_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);
+ $forward[now()->format("d.m.Y H:i:s")] = ['sent'=> true, 'to'=> $data['lead_mail_forward_email']];
+ $lead_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'])) {
+ if(isset($data['lead_id']) && $lead = Lead::find($data['lead_id'])) {
//has Attachments
- $customer_files = [];
+ $lead_files = [];
if(isset($data['message_attachment_id']) && is_array($data['message_attachment_id'])){
foreach ($data['message_attachment_id'] as $message_attachment_id){
- if($CustomerFile = CustomerFewoFile::find($message_attachment_id)){
- $customer_files[] = $CustomerFile;
+ if($LeadFile = LeadFile::find($message_attachment_id)){
+ $lead_files[] = $LeadFile;
}
}
}
- if ($booking_fewo->travel_user) {
+ if ($lead->customer) {
$data['draft'] = (isset($data['action']) && $data['action'] === 'draft' ? true : false);
- $mail_from = isset($data['mail_from']) ? $data['mail_from'] : $booking_fewo->travel_user->email;
+ $mail_from = isset($data['mail_from']) ? $data['mail_from'] : $lead->travel_user->email;
$sent_at = isset($data['sent_at']) ? \Carbon::parse(str_replace("- ", "", $data['sent_at'])) : now();
- $reply_id = isset($data['customer_mail_id']) ? $data['customer_mail_id'] : NULL;
- $customer_mail = $this->store($booking_fewo, $data, $mail_from, true, $reply_id, $sent_at);
- foreach ($customer_files as $file) {
- $file->travel_user_id = $booking_fewo->travel_user_id;
- $file->customer_fewo_mail_id = $customer_mail->id;
+ $reply_id = isset($data['lead_mail_id']) ? $data['lead_mail_id'] : NULL;
+ $lead_mail = $this->store($lead, $data, $mail_from, true, $reply_id, $sent_at);
+ foreach ($lead_files as $file) {
+ $file->lead_id = $lead->id;
+ $file->lead_mail_id = $lead_mail->id;
$file->identifier = 'mail';
$file->save();
}
@@ -127,13 +127,13 @@ class LeadMailRepository extends BaseRepository {
}
}
- public function store($booking_fewo, $data, $mail_from, $is_answer = false, $reply_id = NULL, $sent_at=false){
+ public function store($lead, $data, $mail_from, $is_answer = false, $reply_id = NULL, $sent_at=false){
- if(isset($data['save_customer_mail_id'])){
- $customer_mail = CustomerFewoMail::find($data['save_customer_mail_id']);
- $customer_mail->fill([
- 'travel_user_booking_fewo_id' => $booking_fewo->id,
- 'travel_user_id' => $booking_fewo->travel_user_id,
+ if(isset($data['save_lead_mail_id'])){
+ $lead_mail = LeadMail::find($data['save_lead_mail_id']);
+ $lead_mail->fill([
+ 'lead_id' => $lead->id,
+ 'customer_id' => $lead->customer_id,
'is_answer' => $is_answer,
'reply_id' => $reply_id,
'email' => $mail_from,
@@ -148,9 +148,9 @@ class LeadMailRepository extends BaseRepository {
'sent_at' => $sent_at ? $sent_at : now(),
])->save();
}else{
- $customer_mail = CustomerFewoMail::create([
- 'travel_user_booking_fewo_id' => $booking_fewo->id,
- 'travel_user_id' => $booking_fewo->travel_user_id,
+ $lead_mail = LeadMail::create([
+ 'lead_id' => $lead->id,
+ 'customer_id' => $lead->customer_id,
'is_answer' => $is_answer,
'reply_id' => $reply_id,
'email' => $mail_from,
@@ -166,70 +166,70 @@ class LeadMailRepository extends BaseRepository {
]);
}
- return $customer_mail;
+ return $lead_mail;
}
- private function sendMail($customer_mail){
+ private function sendMail($lead_mail){
$to_mails = [];
- if(strpos($customer_mail->email, ',')){
- $to_mails = array_map('trim', explode(',', $customer_mail->email));
+ if(strpos($lead_mail->email, ',')){
+ $to_mails = array_map('trim', explode(',', $lead_mail->email));
}else{
- $to_mails[] = $customer_mail->email;
+ $to_mails[] = $lead_mail->email;
}
- if($customer_mail->recipient){
- $to_mails = array_merge($to_mails, $customer_mail->recipient);
+ if($lead_mail->recipient){
+ $to_mails = array_merge($to_mails, $lead_mail->recipient);
}
- $customer_files = $customer_mail->customer_files;
- $full_message = $this->prepareMessageFull($customer_mail);
+ $lead_files = $lead_mail->lead_files;
+ $full_message = $this->prepareMessageFull($lead_mail);
try {
//
Mail::to($to_mails)
- ->cc($customer_mail->cc ?: [])
- ->bcc($customer_mail->bcc ?: [])
- ->send(new MailSendInfo($customer_mail->subject, $full_message, $customer_files));
+ ->cc($lead_mail->cc ?: [])
+ ->bcc($lead_mail->bcc ?: [])
+ ->send(new MailSendInfo($lead_mail->subject, $full_message, $lead_files));
}
catch(\Exception $e){
// Never reached
- $customer_mail->fail = true;
- $customer_mail->error = $e->getMessage();
- $customer_mail->save();
+ $lead_mail->fail = true;
+ $lead_mail->error = $e->getMessage();
+ $lead_mail->save();
return false;
}
- $customer_mail->send = true;
- $customer_mail->sent_at = now();
- $customer_mail->save();
+ $lead_mail->send = true;
+ $lead_mail->sent_at = now();
+ $lead_mail->save();
return true;
}
- private function prepareMessageFull($customer_mail, $deep = 0){
+ private function prepareMessageFull($lead_mail, $deep = 0){
$ret = "";
if($deep === 0){
- $ret .= $customer_mail->message;
+ $ret .= $lead_mail->message;
}else{
$ret .= "--------------------------------\n";
- $ret .= $customer_mail->is_answer ? "Antwort von: " : "Gesendet an: ";
- $ret .= "<".$customer_mail->email."> ".$customer_mail->sent_at."\n";
- $ret .= "".$customer_mail->subject."\n";
- $ret .= $customer_mail->message;
+ $ret .= $lead_mail->is_answer ? "Antwort von: " : "Gesendet an: ";
+ $ret .= "<".$lead_mail->email."> ".$lead_mail->sent_at."\n";
+ $ret .= "".$lead_mail->subject."\n";
+ $ret .= $lead_mail->message;
}
- if($customer_mail->customer_mail){
- $ret .= $this->prepareMessageFull($customer_mail->customer_mail, $deep+1);
+ if($lead_mail->lead_mail){
+ $ret .= $this->prepareMessageFull($lead_mail->lead_mail, $deep+1);
}
return $ret;
}
- private function prepareContent($booking_fewo, $content){
- $content = Placeholder::replaceBookingFewo($booking_fewo, $content);
+ private function prepareContent($lead, $content){
+ $content = Placeholder::replaceLead($lead, $content);
return $content;
}
private static function prepareContactMails($value){
- if(isset($value->customers)){ //&& $value->customer_mail_dir !== NULL
+ if(isset($value->customers)){ //&& $value->lead_mail_dir !== NULL
$first_mail = "";
- if($value->customer_mail_dir < 10){ // && $value->customer_mail_subdir > 0
- $customer_mail_dir = \App\Services\BookingFewo::getCustomerMailDir($value->customer_mail_dir);
- $contact_emails = \App\Services\BookingFewo::getCustomerMailEmails($customer_mail_dir, $value->customer_mail_subdir);
- if($value->customer_mail_dir == 0){
+ if($value->lead_mail_dir < 10){ // && $value->lead_mail_subdir > 0
+ $lead_mail_dir = \App\Services\Lead::getCustomerMailDir($value->lead_mail_dir);
+ $contact_emails = \App\Services\Lead::getCustomerMailEmails($lead_mail_dir, $value->lead_mail_subdir);
+ if($value->lead_mail_dir == 0){
$value->recipient = Util::_implodeLines($contact_emails);
return $value;
}else{
@@ -260,68 +260,69 @@ class LeadMailRepository extends BaseRepository {
$value->cc = "";
$value->bcc = "";
$value->lead_title_id = "";
+ $value->lead = "";
$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 = CustomerFewoMail::find($data['customer_mail_id'])) {
+ if ($data['action'] === "show-lead-mail") {
+ if (isset($data['lead_mail_id']) && $lead_mail = LeadMail::find($data['lead_mail_id'])) {
$value->url = $data['url'];
$value->title = "E-Mail Ansicht";
- return view("travel.user.booking.mail.modal-show-mail", compact('data', 'value', 'customer_mail'))->render();
+ return view("lead.modal-show-mail", compact('data', 'value', 'lead_mail'))->render();
}
}
/* neue Mail */
- if ($data['action'] === "edit-customer-mail") {
+ if ($data['action'] === "edit-lead-mail") {
$value->id = $data['id']; //
- $customer_mail = CustomerFewoMail::find($value->id);
- $booking = $customer_mail->travel_user_booking_fewo;
- $value->customer_files = $customer_mail->customer_files;
- $value->save_customer_mail_id = $customer_mail->id;
+ $lead_mail = LeadMail::find($value->id);
+ $lead = $lead_mail->lead;
+ $value->lead_files = $lead_mail->lead_files;
+ $value->save_lead_mail_id = $lead_mail->id;
$value->draft = true;
- $value->id = $customer_mail->travel_user_booking_fewo_id;
- $value->booking = $booking;
+ $value->id = $lead_mail->travel_user_lead_id;
+ $value->lead = $lead;
$value->show = 'single';
- $value->lead_title_id = " - (".$value->booking->invoice_number.")";
+ $value->lead_title_id = " - (".$value->lead->id.")";
$tmp = [];
- $tmp['email'] = $booking->travel_user ? $booking->travel_user->email : "";
- $tmp['name'] = $booking->travel_user ? $booking->travel_user->first_name . " " . $booking->travel_user->last_name . " | " : "- | ";
- $tmp['name'] .= $booking->fewo_lodging_id ? $booking->fewo_lodging->name . " | " : "- | ";
- $data['customers'][$booking->id] = $tmp;
+ $tmp['email'] = $lead->customer ? $lead->customer->email : "";
+ $tmp['name'] = $lead->customer ? $lead->customer->firstname . " " . $lead->customer->name . " | " : "- | ";
+ $tmp['name'] .= $lead->id ? $lead->id. " | " : "- | ";
+ $data['customers'][$lead->id] = $tmp;
$value->customers = $data['customers'];
- $value->subject = $customer_mail->subject;
- $value->message = $customer_mail->message;
- $value->recipient = Util::_implodeLines($customer_mail->recipient);
- $value->cc = Util::_implodeLines($customer_mail->cc);
- $value->bcc = Util::_implodeLines($customer_mail->bcc);
+ $value->subject = $lead_mail->subject;
+ $value->message = $lead_mail->message;
+ $value->recipient = Util::_implodeLines($lead_mail->recipient);
+ $value->cc = Util::_implodeLines($lead_mail->cc);
+ $value->bcc = Util::_implodeLines($lead_mail->bcc);
$value->title = "E-Mail- Nachricht an Kunden senden";
$value->subtitle = "Dem Kunden wird eine E-Mail zugesendet.";
- if($customer_mail->reply_id){
+ if($lead_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->customer_mail;
+ $value->lead_mail = $lead_mail->lead_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_subdir = $customer_mail->subdir ? $customer_mail->subdir : 0;
+ $value->lead_mail_dir = $lead_mail->dir ? $lead_mail->dir : 0;
+ $value->lead_mail_subdir = $lead_mail->subdir ? $lead_mail->subdir : 0;
- return view("travel.user.booking.mail.modal-new-mail", compact('data', 'value'))->render();
+ return view("lead.modal-new-mail", compact('data', 'value'))->render();
}
/* neue Mail */
- if ($data['action'] === "new-customer-mail") {
+ if ($data['action'] === "new-lead-mail") {
$value->id = "";
$value->draft = false;
$value->lead_title_id = "-";
//singel
- if (isset($data['travel_user_booking_fewo_id']) && $booking_fewo = TravelUserBookingFewo::find($data['travel_user_booking_fewo_id'])) {
- $value->id = $data['travel_user_booking_fewo_id'];
- $value->booking = $booking_fewo;
+ if (isset($data['lead_id']) && $lead = Lead::find($data['lead_id'])) {
+ $value->id = $data['lead_id'];
+ $value->lead = $lead;
$value->show = 'single';
$value->draft = true;
- $value->lead_title_id = " - (".$value->booking->invoice_number.")";
+ $value->lead_title_id = " - (".$value->lead->id.")";
}else{
//multi
@@ -332,9 +333,9 @@ class LeadMailRepository extends BaseRepository {
$value->message = CMSContent::getContentBySlug('mailvorlage');
$value->s_placeholder = "Betreff der E-Mail";
$value->m_placeholder = "Nachricht der E-Mail";
- if(isset($data['customer_mail_id']) && $customer_mail = CustomerFewoMail::find($data['customer_mail_id'])){
- $value->subject = "Re: ".Util::_first_replace($customer_mail->subject);
- $value->customer_mail = $customer_mail;
+ if(isset($data['lead_mail_id']) && $lead_mail = LeadMail::find($data['lead_mail_id'])){
+ $value->subject = "Re: ".Util::_first_replace($lead_mail->subject);
+ $value->lead_mail = $lead_mail;
}
$value->title = "E-Mail- Nachricht an Kunden senden";
@@ -344,27 +345,27 @@ class LeadMailRepository extends BaseRepository {
$value->subtitle = "Dem Kunden wird eine E-Mail zugesendet, die im System als Antwort gespeichert wird.";
}
$value->url = $data['url'];
- $value->customer_mail_dir = isset($data['customer_mail_dir']) ? $data['customer_mail_dir'] : 0;
- $value->customer_mail_subdir = isset($data['customer_mail_subdir']) ? $data['customer_mail_subdir'] : 0;
+ $value->lead_mail_dir = isset($data['lead_mail_dir']) ? $data['lead_mail_dir'] : 0;
+ $value->lead_mail_subdir = isset($data['lead_mail_subdir']) ? $data['lead_mail_subdir'] : 0;
$value = self::prepareContactMails($value);
- return view("travel.user.booking.mail.modal-new-mail", compact('data', 'value'))->render();
+ return view("lead.modal-new-mail", compact('data', 'value'))->render();
}
/*Antwort speichern*/
- if ($data['action'] === "reply-customer-mail") {
- if (isset($data['travel_user_booking_fewo_id']) && $booking_fewo = TravelUserBookingFewo::find($data['travel_user_booking_fewo_id'])) {
- $value->id = $data['travel_user_booking_fewo_id'];
+ if ($data['action'] === "reply-lead-mail") {
+ if (isset($data['lead_id']) && $lead = Lead::find($data['lead_id'])) {
+ $value->id = $data['lead_id'];
$value->draft = false;
- $value->booking = $booking_fewo;
+ $value->lead = $lead;
$value->message = "";
- $value->subject = " - (".$value->booking->invoice_number.")";
- $value->lead_title_id = " - (".$value->booking->invoice_number.")";
+ $value->subject = " - (".$value->lead->id.")";
+ $value->lead_title_id = " - (".$value->lead->id.")";
$value->s_placeholder = "Betreff des Kunden";
$value->m_placeholder = "Nachricht des Kunden";
- if(isset($data['customer_mail_id']) && $customer_mail = CustomerFewoMail::find($data['customer_mail_id'])){
- $value->subject = "Re: ".Util::_first_replace($customer_mail->subject);
- $value->customer_mail = $customer_mail;
+ if(isset($data['lead_mail_id']) && $lead_mail = LeadMail::find($data['lead_mail_id'])){
+ $value->subject = "Re: ".Util::_first_replace($lead_mail->subject);
+ $value->lead_mail = $lead_mail;
}
$value->title = "E-Mail Antwort speichern";
$value->subtitle = "Die E-Mail wird im System gespeichert.";
@@ -374,11 +375,11 @@ class LeadMailRepository 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_subdir = isset($data['customer_mail_subdir']) ? $data['customer_mail_subdir'] : 0;
+ $value->lead_mail_dir = isset($data['lead_mail_dir']) ? $data['lead_mail_dir'] : 0;
+ $value->lead_mail_subdir = isset($data['lead_mail_subdir']) ? $data['lead_mail_subdir'] : 0;
$value = self::prepareContactMails($value);
- return view("travel.user.booking.mail.modal-new-mail", compact('data', 'value'))->render();
+ return view("lead.modal-new-mail", compact('data', 'value'))->render();
}
}
diff --git a/app/Services/Lead.php b/app/Services/Lead.php
index 0d93f3c..1532bd8 100644
--- a/app/Services/Lead.php
+++ b/app/Services/Lead.php
@@ -23,9 +23,9 @@ class Lead
return CMSContent::where('identifier', '=', 'customer-lead-mail-dirs')->where('pos', '=', $id)->first();
}
- /* public static function getCustomerMailName($customer_mail_dir, $mail_dir_id){
+ public static function getCustomerMailName($lead_mail_dir, $mail_dir_id){
- switch ($customer_mail_dir->getArrayContent('model')){
+ switch ($lead_mail_dir->getArrayContent('model')){
case 'TravelCountry':
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
break;
@@ -43,7 +43,7 @@ class Lead
}
if($model){
- if($customer_mail_dir->getArrayContent('model') === 'TravelCountry'){
+ if($lead_mail_dir->getArrayContent('model') === 'TravelCountry'){
return $model->mail_dir_name;
}
return $model->name;
@@ -51,9 +51,9 @@ class Lead
return "";
}
- public static function getCustomerMailEmails($customer_mail_dir, $mail_dir_id){
+ public static function getCustomerMailEmails($lead_mail_dir, $mail_dir_id){
- switch ($customer_mail_dir->getArrayContent('model')){
+ switch ($lead_mail_dir->getArrayContent('model')){
case 'TravelCountry':
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
break;
@@ -68,7 +68,7 @@ class Lead
break;
default:
//direkt from CMSContent
- return $customer_mail_dir->getArrayContent('emails');
+ return $lead_mail_dir->getArrayContent('emails');
}
if($model){
@@ -77,7 +77,7 @@ class Lead
return [];
}
- public static function getFeWoInstructionPDFName($fewo){
+ /*public static function getFeWoInstructionPDFName($fewo){
return "HINWEISE-FERIENWOHNUNG-".$fewo->pdf_name.".pdf";
}
public static function getFeWoCMSContent($content, $identifier_fewo){
diff --git a/app/Services/Placeholder.php b/app/Services/Placeholder.php
index 668ee69..9c3d926 100644
--- a/app/Services/Placeholder.php
+++ b/app/Services/Placeholder.php
@@ -3,6 +3,8 @@ namespace App\Services;
use App\Models\Booking;
use App\Models\TravelUserBookingFewo;
+use App\Models\Lead;
+
class Placeholder
{
@@ -29,6 +31,7 @@ class Placeholder
}
return $ret;
}
+
public static function getBookingOptions(){
$ret = "";
foreach (self::$booking as $key => $value) {
@@ -90,6 +93,32 @@ class Placeholder
return $content;
}
+ public static function replaceLead(Lead $lead, $content)
+ {
+ $dear = $lead->customer->salutation_id == 1 ? 'geehrter' : 'geehrte';
+ $first_name = $lead->customer->firstname;
+ $last_name = $lead->customer->name;
+ $title = $lead->customer->title;
+ $country = "";
+ $program = "";
+ $salutation = $lead->customer->salutation_id == 1 ? 'Herr' : 'Frau';
+ $start_date = $lead->travelperiod_start ? _format_date($lead->travelperiod_start) : '';
+ $end_date = $lead->travelperiod_end ? _format_date($lead->travelperiod_end) : '';;
+ $booking_date = $lead->request_date ? _format_date($lead->request_date) : '';;
+
+ $airline = "";
+ $search = [];
+ $replace = [];
+
+ foreach (self::$booking as $key => $value) {
+ $search[] = $value;
+ $replace[] = ${$key};
+ }
+ $content = str_replace($search, $replace, $content);
+ $content = preg_replace('/(.*?)<\/placeholder>/', '$1', $content);
+ $content = preg_replace('/(.*?)<\/span>/', '$1', $content);
+ return $content;
+ }
}
\ No newline at end of file
diff --git a/database/migrations/2020_03_11_131408_create_customer_mails_table.php b/database/migrations/2020_03_11_131408_create_customer_mails_table.php
index 43e0a0d..10e2c57 100644
--- a/database/migrations/2020_03_11_131408_create_customer_mails_table.php
+++ b/database/migrations/2020_03_11_131408_create_customer_mails_table.php
@@ -21,7 +21,7 @@ class CreateCustomerMailsTable extends Migration
$table->bigInteger('lead_id')->nullable();
$table->boolean('is_answer')->default(false);
- $table->unsignedBigInteger('reply_id');
+ $table->unsignedBigInteger('reply_id')->nullable();
$table->string('email', 255);
diff --git a/database/migrations/2020_05_15_111351_create_customer_fewo_mails_table.php b/database/migrations/2020_05_15_111351_create_customer_fewo_mails_table.php
index f1b1a15..5c3f747 100644
--- a/database/migrations/2020_05_15_111351_create_customer_fewo_mails_table.php
+++ b/database/migrations/2020_05_15_111351_create_customer_fewo_mails_table.php
@@ -20,7 +20,7 @@ class CreateCustomerFewoMailsTable extends Migration
$table->unsignedInteger('travel_user_id');
$table->boolean('is_answer')->default(false);
- $table->unsignedInteger('reply_id');
+ $table->unsignedInteger('reply_id')->nullable();
$table->string('email', 255);
diff --git a/database/migrations/2021_05_07_124246_create_lead_mails_table.php b/database/migrations/2021_05_07_124246_create_lead_mails_table.php
index 9920453..f145542 100644
--- a/database/migrations/2021_05_07_124246_create_lead_mails_table.php
+++ b/database/migrations/2021_05_07_124246_create_lead_mails_table.php
@@ -20,7 +20,7 @@ class CreateLeadMailsTable extends Migration
$table->bigInteger('customer_id');
$table->boolean('is_answer')->default(false);
- $table->unsignedBigInteger('reply_id');
+ $table->unsignedBigInteger('reply_id')->nullable();
$table->string('email', 255);
@@ -60,7 +60,7 @@ class CreateLeadMailsTable extends Migration
$table->foreign('reply_id')
->references('id')
- ->on('customer_mails')
+ ->on('lead_mails')
->onDelete('CASCADE');
});
}
diff --git a/database/migrations/2021_05_07_124341_create_lead_files_table.php b/database/migrations/2021_05_07_124341_create_lead_files_table.php
index 1b7b572..c405dc6 100644
--- a/database/migrations/2021_05_07_124341_create_lead_files_table.php
+++ b/database/migrations/2021_05_07_124341_create_lead_files_table.php
@@ -16,7 +16,7 @@ class CreateLeadFilesTable extends Migration
Schema::create('lead_files', function (Blueprint $table) {
$table->bigIncrements('id');
- $table->bigInteger('lead_id');
+ $table->bigInteger('lead_id')->nullable();
$table->unsignedBigInteger('lead_mail_id')->nullable();
$table->string('identifier')->index();
diff --git a/resources/views/booking/_detail_mails.blade.php b/resources/views/booking/_detail_mails.blade.php
index cfbc9c9..3f56751 100755
--- a/resources/views/booking/_detail_mails.blade.php
+++ b/resources/views/booking/_detail_mails.blade.php
@@ -85,6 +85,7 @@
@endif
@endforeach
@foreach($booking::$customer_mail_dirs as $dir_id => $customer_mail_dir)
+ @php($badge = "badge-outline-primary")
diff --git a/resources/views/customer/mail/modal-show-mail-inner.blade.php b/resources/views/customer/mail/modal-show-mail-inner.blade.php
index 86948e1..358d1fd 100644
--- a/resources/views/customer/mail/modal-show-mail-inner.blade.php
+++ b/resources/views/customer/mail/modal-show-mail-inner.blade.php
@@ -30,26 +30,6 @@
-
- {{--
-
-
-
- --}}
{!! nl2br($customer_mail->message) !!}
@@ -152,7 +132,7 @@
-
{!! Form::close() !!}
diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php
index 0b8f091..d563012 100755
--- a/resources/views/home.blade.php
+++ b/resources/views/home.blade.php
@@ -236,7 +236,7 @@
@endforeach
@endif
-
+
{{__('Notizen') }} FeWo letzten 10
@@ -269,6 +269,39 @@
@endforeach
@endif
+
+
+
{{__('Notizen') }} Anfragen letzten 10
+
+ @if($last_lead_notices)
+ @foreach($last_lead_notices as $lead_notice)
+
+
+ @if($lead_notice->from_user_id === \Auth::user()->id)
+
+ @else
+
+ @endif
+
{{ $lead_notice->getName() }} | {{ $lead_notice->created_at->format("d.m.Y - H:i:s") }}
+ @if($lead_notice->edit_at != null)
+ |
{{ $lead_notice->edit_at->format("d.m.Y - H:i:s") }}
+ @endif
+ |
zur Buchnung {{ $lead_notice->lead_id }}
+
+ {!! nl2br($lead_notice->message) !!}
+
+
+
+ {{--
+
+
You | {{ $lead_notice->created_at->format("d.m.Y H:i:s") }}
+ {!! nl2br($lead_notice->message) !!}
+
+
+ --}}
+ @endforeach
+ @endif
+
@endif
diff --git a/resources/views/lead/_detail_mails.blade.php b/resources/views/lead/_detail_mails.blade.php
index 317b927..0cff50f 100644
--- a/resources/views/lead/_detail_mails.blade.php
+++ b/resources/views/lead/_detail_mails.blade.php
@@ -1,43 +1,42 @@
-