diff --git a/.env b/.env index 4eaa56d..ba2c798 100755 --- a/.env +++ b/.env @@ -44,7 +44,7 @@ MAIL_FEWO_EMPLOYEE=kevin@adametz.media #MAIL_FEWO_EMPLOYEE=katrin.nikolai@stern-tours.de,gerda.fritsch@stern-tours.de #MAIL_BBC=kontakt@stern-tours.de,thomas.stern@stern-tours.de MAIL_FROM_ADDRESS=info@mein.sterntours.de -MAIL_FROM_NAME="Mein Reisebüro STERN TOURS" +MAIL_FROM_NAME="Reisebüro STERN TOURS" MAIL_DRIVER=smtp MAIL_HOST=mail.your-server.de MAIL_PORT=587 diff --git a/app/Http/Controllers/API/LeadController.php b/app/Http/Controllers/API/LeadController.php new file mode 100644 index 0000000..4571d28 --- /dev/null +++ b/app/Http/Controllers/API/LeadController.php @@ -0,0 +1,71 @@ +json(['error' => 'lead not exist, but need'], $this->errorStatus); + } + if(!isset($data['lead']['customerForm'])){ + return response()->json(['error' => 'lead customerForm not exist, but need'], $this->errorStatus); + } + + //customer + /* $rules = array( + 'name' => 'required', + 'email' => 'requird' + + ); + $validator = Validator::make($data['lead']['customerForm'], $rules); + if ($validator->fails()) { + return response()->json($validator->messages(), $this->errorStatus); + + } + + //lead + $rules = array( + 'sf_guard_user_id' => 'required', + 'status_id' => 'requird', + 'request_date' => 'requird' + ); + $validator = Validator::make($data['lead'], $rules); + if ($validator->fails()) { + return response()->json($validator->messages(), $this->errorStatus); + + }*/ + + $customer = Customer::create($data['lead']['customerForm']); + unset($data['lead']['customerForm']); + $data['lead']['customer_id'] = $customer->id; + $lead = Lead::create($data['lead']); + $ret= [ + 'url_v1' => make_old_url('/index.php/leads/'.$lead->id.'/edit'), + 'url_v3' => route('lead_detail', $lead->id), + 'lead_id' => $lead->id + ]; + + return response()->json(['success' => $ret], $this->successStatus); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index b12f957..3e68753 100755 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -58,6 +58,12 @@ class BookingController extends Controller $data = Request::all(); + if($data['action'] === 'save_notice'){ + $booking = $this->bookingRepo->updateNotice($id, $data); + \Session()->flash('alert-save', '1'); + return redirect(route('booking_detail', [$booking->id])."#collapseBookingNotice"); + } + if($data['action'] === 'update_booking'){ $booking = $this->bookingRepo->updateBooking($id, $data); \Session()->flash('alert-save', '1'); @@ -268,6 +274,12 @@ class BookingController extends Controller \Session()->flash('alert-success', 'Datei gelöscht'); return redirect(route('booking_detail', [$booking->id])); } + if($del === 'passolution_file'){ + $booking = Booking::findOrFail($id); + $booking->resyncPassolutionPDF(); + \Session()->flash('alert-success', 'Passolution erneuert'); + return redirect(route('booking_detail', [$booking->id])); + } return redirect(route('requests')); } diff --git a/app/Http/Controllers/CustomerFewoMailController.php b/app/Http/Controllers/CustomerFewoMailController.php index 59ab285..a42dd6b 100755 --- a/app/Http/Controllers/CustomerFewoMailController.php +++ b/app/Http/Controllers/CustomerFewoMailController.php @@ -86,6 +86,7 @@ class CustomerFewoMailController extends Controller public function loadModal(){ $data = Request::all(); $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"){ $data['customers'] = []; diff --git a/app/Http/Controllers/CustomerMailController.php b/app/Http/Controllers/CustomerMailController.php index a12adbc..c7838e4 100755 --- a/app/Http/Controllers/CustomerMailController.php +++ b/app/Http/Controllers/CustomerMailController.php @@ -7,6 +7,7 @@ use App\Models\CustomerFewoMail; use App\Models\CustomerFile; use App\Models\CustomerMail; use App\Models\EmailTemplate; +use App\Repositories\CustomerFewoMailRepository; use App\Repositories\CustomerMailRepository; use App\Repositories\CustomerFileRepository; use App\Services\Util; @@ -72,6 +73,22 @@ class CustomerMailController extends Controller $customer_mail->subdir = $data['subdir']; $customer_mail->save(); } + + if($action === 'forward_fewo-email'){ + $customer_mail = CustomerFewoMail::findOrFail($id); + $customerMailFewoRepo = new CustomerFewoMailRepository($customer_mail); + $customerMailFewoRepo->forwardMail($customer_mail, $data); + \Session()->flash('alert-success', __('E-Mail weitergeleitet')); + + } + + if($action === 'forward_email'){ + $customer_mail = CustomerMail::findOrFail($id); + $this->customerMailRepo->forwardMail($customer_mail, $data); + \Session()->flash('alert-success', __('E-Mail weitergeleitet')); + + + } return back(); } @@ -164,10 +181,17 @@ class CustomerMailController extends Controller ->addColumn('send', function (CustomerMail $customer_mail) { return $customer_mail->send ? '' : ''; }) + ->addColumn('date', function (CustomerMail $customer_mail) { + if($customer_mail->send){ + return ' '.$customer_mail->sent_at.''; + } + return ' '.$customer_mail->sent_at.''; + }) ->orderColumn('id', 'id $1') ->orderColumn('booking_id', 'booking_id $1') ->orderColumn('customer_id', 'customer_id $1') ->orderColumn('send', 'send $1') + ->orderColumn('date', 'sent_at $1') ->filterColumn('id', function($query, $keyword) { if($keyword != ""){ @@ -184,7 +208,7 @@ class CustomerMailController extends Controller $query->where('booking_id', 'LIKE', '%'.$keyword.'%'); } }) - ->rawColumns(['action_edit', 'send', 'customer_id', 'booking_id', 'id']) + ->rawColumns(['action_edit', 'send', 'date', 'customer_id', 'booking_id', 'id']) ->make(true); } @@ -331,7 +355,8 @@ class CustomerMailController extends Controller }) ->addColumn('subject', function (CustomerMail $customer_mail) { - $icon = $customer_mail->reply_id ? 'ion-ios-redo' : 'ion-ios-mail'; + + $icon = $customer_mail->reply_id ? '' : ''; $badge = $customer_mail->is_answer ? 'badge-next' : 'badge-secondary'; $badge = $customer_mail->draft ? 'badge-default' : $badge; $to_icon = $customer_mail->draft ? '' : ''; @@ -339,11 +364,16 @@ class CustomerMailController extends Controller $id = $customer_mail->draft ? $customer_mail->id : 'new'; $url = $customer_mail->draft ? route('customer_mail_send_mail') : ''; + $deep = $customer_mail->customer_mail_deep(); + for ($i=1; $i < $deep; $i++) { + $icon .= ''; + } + return ' - '.$to_icon.''.$customer_mail->subject.' + '.$to_icon.''.$icon.' '.$customer_mail->subject.' '.($customer_mail->customer_files->count() ? '  '.$customer_mail->customer_files->count().'' : ''); }) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 06d75f4..829f031 100755 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\BookingNotice; use App\Models\SfGuardUser; use App\User; use Auth; @@ -40,8 +41,11 @@ class HomeController extends Controller if(!Auth::check()){ return redirect('login'); } + + $last_booking_notices = BookingNotice::orderBy('created_at', 'DESC')->limit(10)->get(); $data = [ 'user' => Auth::user(), + 'last_booking_notices' => $last_booking_notices, ]; return view('home', $data); } diff --git a/app/Http/Controllers/RequestController.php b/app/Http/Controllers/RequestController.php index 0eff4b0..fed1f86 100755 --- a/app/Http/Controllers/RequestController.php +++ b/app/Http/Controllers/RequestController.php @@ -233,7 +233,6 @@ class RequestController extends Controller if(isset($data['action']) && $data['action'] === "get_popover_booking_services") { $booking = Booking::findOrFail($data['booking_id']); $ret = ""; - $count = false; foreach($booking->travel_country->getContactLandsModels() as $TravelCountry){ if($TravelCountry->stern_travel_country){ @@ -291,6 +290,20 @@ class RequestController extends Controller } return $ret; } + + if(isset($data['action']) && $data['action'] === "get_popover_booking_notice"){ + $booking = Booking::findOrFail($data['booking_id']); + $ret = ""; + + if($booking->booking_notices->count()){ + $booking_notice = $booking->booking_notices->first(); + return $booking_notice->getSmallerMessage(500); + } + if($ret === ""){ + return 'keine Notiz'; + } + return $ret; + } $query = $this->getSearchRequests(); $ret = $query->get()->pluck('travelagenda_id', 'id')->unique()->toArray(); return TravelAgenda::whereIn('id', $ret)->get()->pluck('name', 'id'); @@ -363,9 +376,15 @@ class RequestController extends Controller return $booking->travel_documents ? '' : ''; }) ->addColumn('booking_services', function (Booking $booking) { - return $booking->hasBookingServicesUnchecked() ? '' : - ''; + return $booking->hasBookingServicesUnchecked() ? '' : + ''; }) + ->addColumn('booking_notice', function (Booking $booking) { + return $booking->booking_notices->count() ? '' : + ''; + }) + + ->addColumn('sf_guard_user_id', function (Booking $booking) { return ''.($booking->sf_guard_user_id? $booking->sf_guard_user->first_name." ".$booking->sf_guard_user->last_name : "-").''; @@ -467,7 +486,7 @@ class RequestController extends Controller ->orderColumn('xx_tkt', 'xx_tkt_date $1') ->orderColumn('comfort', 'comfort $1') //->orderColumn('travel_documents', 'travel_documents $1') - ->rawColumns(['action_lead_edit', 'comfort', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'travel_company_id', 'sf_guard_user_id', 'lead.status_id', 'last_customer_email', 'id', 'travel_documents', 'booking_services', 'paying_out', 'paying_out_status', 'airline_id', 'refund', 'hold', 'xx_tkt']) + ->rawColumns(['action_lead_edit', 'comfort', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'travel_company_id', 'sf_guard_user_id', 'lead.status_id', 'last_customer_email', 'id', 'travel_documents', 'booking_services', 'booking_notice', 'paying_out', 'paying_out_status', 'airline_id', 'refund', 'hold', 'xx_tkt']) ->make(true); } } diff --git a/app/Models/Booking.php b/app/Models/Booking.php index 19fe005..6381ce7 100644 --- a/app/Models/Booking.php +++ b/app/Models/Booking.php @@ -524,6 +524,11 @@ class Booking extends Model return $this->belongsTo(TravelNationality::class, 'nationality_id'); } + public function booking_notices() + { + return $this->hasMany(BookingNotice::class, 'booking_id')->orderBy('created_at', 'DESC'); + } + public function hasBookingServicesUnchecked(){ $country_services = true; $provider_services = true; @@ -547,14 +552,18 @@ class Booking extends Model return false; } - public function getPassolutionPDF($create = false){ + public function getPassolutionPDF($create = false, $resync = false){ $nats = []; if(count($this->passolutionPDFs)){ - return $this->passolutionPDFs; + return $this->passolutionPDFs; } + if(!$this->travel_country){ + return $this->passolutionPDFs; + } + $destco = $this->travel_country->destco; if($this->travel_nationality){ $nats[$this->travel_nationality->nat] = $this->travel_nationality->nat; @@ -566,6 +575,11 @@ class Booking extends Model } } } + + if(empty($nats)){ + $nats['de'] = 'de'; + } + foreach ($nats as $nat){ $data = [ 'nat' => $nat, @@ -573,11 +587,15 @@ class Booking extends Model ]; $passolution = new Passolution($data); - $this->passolutionPDFs[] = $passolution->findOrCreatePDF($create); + $this->passolutionPDFs[] = $passolution->findOrCreatePDF($create, $resync); } return $this->passolutionPDFs; } + public function resyncPassolutionPDF(){ + return $this->getPassolutionPDF(true, true); + } + public function calculate_price_total() { $travel_draft_item = false; diff --git a/app/Models/BookingNotice.php b/app/Models/BookingNotice.php new file mode 100644 index 0000000..d16f9b2 --- /dev/null +++ b/app/Models/BookingNotice.php @@ -0,0 +1,85 @@ + 'int', + 'from_user_id' => 'int', + 'to_user_id' => 'int', + 'show' => 'bool', + 'important' => 'bool' + ]; + + protected $fillable = [ + 'booking_id', + 'from_user_id', + 'to_user_id', + 'message', + 'show', + 'important' + ]; + + public function booking() + { + return $this->belongsTo(Booking::class); + } + + public function to_user() + { + return $this->belongsTo(User::class, 'to_user_id'); + } + + public function from_user() + { + return $this->belongsTo(User::class, 'from_user_id'); + } + + public function getName(){ + if($this->from_user){ + if($this->from_user->sf_guard_user){ + return $this->from_user->sf_guard_user->first_name." ".$this->from_user->sf_guard_user->last_name; + }else{ + $this->from_user->name; + } + } + } + + public function getSmallerMessage($max = 500){ + + $ret = substr($this->message, 0, $max); + if(strlen($this->message) > 500){ + $ret .= " ..."; + } + return $ret; + } +} diff --git a/app/Models/CustomerFewoMail.php b/app/Models/CustomerFewoMail.php index 489856a..c5b0c34 100644 --- a/app/Models/CustomerFewoMail.php +++ b/app/Models/CustomerFewoMail.php @@ -102,6 +102,7 @@ class CustomerFewoMail extends Model 'send' => 'bool', 'fail' => 'bool', 'recipient' => 'array', + 'forward' => 'array', 'cc' => 'array', 'bcc' => 'array' ]; @@ -131,6 +132,7 @@ class CustomerFewoMail extends Model 'send', 'fail', 'error', + 'forward', 'sent_at', 'scheduled_at', 'delivered_at' @@ -204,4 +206,15 @@ class CustomerFewoMail extends Model 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/Models/CustomerMail.php b/app/Models/CustomerMail.php index 88ba411..1f73148 100644 --- a/app/Models/CustomerMail.php +++ b/app/Models/CustomerMail.php @@ -105,6 +105,7 @@ class CustomerMail extends Model 'send' => 'bool', 'fail' => 'bool', 'recipient' => 'array', + 'forward' => 'array', 'cc' => 'array', 'bcc' => 'array' ]; @@ -135,6 +136,7 @@ class CustomerMail extends Model 'send', 'fail', 'error', + 'forward', 'sent_at', 'scheduled_at', 'delivered_at' @@ -188,4 +190,23 @@ class CustomerMail extends Model if(!$this->attributes['created_at']){ return ""; } return Carbon::parse($this->attributes['created_at'])->format(\Util::formatDateTimeDB()); } + + public function customer_mail_deep($deep = 0){ + + if($this->customer_mail){ + $deep = $this->customer_mail->customer_mail_deep(++$deep); + } + return $deep; + } + 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/Models/SfGuardUser.php b/app/Models/SfGuardUser.php index 42860c7..8b920f3 100755 --- a/app/Models/SfGuardUser.php +++ b/app/Models/SfGuardUser.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\User; use Illuminate\Database\Eloquent\Model; @@ -59,4 +60,9 @@ class SfGuardUser extends Model protected $table = 'sf_guard_user'; + public function user() + { + return $this->belongsTo(User::class, 'user_id'); + } + } diff --git a/app/Repositories/BookingRepository.php b/app/Repositories/BookingRepository.php index d2bc48c..79a1526 100644 --- a/app/Repositories/BookingRepository.php +++ b/app/Repositories/BookingRepository.php @@ -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); diff --git a/app/Repositories/CustomerFewoMailRepository.php b/app/Repositories/CustomerFewoMailRepository.php index f71a62e..b5e6bf4 100644 --- a/app/Repositories/CustomerFewoMailRepository.php +++ b/app/Repositories/CustomerFewoMailRepository.php @@ -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 .= "".$customer_mail->subject."\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"; diff --git a/app/Repositories/CustomerMailRepository.php b/app/Repositories/CustomerMailRepository.php index ba81cc6..eec5a83 100644 --- a/app/Repositories/CustomerMailRepository.php +++ b/app/Repositories/CustomerMailRepository.php @@ -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 .= "".$customer_mail->subject."\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(); } diff --git a/app/Services/Passolution.php b/app/Services/Passolution.php index 88cf8a6..fccb632 100644 --- a/app/Services/Passolution.php +++ b/app/Services/Passolution.php @@ -170,12 +170,12 @@ class Passolution $pdf_file->create(['contents' => $this->htmlText], $this->pdf_name, 'save', $this->pdf_path.$this->pdf_dir); } - public function findOrCreatePDF($create = false){ + public function findOrCreatePDF($create = false, $resync = false){ $this->createPDFName(); $this->storagePath(); $bool = Storage::disk('public')->exists( $this->pdf_dir.$this->pdf_name ); - if(!$bool && $create){ + if(!$bool && $create || $resync){ $this->read(); $this->onlyCreatePDF(); $bool = true; diff --git a/app/Services/Placeholder.php b/app/Services/Placeholder.php index 8e87f1f..668ee69 100644 --- a/app/Services/Placeholder.php +++ b/app/Services/Placeholder.php @@ -46,7 +46,7 @@ class Placeholder $title = $booking->customer->title; $country = $booking->travel_country_id ? $booking->travel_country->name : "-"; $program = $booking->travelagenda_id ? $booking->travel_agenda->name : "-"; - $salutation = $booking->customer->salutation->name; + $salutation = isset($booking->customer->salutation) ? $booking->customer->salutation->name : ''; $start_date = $booking->getStartDateFormat(); $end_date = $booking->getEndDateFormat(); $booking_date = $booking->getBookingDateFormat(); diff --git a/app/User.php b/app/User.php index e43f270..cf05516 100755 --- a/app/User.php +++ b/app/User.php @@ -3,12 +3,13 @@ namespace App; use Carbon\Carbon; -use Illuminate\Notifications\Notifiable; -use Illuminate\Foundation\Auth\User as Authenticatable; -use Illuminate\Support\Facades\Mail; +use App\Models\SfGuardUser; use App\Mail\MailResetPassword; -use Illuminate\Database\Eloquent\SoftDeletes; use Laravel\Passport\HasApiTokens; +use Illuminate\Support\Facades\Mail; +use Illuminate\Notifications\Notifiable; +use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Foundation\Auth\User as Authenticatable; /** @@ -113,7 +114,10 @@ class User extends Authenticatable 'permissions' => 'array', ]; - + public function sf_guard_user() + { + return $this->hasOne(SfGuardUser::class, 'user_id', 'id'); + } public function account() { diff --git a/config/mail.php b/config/mail.php index f909655..48439ab 100755 --- a/config/mail.php +++ b/config/mail.php @@ -57,7 +57,7 @@ return [ 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'stern@sterntours.de'), - 'name' => env('MAIL_FROM_NAME', 'Mein Reisebüro STERN TOURS'), + 'name' => env('MAIL_FROM_NAME', 'Reisebüro STERN TOURS'), ], 'mail_bbc' => explode(',', env('MAIL_BBC', 'kontakt@stern-tours.de')), 'mail_fewo_employee' => env('MAIL_FEWO_EMPLOYEE', 'kontakt@stern-tours.de'), diff --git a/database/migrations/2019_08_05_171718_create_i_q_content_categories_table.php b/database/migrations/2019_08_05_171718_create_i_q_content_categories_table.php index b23a86a..0d1075f 100644 --- a/database/migrations/2019_08_05_171718_create_i_q_content_categories_table.php +++ b/database/migrations/2019_08_05_171718_create_i_q_content_categories_table.php @@ -13,7 +13,7 @@ class CreateIQContentCategoriesTable extends Migration */ public function up() { - Schema::connection('mysql_stern')->create('i_q_content_categories', function (Blueprint $table) {y + Schema::connection('mysql_stern')->create('i_q_content_categories', function (Blueprint $table) { $table->bigIncrements('id'); 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 7bf0e2f..43e0a0d 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 @@ -41,6 +41,8 @@ class CreateCustomerMailsTable extends Migration $table->boolean('send')->default(false); $table->boolean('fail')->default(false); $table->text('error')->nullable(); + $table->text('forward')->nullable(); + $table->timestamp('sent_at')->nullable(); $table->timestamp('scheduled_at')->nullable(); 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 bf31a99..f1b1a15 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 @@ -40,6 +40,8 @@ class CreateCustomerFewoMailsTable extends Migration $table->boolean('send')->default(false); $table->boolean('fail')->default(false); $table->text('error')->nullable(); + $table->text('forward')->nullable(); + $table->timestamp('sent_at')->nullable(); $table->timestamp('scheduled_at')->nullable(); diff --git a/database/migrations/2021_03_31_155913_create_booking_notices_table.php b/database/migrations/2021_03_31_155913_create_booking_notices_table.php new file mode 100644 index 0000000..e64785f --- /dev/null +++ b/database/migrations/2021_03_31_155913_create_booking_notices_table.php @@ -0,0 +1,57 @@ +bigIncrements('id'); + $table->bigInteger('booking_id'); + //from + $table->unsignedInteger('from_user_id'); + //to + $table->unsignedInteger('to_user_id')->nullable(); + + $table->text('message')->nullable(); + $table->boolean('show')->default(false); + $table->boolean('important')->default(false); + + $table->timestamps(); + + $table->foreign('booking_id') + ->references('id') + ->on('booking'); + + $table->foreign('from_user_id') + ->references('id') + ->on('users') + ->onDelete('CASCADE'); + + $table->foreign('to_user_id') + ->references('id') + ->on('users') + ->onDelete('CASCADE'); + + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('booking_notices'); + } +} diff --git a/mein-sterntours.code-workspace b/mein-sterntours.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/mein-sterntours.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file diff --git a/resources/views/booking/_detail_files.blade.php b/resources/views/booking/_detail_files.blade.php index 6774c85..5139b1b 100755 --- a/resources/views/booking/_detail_files.blade.php +++ b/resources/views/booking/_detail_files.blade.php @@ -207,7 +207,7 @@ @endif @endforeach - + @if($booking->travel_country) @foreach($booking->travel_country->getContactLandsModels() as $TravelCountry) @if($TravelCountry->stern_travel_country) @foreach($TravelCountry->stern_travel_country->general_files as $general_files) @@ -235,13 +235,13 @@ @endforeach @endif @endforeach - + @endif @foreach($booking->getPassolutionPDF() as $PassolutionPDF) @if($PassolutionPDF) {{$booking_files_count++}} - + {{$PassolutionPDF['filename']}} @@ -251,7 +251,7 @@ {{\App\Services\Util::_format_date($PassolutionPDF['date'], 'date')}} - @@ -297,6 +297,11 @@ @if(Auth::user()->isPermission('sua-st-co'))
Landesspezifische Dateien unter: Einstellungen -> Reieseländer
@endif +
Passolution Dateien aktualisieren: +
+ + + +
+ + {!! Form::close() !!} + + + @if($booking->booking_notices) + @foreach($booking->booking_notices as $booking_notice) + +
+ @if($booking_notice->from_user_id === \Auth::user()->id) +
+ @else +
+ @endif +
{{ $booking_notice->getName() }} | {{ $booking_notice->created_at->format("d.m.Y - H:i:s") }}
+ {!! nl2br($booking_notice->message) !!} +
+
+ {{--
+
+
You | {{ $booking_notice->created_at->format("d.m.Y H:i:s") }}
+ {!! nl2br($booking_notice->message) !!} +
+
+ --}} + @endforeach + @endif +
+ + \ No newline at end of file diff --git a/resources/views/booking/_detail_services.blade.php b/resources/views/booking/_detail_services.blade.php index 940565c..b958c9f 100755 --- a/resources/views/booking/_detail_services.blade.php +++ b/resources/views/booking/_detail_services.blade.php @@ -9,6 +9,7 @@
Agentur

+ @if($booking->travel_country) @foreach($booking->travel_country->getContactLandsModels() as $TravelCountry) @if($TravelCountry->stern_travel_country->count())
{{$TravelCountry->stern_travel_country->name}}
@@ -27,6 +28,7 @@ @endforeach @endif @endforeach + @endif
Leistungsträger
diff --git a/resources/views/booking/detail.blade.php b/resources/views/booking/detail.blade.php index 86a77f3..275dee0 100755 --- a/resources/views/booking/detail.blade.php +++ b/resources/views/booking/detail.blade.php @@ -95,6 +95,11 @@ PDF Dateien
+ @@ -137,6 +142,8 @@ @include('booking._detail_files') + @include('booking._detail_notice') +
{{ __('zur Übersicht') }} {{ __('zurück ins CRM v2') }} diff --git a/resources/views/customer/mail/index.blade.php b/resources/views/customer/mail/index.blade.php index 493f896..0cfd358 100755 --- a/resources/views/customer/mail/index.blade.php +++ b/resources/views/customer/mail/index.blade.php @@ -48,7 +48,7 @@ { data: 'booking_id', name: 'booking_id' }, { data: 'booking', name: 'booking', searchable: false }, { data: 'send', name: 'send', searchable: false }, - { data: 'created_at', name: 'created_at' }, + { data: 'date', name: 'date' }, ], "bLengthChange": false, diff --git a/resources/views/customer/mail/modal-new-booking-files.blade.php b/resources/views/customer/mail/modal-new-booking-files.blade.php index fbdd863..f372328 100644 --- a/resources/views/customer/mail/modal-new-booking-files.blade.php +++ b/resources/views/customer/mail/modal-new-booking-files.blade.php @@ -176,6 +176,7 @@ @endif @endforeach + @if($booking->travel_country) @foreach($booking->travel_country->getContactLandsModels() as $TravelCountry) @if($TravelCountry->stern_travel_country) @foreach($TravelCountry->stern_travel_country->general_files as $general_files) @@ -200,6 +201,7 @@ @endforeach @endif @endforeach + @endif @foreach($booking->getPassolutionPDF() as $PassolutionPDF) @if($PassolutionPDF) diff --git a/resources/views/customer/mail/modal-new-mail.blade.php b/resources/views/customer/mail/modal-new-mail.blade.php index 10d1d34..b16180a 100644 --- a/resources/views/customer/mail/modal-new-mail.blade.php +++ b/resources/views/customer/mail/modal-new-mail.blade.php @@ -33,7 +33,7 @@
@if($value->booking->customer) - Kunde:
{{ $value->booking->customer->salutation->name }} {{ $value->booking->customer->title }} {{ $value->booking->customer->firstname }} {{ $value->booking->customer->name }} + Kunde:
@if($value->booking->customer->salutation) {{ $value->booking->customer->salutation->name }} @endif {{ $value->booking->customer->title }} {{ $value->booking->customer->firstname }} {{ $value->booking->customer->name }} @endif @if($value->booking->lead) ({{$value->booking->lead->id}}) @@ -219,10 +219,10 @@ @if($customer_mail_dir->pos > 0) @endif @endforeach @@ -317,7 +317,7 @@ } function add_mail_attachment_preview(response){ - console.log(response); + //console.log(response); var template = $('#mail-attachment-template').clone() .removeAttr('id').removeClass('d-none') .attr('data-id', response.file_id); @@ -454,7 +454,9 @@ function callback_email_template_data_table(data) { if(data.status === 'success'){ - $('input#subject').val(data.response.subject + $('input#lead_title_id').val()); + if($('input#subject').val() === $('input#lead_title_id').val()){ + $('input#subject').val(data.response.subject + $('input#lead_title_id').val()); + } $("input#message-editor-fallback").val(data.html); $('#message-editor .ql-editor').html(data.html) $('#collapseModalEmailTemplate').collapse('hide'); 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 6a82b48..86948e1 100644 --- a/resources/views/customer/mail/modal-show-mail-inner.blade.php +++ b/resources/views/customer/mail/modal-show-mail-inner.blade.php @@ -110,7 +110,7 @@
@endif - @if(isset($show_move_dirs)) + @if(isset($show_move_dirs) && $show_move_dirs)
{!! Form::open(['url' => route('customer_mail_detail', [$customer_mail->id, 'move-mail']), 'class' => 'move-mail-form']) !!} @@ -125,7 +125,6 @@
- {{-- TODO load subdirs by pos id --}} @if($customer_mail->booking->travel_country) @@ -144,6 +143,24 @@
{!! Form::close() !!} +
+ {!! Form::open(['url' => route('customer_mail_detail', [$customer_mail->id, 'forward_email']), 'class' => 'forward-mail-form']) !!} +
+
+ + {{ Form::text('customer_mail_forward_email', $customer_mail->email, array('placeholder'=>'E-Mail', 'id'=>'customer_mail_forward_email', 'class'=>'form-control', 'required')) }} +
+
+ +
+ {!! Form::close() !!}
@endif - \ No newline at end of file + + + + @if(isset($customer_mail->customer_mail)) +
+ @include('customer.mail.modal-show-mail-inner', ['customer_mail' => $customer_mail->customer_mail, 'show_move_dirs' => false]) + @endif \ No newline at end of file diff --git a/resources/views/customer/mail/modal-show-mail.blade.php b/resources/views/customer/mail/modal-show-mail.blade.php index b9007b0..1f1fd7a 100644 --- a/resources/views/customer/mail/modal-show-mail.blade.php +++ b/resources/views/customer/mail/modal-show-mail.blade.php @@ -10,9 +10,6 @@ @include('customer.mail.modal-show-mail-inner', ['customer_mail' => $customer_mail, 'show_move_dirs' => true]) - @if($customer_mail->customer_mail) - @include('customer.mail.modal-show-mail-inner', ['customer_mail' => $customer_mail->customer_mail]) - @endif --}} +{{-- Später need ADMIN!!!! --}} + @if(\Auth::user()->isAdmin()) +
+

{{__('Notizen') }} Buchnungen letzten 10

+ @if($last_booking_notices) + @foreach($last_booking_notices as $booking_notice) +
+
+ @if($booking_notice->from_user_id === \Auth::user()->id) +
+ @else +
+ @endif +
{{ $booking_notice->getName() }} | {{ $booking_notice->created_at->format("d.m.Y - H:i:s") }} | + zur Buchnung {{ $booking_notice->booking_id }} +
+ {!! nl2br($booking_notice->message) !!} +
+
+
+ {{--
+
+
You | {{ $booking_notice->created_at->format("d.m.Y H:i:s") }}
+ {!! nl2br($booking_notice->message) !!} +
+
+ --}} + @endforeach + @endif +
+ @endif - -
+

{{__('Activities') }}

@if($user->active == 1) @@ -239,7 +269,7 @@ @if($user->active == 1) -
+

{{ __('Einwilligung & Datenschutz') }}

{!! Form::open(['url' => route('user_data_accepted_form'), 'class' => 'form-horizontal' , 'id'=>'data-privacy-form-validations']) !!} @@ -262,7 +292,7 @@ @endif -
+

{{__('Login & Security') }}

{{__('Sign in with your e-mail:')}} {{ Auth::user()->email }}

@if(!$user->isPasswort()) diff --git a/resources/views/lead/index.blade.php b/resources/views/lead/index.blade.php index 2735bff..f35006e 100755 --- a/resources/views/lead/index.blade.php +++ b/resources/views/lead/index.blade.php @@ -17,6 +17,7 @@ {{__('KundenID')}} {{__('Vorname')}} {{__('Nachname')}} + {{__('E-Mail')}} {{__('Anfrage-Datum')}} {{__('Sachbearbeiter')}} {{__('Status')}} @@ -39,6 +40,7 @@ { data: 'customer_id', name: 'customer_id' }, { data: 'customer.firstname', name: 'customer.firstname' }, { data: 'customer.name', name: 'customer.name' }, + { data: 'customer.email', name: 'customer.email' }, { data: 'request_date', name: 'request_date' }, { data: 'sf_guard_user.last_name', name: 'sf_guard_user.last_name', searchable: false }, { data: 'status.name', name: 'status.name' }, diff --git a/resources/views/request/index.blade.php b/resources/views/request/index.blade.php index a36c341..44e99de 100755 --- a/resources/views/request/index.blade.php +++ b/resources/views/request/index.blade.php @@ -190,6 +190,7 @@ {{__('Abreise')}} {{__('U.')}} {{__('L.')}} + {{__('N.')}} {{__('Sachbearbeiter')}} {{__('Status')}} {{__('E-Mail')}} @@ -270,6 +271,7 @@ { data: 'end_date', name: 'end_date' }, { data: 'travel_documents', name: 'travel_documents', orderable: false }, { data: 'booking_services', name: 'booking_services', orderable: false }, + { data: 'booking_notice', name: 'booking_notice', orderable: false }, { data: 'sf_guard_user_id', name: 'sf_guard_user_id', orderable: false }, { data: 'lead.status_id', name: 'lead.status_id', orderable: false }, { data: 'last_customer_email', name: 'last_customer_email', orderable: true }, @@ -306,7 +308,7 @@ } } ); } );*/ - this.api().columns(14).every( function () { + this.api().columns(15).every( function () { var column = this; var title = $(column.header()).html(); var select = $('') @@ -402,12 +404,9 @@ function get_popover_content() { - - - if ($(this).data('booking_id')) { var data = {}; - data['action'] = 'get_popover_booking_services'; + data['action'] = $(this).data('action'); data['booking_id'] = $(this).data('booking_id'); $(this).addClass("loading"); var icontent = $.ajax({ diff --git a/resources/views/settings/travel_country/detail.blade.php b/resources/views/settings/travel_country/detail.blade.php index 82b1f6e..c169ad3 100755 --- a/resources/views/settings/travel_country/detail.blade.php +++ b/resources/views/settings/travel_country/detail.blade.php @@ -15,6 +15,7 @@ + @if($id > 0) @@ -33,6 +34,7 @@ + @endif @@ -102,7 +104,7 @@
- + @if($id > 0)
+ @endif
diff --git a/resources/views/travel/user/booking/mail/modal-new-mail.blade.php b/resources/views/travel/user/booking/mail/modal-new-mail.blade.php index 06b86cf..3a0c854 100644 --- a/resources/views/travel/user/booking/mail/modal-new-mail.blade.php +++ b/resources/views/travel/user/booking/mail/modal-new-mail.blade.php @@ -451,7 +451,9 @@ function callback_email_template_data_table(data) { if(data.status === 'success'){ - $('input#subject').val(data.response.subject + $('input#lead_title_id').val()); + if($('input#subject').val() === $('input#lead_title_id').val()){ + $('input#subject').val(data.response.subject + $('input#lead_title_id').val()); + } $("input#message-editor-fallback").val(data.html); $('#message-editor .ql-editor').html(data.html) $('#collapseModalEmailTemplate').collapse('hide'); diff --git a/resources/views/travel/user/booking/mail/modal-show-mail-inner.blade.php b/resources/views/travel/user/booking/mail/modal-show-mail-inner.blade.php index 16fb35d..f8a5d50 100644 --- a/resources/views/travel/user/booking/mail/modal-show-mail-inner.blade.php +++ b/resources/views/travel/user/booking/mail/modal-show-mail-inner.blade.php @@ -105,7 +105,7 @@ @endif - @if(isset($show_move_dirs)) + @if(isset($show_move_dirs) && $show_move_dirs)
{!! Form::open(['url' => route('customer_mail_detail', [$customer_mail->id, 'move-mail-fewo']), 'class' => 'move-mail-form']) !!} @@ -140,6 +140,23 @@
{!! Form::close() !!} +
+ {!! Form::open(['url' => route('customer_mail_detail', [$customer_mail->id, 'forward_fewo-email']), 'class' => 'forward-mail-form']) !!} +
+
+ + {{ Form::text('customer_mail_forward_email', $customer_mail->email, array('placeholder'=>'E-Mail', 'id'=>'customer_mail_forward_email', 'class'=>'form-control', 'required')) }} +
+
+ +
+ {!! Form::close() !!}
@endif - \ No newline at end of file + + + @if(isset($customer_mail->customer_mail)) +
+ @include('travel.user.booking.mail.modal-show-mail-inner', ['customer_mail' => $customer_mail->customer_mail, 'show_move_dirs' => false]) + @endif \ No newline at end of file diff --git a/resources/views/travel/user/booking/mail/modal-show-mail.blade.php b/resources/views/travel/user/booking/mail/modal-show-mail.blade.php index eb8d5c4..14bd6e9 100644 --- a/resources/views/travel/user/booking/mail/modal-show-mail.blade.php +++ b/resources/views/travel/user/booking/mail/modal-show-mail.blade.php @@ -10,9 +10,10 @@ @include('travel.user.booking.mail.modal-show-mail-inner', ['customer_mail' => $customer_mail, 'show_move_dirs' => true]) - @if($customer_mail->customer_fewo_mail) + {{-- @if($customer_mail->customer_fewo_mail) @include('travel.user.booking.mail.modal-show-mail-inner', ['customer_fewo_mail' => $customer_mail->customer_mail]) @endif + --}}