Mails etc. in Lead finish

This commit is contained in:
Kevin Adametz 2021-05-11 17:07:20 +02:00
parent 66ca252bfa
commit b362b93bca
45 changed files with 1460 additions and 418 deletions

View file

@ -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);
}

View file

@ -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() ? '<span data-order="1" class="badge badge-pill badge-success" data-lead_id="'.$lead->id.'" data-action="get_popover_lead_notice" data-placement="top" data-toggle="popover" title="letzte Notiz"><i class="fa fa-check"></i></span>' :
'<span data-order="0" class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
})
->addColumn('last_lead_email', function (Lead $lead) {
//umbuchen
if($lead->lead_mails->count()){
$lead_mail = $lead->lead_mails_sent_at->last();
return '<a data-order="'.$lead_mail->getSentAtRaw().'" href="'.route('lead_detail', [$lead->id]).'#collapseLeadMails" data-order="'.$lead_mail->sent_at.'"><span class="badge '.($lead_mail->is_answer ? 'badge-default' : 'badge-secondary').'">'.$lead_mail->sent_at.'</span></a>';
}
return '<span data-order="">-</span>';
})
->addColumn('action_delete', function (Lead $lead) {
return '<a href="' . route('lead_delete', [$lead->id, 'lead']) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
})
->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);
}

View file

@ -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 '<a href="'.route('customer_mail_detail', [$customer_mail->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
})
->addColumn('id', function (CustomerFewoMail $customer_mail) {
return '<a data-order="'.$customer_mail->id.'" href="'.route('customer_mail_detail', [$customer_mail->id]).'" data-id="'.$customer_mail->id.'">'.$customer_mail->id.'</a>';
})
->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 '<a data-order="'.$customer_mail->travel_user_booking_fewo_id.'" href="'.route('booking_detail', [$customer_mail->travel_user_booking_fewo_id]).'">'.$customer_mail->travel_user_booking_fewo_id.'</a>';
})
->addColumn('customer_id', function (CustomerFewoMail $customer_mail) {
return '<a data-order="'.$customer_mail->customer_id.'" href="'.route('customer_detail', [$customer_mail->customer_id]).'">'.$customer_mail->customer_id.'</a>';
})
->addColumn('send', function (CustomerFewoMail $customer_mail) {
return $customer_mail->send ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
})
->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 '<div class="message-checkbox mr-1">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input">
@ -325,54 +287,54 @@ class LeadMailController extends Controller
</label>
</div>';
})
->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 '<a href="javascript:void(0)" class="ion '.$icon.' d-block text-secondary text-big mr-3 customer-mail-ajax-action"
data-url="'.route('customer_fewo_mail_ajax').'" data-id="'.$customer_mail->id.'" data-important="'.$customer_mail->important.'" data-action="toggle_important"></a>';
data-url="'.route('lead_mail_ajax').'" data-id="'.$lead_mail->id.'" data-important="'.$lead_mail->important.'" data-action="toggle_important"></a>';
})
->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 ? '<i class="ion ion-ios-warning" style="opacity: 0.7"></i>' : '';
$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 ? '<i class="ion ion-ios-warning" style="opacity: 0.7"></i>' : '';
$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 '<a href="javascript:void(0)" class="badge '.$badge.'" data-toggle="modal"
data-target="#modals-load-content" data-id="'.$id.'" data-model="CustomerFewoMail"
data-target="#modals-load-content" data-id="'.$id.'" data-model="LeadMail"
data-action="'.$action.'" data-url="'.$url.'" data-redirect="back"
data-customer_mail_id="'.$customer_mail->id.'" data-route="'.route('customer_fewo_modal_load').'">
'.$to_icon.'<i class="ion '.$icon.' ui-w-30 text-center" style="opacity: 0.7"></i>'.$customer_mail->subject.'
'.($customer_mail->customer_fewo_files->count() ? '&nbsp; <i class="ion ion-md-attach"> <span class="badge badge-primary indicator">'.$customer_mail->customer_fewo_files->count().'</span></i>' : '');
data-lead_mail_id="'.$lead_mail->id.'" data-route="'.route('lead_mail_modal_load').'">
'.$to_icon.'<i class="ion '.$icon.' ui-w-30 text-center" style="opacity: 0.7"></i>'.$lead_mail->subject.'
'.($lead_mail->lead_files->count() ? '&nbsp; <i class="ion ion-md-attach"> <span class="badge badge-primary indicator">'.$lead_mail->lead_files->count().'</span></i>' : '');
})
->addColumn('date', function (CustomerFewoMail $customer_mail) {
if($customer_mail->send){
return '<span class="badge badge-success" style="background-color: #94ae59"><i class="fa fa-check-circle"></i> '.$customer_mail->sent_at.'</span>';
->addColumn('date', function (LeadMail $lead_mail) {
if($lead_mail->send){
return '<span class="badge badge-success" style="background-color: #94ae59"><i class="fa fa-check-circle"></i> '.$lead_mail->sent_at.'</span>';
}
return '<span class="badge badge-default"><i class="fa fa-times-circle"></i> '.$customer_mail->sent_at.'</span>';
return '<span class="badge badge-default"><i class="fa fa-times-circle"></i> '.$lead_mail->sent_at.'</span>';
})
->addColumn('action', function (CustomerFewoMail $customer_mail) {
->addColumn('action', function (LeadMail $lead_mail) {
$ret = '';
if(!$customer_mail->draft){
if(!$lead_mail->draft){
$ret = '<a href="javascript:void(0)" class="btn btn-xs btn-secondary" data-toggle="modal"
data-target="#modals-load-content" data-id="reply-send" data-model="customerMail" data-action="new-customer-mail"
data-url="'.route('customer_fewo_mail_send_mail').'" data-redirect="back" data-customer_mail_id="'.$customer_mail->id.'"
data-travel_user_booking_fewo_id="'.$customer_mail->travel_user_booking_fewo_id.'" data-route="'.route('customer_fewo_modal_load').'" data-customer_mail_dir="'.$customer_mail->dir.'" data-customer_subdir="'.$customer_mail->subdir.'">
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.'">
<span title="Antwort auf E-Mail senden" data-placement="left" rel="tooltip"><i class="ion ion-ios-redo"></i> <i class="ion ion-md-mail-open"></i></span>
</a>
&nbsp;
<a href="javascript:void(0)" class="btn btn-xs btn-default" data-toggle="modal"
data-target="#modals-load-content" data-id="reply-save" data-model="customerMail" data-action="reply-customer-mail"
data-url="'.route('customer_fewo_mail_reply_mail').'" data-redirect="back" data-customer_mail_id="'.$customer_mail->id.'"
data-travel_user_booking_fewo_id="'.$customer_mail->travel_user_booking_fewo_id.'" data-route="'.route('customer_fewo_modal_load').'" data-customer_mail_dir="'.$customer_mail->dir.'" data-customer_mail_subdir="'.$customer_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.'">
<span title="Antwort auf E-Mail speichern" data-placement="left" rel="tooltip"><i class="ion ion-ios-redo"></i> <i class="ion ion-md-mail-unread"></i></span>
</a>
&nbsp;';
}
$ret .= '<a href="'.route('customer_fewo_mail_delete', [$customer_mail->id]).'" class="btn btn-xs btn-default text-danger" onclick="return confirm(\'In den Papierkorb verschieben?\');"><i class="ion ion-md-trash"></i></a>';
$ret .= '<a href="'.route('lead_mail_delete', [$lead_mail->id]).'" class="btn btn-xs btn-default text-danger" onclick="return confirm(\'In den Papierkorb verschieben?\');"><i class="ion ion-md-trash"></i></a>';
return '<div style="white-space: nowrap;">'.$ret.'</div>';
})

View file

@ -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 .= "</div>";
return $back;
})
->addColumn('booking_fewo_notice', function (TravelUserBookingFewo $travel_user_booking_fewo) {
return $travel_user_booking_fewo->booking_fewo_notices->count() ? '<span data-order="1" class="badge badge-pill badge-success" data-travel_user_booking_fewo_id="'.$travel_user_booking_fewo->id.'" data-action="get_popover_fewo_notice" data-placement="top" data-toggle="popover" title="letzte Notiz"><i class="fa fa-check"></i></span>' :
'<span data-order="0" class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
})
->addColumn('action_delete', function (TravelUserBookingFewo $travel_user_booking_fewo) {
return '<a href="' . route('travel_user_booking_fewo_delete', [$travel_user_booking_fewo->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
})
@ -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);
}
}

View file

@ -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) {

View file

@ -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 '<span data-order="0">-</span>';
}
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();
}
}

View file

@ -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();
}
}
}

View file

@ -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,

View file

@ -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 .= "&lt;".$customer_mail->email."&gt; ".$customer_mail->sent_at."\n";
$ret .= "<strong>".$customer_mail->subject."</strong>\n";
$ret .= $customer_mail->message;
$ret .= $lead_mail->is_answer ? "Antwort von: " : "Gesendet an: ";
$ret .= "&lt;".$lead_mail->email."&gt; ".$lead_mail->sent_at."\n";
$ret .= "<strong>".$lead_mail->subject."</strong>\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();
}
}

View file

@ -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){

View file

@ -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.*?>(.*?)<\/placeholder>/', '$1', $content);
$content = preg_replace('/<span contenteditable="false">(.*?)<\/span>/', '$1', $content);
return $content;
}
}

View file

@ -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);

View file

@ -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);

View file

@ -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');
});
}

View file

@ -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();

View file

@ -85,6 +85,7 @@
@endif
@endforeach
@foreach($booking::$customer_mail_dirs as $dir_id => $customer_mail_dir)
@php($badge = "badge-outline-primary")
<a href="javascript:void(0)" class="d-flex justify-content-between align-items-center py-2 px-4 sidebox-nav-item"
data-dir="{{$dir_id}}" data-subdir="0" data-icon="{{$customer_mail_dir['icon']}}" data-name="{{$customer_mail_dir['name']}}">
<div class="item">

View file

@ -30,26 +30,6 @@
</div>
</div>
<hr class="border-light m-0">
<!-- / Header -->
{{-- <!-- Controls -->
<div class="media flex-wrap align-items-center p-2">
<div class="media-body d-flex flex-wrap flex-basis-100 flex-basis-sm-auto">
<button type="button" class="btn btn-default borderless md-btn-flat icon-btn messages-tooltip text-muted mr-3" title="Back"><i class="ion ion-md-arrow-back"></i></button>
<button type="button" class="btn btn-default borderless md-btn-flat icon-btn messages-tooltip text-muted" title="Mark as unread"><i class="ion ion-md-mail-unread"></i></button>
<button type="button" class="btn btn-default borderless md-btn-flat icon-btn messages-tooltip text-muted" title="Mark as important"><i class="ion ion-md-alert"></i></button>
<button type="button" class="btn btn-default borderless md-btn-flat icon-btn messages-tooltip text-muted" title="Move to spam"><i class="ion ion-md-folder-open"></i></button>
<button type="button" class="btn btn-default borderless md-btn-flat icon-btn messages-tooltip text-muted" title="Move to trash"><i class="ion ion-md-trash"></i></button>
</div>
<div class="d-flex flex-wrap align-items-center ml-auto">
<button type="button" class="btn btn-default borderless md-btn-flat text-muted px-3"><i class="ion ion-ios-undo"></i>&nbsp; Reply</button>
<div class="text-lighter">|</div>
<button type="button" class="btn btn-default borderless md-btn-flat text-muted px-3">Forward &nbsp;<i class="ion ion-ios-redo"></i></button>
</div>
</div>
<hr class="border-light m-0">
<!-- / Controls -->
--}}
<div class="p-4">
{!! nl2br($customer_mail->message) !!}
</div>
@ -152,7 +132,7 @@
</div>
<div class="col-sm-6">
<button type="submit" class="btn btn-xs btn-default float-right mt-1" onclick="return confirm('{{__('Wirklich weiterleiten? E-Mail wird erneut gesendet!')}}');"><i class="ion ion-ios-send"></i>&nbsp; weiterleiten</button>
</div
</div>
</div>
{!! Form::close() !!}
</div>

View file

@ -236,7 +236,7 @@
@endforeach
@endif
</div>
<div class="card-body mb-2" style="background: #fff; border: 1px solid rgba(24, 28, 33, 0.06);">
<h4>{{__('Notizen') }} FeWo <span class=" text-muted">letzten 10</span></h4>
@ -269,6 +269,39 @@
@endforeach
@endif
</div>
<div class="card-body mb-2" style="background: #fff; border: 1px solid rgba(24, 28, 33, 0.06);">
<h4>{{__('Notizen') }} Anfragen <span class=" text-muted">letzten 10</span></h4>
@if($last_lead_notices)
@foreach($last_lead_notices as $lead_notice)
<div class="row">
<div class="col-sm-12">
@if($lead_notice->from_user_id === \Auth::user()->id)
<div class="bg-primary rounded py-2 px-3 mr-3 text-white mb-2">
@else
<div class="bg-secondary rounded py-2 px-3 mr-3 mb-2">
@endif
<div class="font-weight-semibold mb-1">{{ $lead_notice->getName() }} | {{ $lead_notice->created_at->format("d.m.Y - H:i:s") }}
@if($lead_notice->edit_at != null)
| <i class="ion ion-ios-create"></i> {{ $lead_notice->edit_at->format("d.m.Y - H:i:s") }}
@endif
| <a class="btn btn-white btn-xs " href="{{ route('lead_detail', [$lead_notice->lead_id]) }}#collapseLeadNotice">zur Buchnung {{ $lead_notice->lead_id }}</a>
</div>
{!! nl2br($lead_notice->message) !!}
</div>
</div>
</div>
{{-- <div class="col-sm-12">
<div class="bg-lighter rounded py-2 px-3 mr-3 mb-2">
<div class="font-weight-semibold mb-1">You | {{ $lead_notice->created_at->format("d.m.Y H:i:s") }}</div>
{!! nl2br($lead_notice->message) !!}
</div>
</div>
--}}
@endforeach
@endif
</div>
@endif
<div class="card-body mb-2" style="background: #fff; border: 1px solid rgba(24, 28, 33, 0.06);">

View file

@ -1,43 +1,42 @@
<div class="card mb-2">
<h6 class="card-header bg-primary text-white py-2" data-toggle="collapse" data-target="#collapseBookingMails" aria-expanded="false" aria-controls="collapseBookingMails">
<h6 class="card-header bg-primary text-white py-2" data-toggle="collapse" data-target="#collapseLeadMails" aria-expanded="false" aria-controls="collapseLeadMails">
<strong style="line-height: 1.6em">E-Mails</strong>
<span class="badge badge-secondary">{{$travel_user_booking_fewo->customer_fewo_mails->count()}}</span>
<span class="badge badge-secondary">{{$lead->lead_mails->count()}}</span>
</h6>
<div class="collapse" id="collapseBookingMails">
<div class="collapse" id="collapseLeadMails">
<div class="container-fluid d-flex align-items-stretch flex-grow-1 p-0">
<!-- `.messages-wrapper` fills all available space of container -->
<div class="messages-wrapper">
<!-- Messages sidebox -->
<div class="messages-sidebox messages-scroll bg-body border-right">
<div class="py-3 px-4">
<div class="media align-items-center">
<div class="media-body text-center">
<button type="button" class="btn btn-sm btn-secondary mb-3 btn-compare-customer-mails" data-toggle="modal"
data-target="#modals-load-content"
data-id="new-send"
data-model="CustomerFewoMail"
data-action="new-customer-mail"
data-url="{{route('customer_fewo_mail_send_mail')}}"
data-model="LeadMail"
data-action="new-lead-mail"
data-url="{{route('lead_mail_send_mail')}}"
data-redirect="back"
data-travel_user_booking_fewo_id="{{$travel_user_booking_fewo->id}}"
data-customer_mail_dir="0"
data-customer_mail_subdir="0"
data-route="{{ route('customer_fewo_modal_load') }}"><i class="ion ion-md-mail-open"></i>&nbsp;E-Mail schreiben</button>
data-lead_id="{{$lead->id}}"
data-lead_mail_dir="0"
data-lead_mail_subdir="0"
data-route="{{ route('lead_mail_modal_load') }}"><i class="ion ion-md-mail-open"></i>&nbsp;E-Mail schreiben</button>
<button type="button" class="btn btn-sm btn-next btn-compare-customer-mails" data-toggle="modal"
data-target="#modals-load-content"
data-id="new-save"
data-model="CustomerFewoMail"
data-action="reply-customer-mail"
data-url="{{route('customer_fewo_mail_reply_mail')}}"
data-model="LeadMail"
data-action="reply-lead-mail"
data-url="{{route('lead_mail_reply_mail')}}"
data-redirect="back"
data-travel_user_booking_fewo_id="{{$travel_user_booking_fewo->id}}"
data-customer_mail_dir="0"
data-customer_mail_subdir="0"
data-route="{{ route('customer_fewo_modal_load') }}"><i class="ion ion-md-mail-unread"></i>&nbsp;Antwort speichern</button>
data-lead_id="{{$lead->id}}"
data-lead_mail_dir="0"
data-lead_mail_subdir="0"
data-route="{{ route('lead_mail_modal_load') }}"><i class="ion ion-md-mail-unread"></i>&nbsp;Antwort speichern</button>
</div>
<a href="javascript:void(0)" class="messages-sidebox-toggler d-lg-none d-block text-muted text-large font-weight-light pl-4">&times;</a>
</div>
@ -62,32 +61,30 @@
</style>
<!-- Mail boxes -->
@foreach(\App\Services\BookingFewo::getCustomerMailDirs() as $customer_mail_dir)
@php($badge = $customer_mail_dir->pos === 0 ? "badge-primary" : "badge-outline-primary")
<a href="javascript:void(0)" class="d-flex justify-content-between align-items-center py-2 px-4 sidebox-nav-item @if($customer_mail_dir->pos === 0) active @endif"
data-dir="{{$customer_mail_dir->pos}}" data-subdir="0" data-icon="{{$customer_mail_dir->getArrayContent('icon')}}" data-name="{{$customer_mail_dir->name}}">
@foreach(\App\Services\Lead::getCustomerMailDirs() as $lead_mail_dir)
@php($badge = $lead_mail_dir->pos === 0 ? "badge-primary" : "badge-outline-primary")
<a href="javascript:void(0)" class="d-flex justify-content-between align-items-center py-2 px-4 sidebox-nav-item @if($lead_mail_dir->pos === 0) active @endif"
data-dir="{{$lead_mail_dir->pos}}" data-subdir="0" data-icon="{{$lead_mail_dir->getArrayContent('icon')}}" data-name="{{$lead_mail_dir->name}}">
<div class="item">
<i class="ion {{$customer_mail_dir->getArrayContent('icon')}}"></i> {{$customer_mail_dir->name}}
<i class="ion {{$lead_mail_dir->getArrayContent('icon')}}"></i> {{$lead_mail_dir->name}}
</div>
<div class="badge {{$badge}}">{{$travel_user_booking_fewo->countCustomerMailsBy($customer_mail_dir->pos)}}</div>
<div class="badge {{$badge}}">{{$lead->countLeadMailsBy($lead_mail_dir->pos)}}</div>
</a>
@endforeach
@foreach($travel_user_booking_fewo::$customer_mail_dirs as $dir_id => $customer_mail_dir)
@foreach($lead::$lead_mail_dirs as $dir_id => $lead_mail_dir)
@php($badge = "badge-outline-primary")
<a href="javascript:void(0)" class="d-flex justify-content-between align-items-center py-2 px-4 sidebox-nav-item"
data-dir="{{$dir_id}}" data-subdir="0" data-icon="{{$customer_mail_dir['icon']}}" data-name="{{$customer_mail_dir['name']}}">
data-dir="{{$dir_id}}" data-subdir="0" data-icon="{{$lead_mail_dir['icon']}}" data-name="{{$lead_mail_dir['name']}}">
<div class="item">
<i class="ion {{$customer_mail_dir['icon']}}"></i> {{$customer_mail_dir['name']}}
<i class="ion {{$lead_mail_dir['icon']}}"></i> {{$lead_mail_dir['name']}}
</div>
<div class="badge {{$badge}}">{{$travel_user_booking_fewo->countCustomerMailsBy($dir_id)}}</div>
<div class="badge {{$badge}}">{{$lead->countLeadMailsBy($dir_id)}}</div>
</a>
@endforeach
<hr class="border-light m-4">
</div>
<!-- / Messages sidebox -->
<!-- Messages content wrapper -->
<div class="d-flex flex-column w-100">
<!-- Header -->
<div class="flex-grow-0">
<h4 class="media align-items-center font-weight-bold container-p-x py-3 py-lg-4 m-0">
<a href="javascript:void(0)" class="messages-sidebox-toggler d-lg-none d-block align-self-center text-muted px-3 mr-3"><i class="ion ion-md-more"></i></a>
@ -98,22 +95,18 @@
</h4>
<hr class="border-light m-0">
</div>
<!-- / Header -->
<style>
div.dataTables_info, div.dataTables_paginate {
padding: 10px;
}
</style>
<!-- Wrap `.messages-scroll` to properly position scroll area. Remove this wrapper if you don't need scroll -->
<div class="flex-grow-1 position-relative">
<!-- Remove `.messages-scroll` and add `.flex-grow-1` if you don't need scroll -->
<div class="messages-content flex-grow-1">
<div class="table-responsive" id="customer_mails_table">
<input type="hidden" name="travel_user_booking_fewo_id" value="{{$travel_user_booking_fewo->id}}">
<input type="hidden" name="customer_mail_dir" value="0">
<input type="hidden" name="customer_mail_subdir" value="">
<table id="datatables-customer-mails" class="table table-striped">
<div class="table-responsive" id="lead_mails_table">
<input type="hidden" name="lead_id" value="{{$lead->id}}">
<input type="hidden" name="lead_mail_dir" value="0">
<input type="hidden" name="lead_mail_subdir" value="">
<table id="datatables-lead-mails" class="table table-striped">
<thead>
<tr>
<th>&nbsp;</th>
@ -128,10 +121,10 @@
</table>
</div>
</div><!-- / .messages-content -->
</div>
</div>
</div>
</div><!-- / .messages-wrapper -->
</div>
</div>
</div>
</div>

View file

@ -4,12 +4,8 @@
<style>
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.btn-xs {
line-height: 1.3em;
@ -91,10 +87,7 @@
{!! Form::close() !!}
@if($id !== "new")
{{--
@include('lead._detail_mails')
--}}
@include('lead._detail_mails')
@include('lead._detail_files')
@endif
@ -105,9 +98,6 @@
<a href="{{ make_old_url('/index.php/leads/'.$lead->id.'/edit') }}" class="btn btn-sm btn-default float-right">{{ __('zurück ins CRM v2') }}</a>
</div>
<script>
$(document).ready(function() {
@ -165,20 +155,18 @@
}
init_site();
/*
var oTable = $('#datatables-customer-mails').DataTable({
var oTable = $('#datatables-lead-mails').DataTable({
"processing": true,
"serverSide": true,
"searching": false,
ajax: {
url: '{!! route( 'customer_fewo_mail_data_table' ) !!}',
url: '{!! route( 'lead_mail_data_table' ) !!}',
data: function(d) {
d.model = 'CustomerFewoMail';
d.travel_user_booking_fewo_id = $('#customer_mails_table input[name=travel_user_booking_fewo_id]').val();
d.customer_mail_dir = $('#customer_mails_table input[name=customer_mail_dir]').val();
d.customer_mail_subdir = $('#customer_mails_table input[name=customer_mail_subdir]').val();
d.model = 'LeadMail';
d.lead_id = $('#lead_mails_table input[name=lead_id]').val();
d.lead_mail_dir = $('#lead_mails_table input[name=lead_mail_dir]').val();
d.lead_mail_subdir = $('#lead_mails_table input[name=lead_mail_subdir]').val();
d.data_table_search = $('#dataTableInputSearchField').val();
}
},
@ -196,13 +184,13 @@
"url": "/js/German.json"
},
"drawCallback": function( settings ) {
$('#datatables-customer-mails [rel="tooltip"]').tooltip({trigger: "hover"});
$('#datatables-customer-mails .customer-mail-ajax-action').on('click', function (event) {
ajax_object_action(event, $(this), callback_customer_mails_data_table);
$('#datatables-lead-mails [rel="tooltip"]').tooltip({trigger: "hover"});
$('#datatables-lead-mails .lead-mail-ajax-action').on('click', function (event) {
ajax_object_action(event, $(this), callback_lead_mails_data_table);
});
}
});
function callback_customer_mails_data_table(data) {
function callback_lead_mails_data_table(data) {
if(data.status === 'success'){
oTable.draw();
}
@ -213,14 +201,14 @@
if($(this).hasClass('active')){
return;
}
$('#customer_mails_table input[name=customer_mail_dir]').val($(this).data('dir'));
$('#customer_mails_table input[name=customer_mail_subdir]').val($(this).data('subdir'));
$('#lead_mails_table input[name=lead_mail_dir]').val($(this).data('dir'));
$('#lead_mails_table input[name=lead_mail_subdir]').val($(this).data('subdir'));
if($(this).data('dir') <= 10){
$('.btn-compare-customer-mails').data('customer_mail_dir', $(this).data('dir'));
$('.btn-compare-customer-mails').data('customer_mail_subdir', $(this).data('subdir'));
$('.btn-compare-customer-mails').prop('disabled', false);
$('.btn-compare-lead-mails').data('lead_mail_dir', $(this).data('dir'));
$('.btn-compare-lead-mails').data('lead_mail_subdir', $(this).data('subdir'));
$('.btn-compare-lead-mails').prop('disabled', false);
}else{
$('.btn-compare-customer-mails').prop('disabled', true);
$('.btn-compare-lead-mails').prop('disabled', true);
}
oTable.draw();
$('.messages-wrapper .sidebox-nav-item').removeClass('active');
@ -236,9 +224,5 @@
});
});
*/
});
</script>
</script>
@endsection

View file

@ -8,7 +8,7 @@
<div class="card">
<div class="card-datatable table-responsive">
<table class="datatables-leads table table-striped table-bordered">
<table class="datatables-leads table table-striped table-bordered" id="datatables-leads">
<thead>
<tr>
@ -19,8 +19,11 @@
<th>{{__('Nachname')}}</th>
<th>{{__('E-Mail')}}</th>
<th>{{__('Anfrage-Datum')}}</th>
<th>{{__('N.')}}</th>
<th>{{__('Sachbearbeiter')}}</th>
<th>{{__('Status')}}</th>
<th>{{__('E-Mail')}}</th>
<th style="max-width: 60px;">{{__('delete')}}</th>
</tr>
</thead>
</table>
@ -29,7 +32,7 @@
<script>
$( document ).ready(function() {
$('.datatables-leads').dataTable({
var table = $('#datatables-leads').DataTable({
"processing": true,
"serverSide": true,
"ajax": '{!! route('data_table_leads') !!}',
@ -42,16 +45,55 @@
{ data: 'customer.name', name: 'customer.name' },
{ data: 'customer.email', name: 'customer.email' },
{ data: 'request_date', name: 'request_date' },
{ data: 'lead_notice', name: 'lead_notice', orderable: false },
{ data: 'sf_guard_user.last_name', name: 'sf_guard_user.last_name', searchable: false },
{ data: 'status', name: 'status' },
{ data: 'last_lead_email', name: 'last_lead_email', orderable: true },
{ data: 'action_delete', orderable: false, searchable: false},
],
"bLengthChange": false,
"iDisplayLength": 100,
"language": {
"url": "/js/German.json"
},
drawCallback: function () {
$('#datatables-leads [rel="tooltip"]').tooltip({trigger: "hover"});
$('#datatables-leads [data-toggle="popover"]').popover({trigger: "hover", content: get_popover_content, html: true,});
}
});
function get_popover_content() {
if ($(this).data('lead_id')) {
var data = {};
data['action'] = $(this).data('action');
data['lead_id'] = $(this).data('lead_id');
$(this).addClass("loading");
var icontent = $.ajax({
url: '{!! route( 'lead_ajax_requests' ) !!}',
data: data,
type: "POST",
dataType: "html",
cache: false,
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
encode: true,
async: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function() {
// just get the response
},
error: function() {
// nothing
}
}).responseText;
$(this).removeClass("loading");
return icontent;
}
return "Keine Buchungs-ID";
}
});
</script>

View file

@ -0,0 +1,99 @@
<div class="table-responsive border-bottom mb-2">
<table class="table table-striped table-sm" id="table-modal-booking-files">
<thead>
<tr>
<th>#</th>
<th>Datei</th>
<th>Inhalt</th>
<th>Datum</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
@php($booking_files_count = 1)
@if($booking->fewo_lodging)
<tr>
<th scope="row">{{$booking_files_count++}}</th>
<td>
<a target="_blank" href="{{ route('customer_file_show', ['fewo_instruction_pdf', $booking->fewo_lodging->id, 'stream']) }}" class="badge badge-md badge-next">
<i class="fa fa-file-pdf mr-1"></i> {{\App\Services\BookingFewo::getFeWoInstructionPDFName($booking->fewo_lodging)}}
</a>
</td>
<td>
application/pdf
</td>
<td>-</td>
<td>
<button data-target="{{ route('customer_file_show', ['fewo_instruction_pdf', $booking->fewo_lodging->id, 'stream']) }}" data-name="{{\App\Services\BookingFewo::getFeWoInstructionPDFName($booking->fewo_lodging)}}" class="btn btn-xs btn-primary add-file-to-attachment"
title="als Anhang hinzufügen" data-placement="left" rel="tooltip">
<i class="fa fa-cloud-download-alt"></i>
</button>
</td>
</tr>
@endif
@foreach(\App\Services\BookingFewo::contentFiles() as $content_file)
@if($file = \App\Models\CMSContent::getModelBySlug($content_file))
<tr>
<th scope="row">{{$booking_files_count++}}</th>
<td>
<a target="_blank" href="{{ $file->getURL() }}" class="badge badge-md badge-next">
<i class="fa fa-file-pdf mr-1"></i> {{$file->name}}
</a>
</td>
<td>
{{ $file->formatBytes() }}
</td>
<td>{{\App\Services\Util::_format_date($file->created_at, 'date')}}</td>
<td>
<button data-target="{{ $file->getURL() }}" data-name="{{ $file->name }}" class="btn btn-xs btn-primary add-file-to-attachment"
title="als Anhang hinzufügen" data-placement="left" rel="tooltip">
<i class="fa fa-cloud-download-alt"></i>
</button>
</td>
</tr>
@endif
@endforeach
@if($booking->booking_files)
@foreach($booking->booking_files as $booking_file)
<tr>
<th scope="row">{{$booking_files_count++}}</th>
<td>
<a target="_blank" href="{{ $booking_file->getURL() }}" class="badge badge-md badge-secondary">
<i class="{{$booking_file->getIconExt()}} mr-1"></i> {{ $booking_file->original_name }}
</a>
</td>
<td>
{{ $booking_file->mine }} | {{ $booking_file->formatBytes() }}
</td>
<td>{{\App\Services\Util::_format_date($booking_file->created_at, 'date')}}</td>
<td>
<button data-target="{{ $booking_file->getURL() }}" data-name="{{ $booking_file->original_name }}" class="btn btn-xs btn-primary add-file-to-attachment"
title="als Anhang hinzufügen" data-placement="left" rel="tooltip">
<i class="fa fa-cloud-download-alt"></i>
</button>
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#table-modal-booking-files [rel="tooltip"]').tooltip({trigger: "hover"});
$('#table-modal-booking-files .add-file-to-attachment').on('click', function (event) {
var $elem = $('<div/>');
$elem.data('action', 'add_attachment');
$elem.data('id', 'new');
$elem.data('url', '{{route('customer_fewo_mail_ajax')}}');
$elem.data('target', $(this).data('target'));
$elem.data('name', $(this).data('name'));
ajax_object_action(event, $elem, callback_ajax_add_attachment);
});
});
</script>

View file

@ -0,0 +1,78 @@
<div class="table-responsive border-bottom mb-2">
<table class="table table-striped table-sm" id="table-modal-lead-files">
<thead>
<tr>
<th>#</th>
<th>Datei</th>
<th>Inhalt</th>
<th>Datum</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
@php($lead_files_count = 1)
@foreach(\App\Services\Lead::contentFiles() as $content_file)
@if($file = \App\Models\CMSContent::getModelBySlug($content_file))
<tr>
<th scope="row">{{$lead_files_count++}}</th>
<td>
<a target="_blank" href="{{ $file->getURL() }}" class="badge badge-md badge-next">
<i class="fa fa-file-pdf mr-1"></i> {{$file->name}}
</a>
</td>
<td>
{{ $file->formatBytes() }}
</td>
<td>{{\App\Services\Util::_format_date($file->created_at, 'date')}}</td>
<td>
<button data-target="{{ $file->getURL() }}" data-name="{{ $file->name }}" class="btn btn-xs btn-primary add-file-to-attachment"
title="als Anhang hinzufügen" data-placement="left" rel="tooltip">
<i class="fa fa-cloud-download-alt"></i>
</button>
</td>
</tr>
@endif
@endforeach
@if($lead->lead_files)
@foreach($lead->lead_files as $lead_file)
<tr>
<th scope="row">{{$lead_files_count++}}</th>
<td>
<a target="_blank" href="{{ $lead_file->getURL() }}" class="badge badge-md badge-secondary">
<i class="{{$lead_file->getIconExt()}} mr-1"></i> {{ $lead_file->original_name }}
</a>
</td>
<td>
{{ $lead_file->mine }} | {{ $lead_file->formatBytes() }}
</td>
<td>{{\App\Services\Util::_format_date($lead_file->created_at, 'date')}}</td>
<td>
<button data-target="{{ $lead_file->getURL() }}" data-name="{{ $lead_file->original_name }}" class="btn btn-xs btn-primary add-file-to-attachment"
title="als Anhang hinzufügen" data-placement="left" rel="tooltip">
<i class="fa fa-cloud-download-alt"></i>
</button>
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('#table-modal-lead-files [rel="tooltip"]').tooltip({trigger: "hover"});
$('#table-modal-lead-files .add-file-to-attachment').on('click', function (event) {
var $elem = $('<div/>');
$elem.data('action', 'add_attachment');
$elem.data('id', 'new');
$elem.data('url', '{{route('lead_mail_ajax')}}');
$elem.data('target', $(this).data('target'));
$elem.data('name', $(this).data('name'));
ajax_object_action(event, $elem, callback_ajax_add_attachment);
});
});
</script>

View file

@ -0,0 +1,508 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">
{{ $value->title }}
@if($value->subtitle)
<br><small class="text-muted">{{$value->subtitle}}</small>
@endif
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
</div>
<div class="modal-body">
{!! Form::open(['url' => $value->url, 'class' => '', 'id'=>'lead-mail-form']) !!}
{{ Form::hidden('lead_id', $value->id) }}
{{ Form::hidden('action', '') }}
@if(isset($value->save_lead_mail_id))
{{ Form::hidden('save_lead_mail_id', $value->save_lead_mail_id) }}
@endif
@if($value->show === 'single' || $value->show === 'reply')
<div class="row">
@if(isset($value->lead))
<div class="col-sm-4">
<strong>Anfrage: </strong><br>
({{ $value->lead->id }})
</div>
<div class="col-sm-4">
@if($value->lead->customer)
<strong>Kunde: </strong><br>{{ $value->lead->customer->getSalutation() }} {{ $value->lead->customer->title }} {{ $value->lead->customer->firstname }} {{ $value->lead->customer->name }}
({{$value->lead->id}})
@endif
</div>
@endif
<div class="col-sm-4">
@if(isset($value->lead_mail))
<strong>Antwort auf: </strong><br>{{ $value->lead_mail->id }} || {{ $value->lead_mail->subject }}
@endif
</div>
<div class="col-sm-12">
<hr>
</div>
</div>
@endif
@if(isset($value->customers))
@if($value->show === 'single')
<div class="form-row">
<div class="form-group col-sm-12 mb-1">
<label for="to" class="form-label">E-Mail senden an:*</label>
@foreach($value->customers as $key=>$val)
<label class="custom-control custom-checkbox mt-2" style="margin-right: 20px;">
{!! Form::checkbox('send_mail_to['.$key.']', 1, $key, ['class'=>'custom-control-input']) !!}
<span class="custom-control-label">
<div class="row">
<div class="col-sm-6">
{{ Form::text('send_mail_to_mail['.$key.']', $val['email'], array('placeholder'=>'Erste E-Mail: Pflichtpfeld', 'id'=>'send_mail_to_mail_'.$key, 'class'=>'form-control', 'style'=>'margin-top: -8px;', 'required')) }}
</div>
<div class="col-sm-6">
<button type="button" class="btn btn-sm btn-outline-primary mt-1 mb-2" data-toggle="collapse" data-target="#collapseModalNewMailRe" aria-expanded="false" aria-controls="collapseModalNewMailRe"><i class="fa fa-plus-circle"></i> Weitere Empfänger</button>
</div>
</div>
</span>
</label>
@endforeach
</div>
</div>
<div class="collapse form-row" id="collapseModalNewMailRe">
<div class="form-group col-sm-4">
<label class="form-label" for="recipient">TO: (weitere Empfänger)</label>
{{ Form::textarea('recipient', $value->recipient, ['class' => 'form-control', 'rows'=>4]) }}
</div>
<div class="form-group col-sm-4">
<label class="form-label" for="cc">CC: (Kopie Empfänger)</label>
{{ Form::textarea('cc', $value->cc, ['class' => 'form-control', 'rows'=>4]) }}
</div>
<div class="form-group col-sm-4">
<label class="form-label" for="bcc">BCC: (Blindkopie Empfänger)</label>
{{ Form::textarea('bcc', $value->bcc, ['class' => 'form-control', 'rows'=>4]) }}
</div>
</div>
@endif
@if($value->show === 'multi')
<div class="form-row">
<div class="form-group col-sm-12 mb-1">
<label for="to" class="form-label">E-Mail senden an:</label>
@foreach($value->customers as $key=>$val)
<label class="custom-control custom-checkbox mt-2" style="margin-right: 20px;">
{!! Form::checkbox('send_mail_to['.$key.']', 1, $key, ['class'=>'custom-control-input']) !!}
<span class="custom-control-label">{{ $val['email'] }} | {{ $val['name'] }}</span>
</label>
@endforeach
</div>
</div>
@endif
@endif
@if($value->show === 'reply' && isset($value->lead))
<div class="form-row">
<div class="form-group col">
<label for="mail_from" class="form-label">E-Mail von:</label>
{{ Form::text('mail_from', $value->lead->customer ? $value->lead->customer->email : '', array('placeholder'=>'E-Mail Adresse von', 'id'=>'mail_from', 'class'=>'form-control', 'required')) }}
</div>
</div>
<div class="form-row">
<div class="form-group col">
<label for="sent_at" class="form-label">Gesendet am:</label>
{{ Form::text('sent_at', \Carbon::now()->format('d.m.Y H:i'), array('placeholder'=>__(\Carbon::now()->format('d.m.Y - H:i')), 'class'=>'form-control b-material-datetime-picker', 'id'=>'sent_at')) }}
</div>
</div>
@endif
<div class="form-row">
{{ Form::hidden('lead_title_id', $value->lead_title_id, array('id'=>'lead_title_id')) }}
<div class="form-group col">
<label for="subject" class="form-label">Betreff</label>
{{ Form::text('subject', $value->subject, array('placeholder'=>$value->s_placeholder, 'id'=>'subject', 'class'=>'form-control', 'required')) }}
</div>
</div>
<div class="form-group mb-1">
<label class="form-label" for="message">Nachricht</label>
@if($value->show === 'single' || $value->show === 'multi')
@if(Auth::user()->isPermission('sua-st-em'))
<div class="float-right small">Vorlage unter: <a href="{{route('admin_settings_emails')}}">Einstellungen -> E-Mails / Vorlagen</a></div>
@endif
@endif
<div id="message-editor-toolbar">
<span class="ql-formats">
<button class="ql-bold"></button>
<button class="ql-italic"></button>
<button class="ql-underline"></button>
<button class="ql-strike"></button>
</span>
<span class="ql-formats">
<button class="ql-header" value="1"></button>
<button class="ql-header" value="2"></button>
<button class="ql-blockquote"></button>
<button class="ql-code-block"></button>
</span>
<span class="ql-formats">
<button class="ql-list" value="ordered"></button>
<button class="ql-list" value="bullet"></button>
<button class="ql-indent" value="-1"></button>
<button class="ql-indent" value="+1"></button>
</span>
<span class="ql-formats">
<select class="ql-align"></select>
</span>
<span class="ql-formats">
<button class="ql-clean"></button>
</span>
<span class="ql-formats">
<select class="ql-placeholder">
{!! \App\Services\Placeholder::getBookingOptions() !!}
</select>
</span>
</div>
<div id="message-editor" style="height: 400px">{!! $value->message !!}</div>
{{ Form::textarea('message', $value->message, array('placeholder'=>$value->m_placeholder, 'id'=>'message-editor-fallback', 'class'=>'form-control d-none', 'rows'=>15)) }}
</div>
@if($value->show === 'single' || $value->show === 'multi')
<div class="row">
<div class="col-12">
<button type="button" class="btn btn-sm btn-outline-next mt-1 mb-3 float-left" data-toggle="collapse" data-target="#collapseModalEmailTemplate" aria-expanded="false" aria-controls="collapseModalEmailTemplate"><i class="ion ion-ios-mail"></i> E-Mail Vorlage laden</button>
</div>
<div class="collapse col-12" id="collapseModalEmailTemplate">
<hr class="mt-0">
<select class="custom-select" name="filter_email_templates_directory" id="filter_email_templates_directory" style="">
<option value="">Alle Verzeichniss</option>
@foreach($value->filter_email_templates_directories as $id=>$name)
<option value="{{$id}}" >{{$name}}</option>
@endforeach
</select>
<div class="table-responsive" id="email_templates_table">
<table id="datatables-email-templates" class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>{{__('Vorlage Bezeichnung')}}</th>
<th>{{__('Verzeichniss')}}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody class="">
</tbody>
</table>
</div>
<hr class="mt-1">
</div>
</div>
@endif
@if($value->show === 'single' || $value->show === 'reply')
<div class="form-row">
<div class="col-sm-6">
<label for="send_mail_dir" class="form-label">Ablegen unter:</label>
<select class="custom-select" name="dir" id="send_mail_dir">
@foreach(\App\Services\Lead::getCustomerMailDirs() as $lead_mail_dir)
<option value="{{$lead_mail_dir->pos}}" @if($value->lead_mail_dir == $lead_mail_dir->pos) selected @endif>{{$lead_mail_dir->name}}</option>
@endforeach
</select>
</div>
<div class="col-sm-6">
<label for="subdir" class="form-label">&nbsp;</label>
{{-- TODO load subdirs by pos id --}}
{{-- @if(isset($value->booking))
@foreach(\App\Services\Booking::getCustomerMailDirs() as $lead_mail_dir)
@if($lead_mail_dir->pos > 0)
<select class="custom-select send_mail_subdir" name="subdir" id="send_mail_subdir_{{$lead_mail_dir->pos}}">
<option value="0">keinen Unterordner</option>
@foreach($value->booking->travel_country->getMailDirs($lead_mail_dir->pos) as $mail_dir_id)
@php ($mail_dir_name = \App\Services\Booking::getCustomerMailName($lead_mail_dir, $mail_dir_id))
<option value="{{$mail_dir_id}}" @if($value->customer_mail_subdir == $mail_dir_id) selected @endif>{{$mail_dir_name}}</option>
@endforeach
</select>
@endif
@endforeach
@endif
--}}
</div>
</div>
@endif
@if(isset($value->lead_mail))
{{ Form::hidden('lead_mail_id', $value->lead_mail->id) }}
@endif
<hr>
{!! Form::close() !!}
<div class="row">
<div class="col-12">
@if($value->show === 'single' && isset($value->lead))
<button type="button" class="btn btn-sm btn-outline-primary mt-1 mb-2 float-right" data-toggle="collapse" data-target="#collapseModalLeadFiles" aria-expanded="false" aria-controls="collapseModalLeadFiles"><i class="fa fa-plus-circle"></i> Dateien aus Buchung</button>
@endif
<h5>Datei Anhänge</h5>
</div>
@if($value->show === 'single' && isset($value->lead))
<div class="collapse col-12" id="collapseModalLeadFiles">
@include('lead.modal-new-lead-files', ['lead'=>$value->lead])
</div>
@endif
<div class="col-12">
<div class="alert alert-danger alert-dismissable" style="display:none;"></div>
</div>
<div class="col-6" id="preview-mail-attachment">
@if(isset($value->lead_files))
@foreach($value->lead_files as $lead_file)
<div class="message-attachment ui-bordered p-2 mr-3 mb-3">
<div class="message-attachment-file display-4"><i class="mail-att-icon {{$lead_file->getIconExt()}}"></i></div>
<div class="media-body ml-3">
<strong class="message-attachment-filename">{{$lead_file->original_name}}</strong>
<div class="text-muted small mail-att-size">{{$lead_file->formatBytes()}}</div>
<div>
<a href="{{$lead_file->getURL()}}" target="_blank" class="mail-att-show">Vorschau</a> &nbsp;
<a href="javascript:void(0)" data-url="{{route('lead_mail_ajax')}}" data-id="{{$lead_file->id}}" data-action="delete_mail_attachment" class="mail-att-delete">löschen</a>
</div>
</div>
</div>
@endforeach
@endif
</div>
<div class="col-6">
{!! Form::open([ 'url' => route('lead_mail_upload_attachment', ['tmp']), 'method' => 'post', 'files' => true, 'enctype' => 'multipart/form-data', 'class' => 'dropzone', 'id' => 'uploadAttachmentFile' ]) !!}
<div class="fallback">
<input name="file" type="file" multiple>
</div>
{!! Form::close() !!}
</div>
</div>
@if(isset($value->lead_mail))
<hr>
@include('lead.modal-show-mail-inner', ['lead_mail' => $value->lead_mail])
@endif
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default float-left" data-dismiss="modal">schließen</button>
@if($value->show === 'single' || $value->show === 'multi')
@if($value->draft)
<button type="submit" class="btn btn-next submit-button-form" value="draft"><i class="ion ion-ios-save"></i> Entwurf speichern</button>
@endif
<button type="submit" class="btn btn-primary submit-button-form" value="send"><i class="ion ion-ios-mail-open"></i> E-Mail senden</button>
@endif
@if($value->show === 'reply')
<button type="submit" class="btn btn-primary submit-button-form" value="save"><i class="ion ion-ios-mail-open"></i> Antwort speichern</button>
@endif
</div>
<div class="message-attachment ui-bordered p-2 mr-3 mb-3 d-none" id="mail-attachment-template">
<div class="message-attachment-file display-4"><i class="mail-att-icon"></i></div>
<div class="media-body ml-3">
<strong class="message-attachment-filename"> </strong>
<div class="text-muted small mail-att-size"> </div>
<div>
<a href="javascript:void(0)" target="_blank" class="mail-att-show">Vorschau</a> &nbsp;
<a href="javascript:void(0)" class="mail-att-remove">entfernen</a>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function callback_ajax_add_attachment(response) {
if(response.error === false){
add_mail_attachment_preview(response);
}
}
function add_mail_attachment_preview(response){
console.log(response);
var template = $('#mail-attachment-template').clone()
.removeAttr('id').removeClass('d-none')
.attr('data-id', response.file_id);
template.find('.mail-att-icon').addClass(response.file_icon);
template.find('.message-attachment-filename').text(response.original_name);
template.find('.mail-att-size').text(response.file_format_bytes);
///'storage/file/{id}/{disk}
template.find('.mail-att-show').attr('href', response.file_url);
template.find('.mail-att-remove').on('click', function () {
$(this).parents('.message-attachment').remove();
});
$('#preview-mail-attachment').append(template);
}
function change_mail_subdir_select(){
var $dir_id = $('#send_mail_dir').val();
$('.send_mail_subdir').each(function () {
var send_mail_subdir = 'send_mail_subdir_' + $dir_id;
if($(this).attr('id') === send_mail_subdir){
$(this).prop('disabled', false);
$(this).show();
}else{
$(this).prop('disabled', true);
$(this).val(0);
$(this).hide();
}
})
}
$(document).ready(function() {
change_mail_subdir_select();
$('#send_mail_dir').on('change', function () {
change_mail_subdir_select();
});
if (!window.Quill) {
$('#message-editor,#message-editor-toolbar').remove();
$('#message-editor-fallback').removeClass('d-none');
} else {
Quill.register('modules/placeholder', PlaceholderModule.default(Quill))
//$('#message-editor-fallback').remove();
var quill = new Quill('#message-editor', {
debug: 'error',
modules: {
toolbar: '#message-editor-toolbar',
placeholder: {
placeholders: [
{!! \App\Services\Placeholder::getBookingQuill() !!}
]
}
},
placeholder: '{{$value->m_placeholder}}',
theme: 'snow'
});
}
$('.b-material-datetime-picker').bootstrapMaterialDatePicker({
weekStart: 1,
format : 'DD.MM.YYYY HH:mm',
shortTime: false,
nowButton : true,
clearButton: true,
lang: 'de',
//currentDate: ''
});
$(".submit-button-form").click(function(event) {
@if(isset($value->customers))
if($(this).val() === 'send' && !confirm('E-Mail wirklich senden?')){
event.preventDefault();
return;
}
@endif
$('#lead-mail-form input[name=action]').val($(this).val());
$("#message-editor-fallback").val($('#message-editor .ql-editor').html());
var message_attachment = $('#preview-mail-attachment').find('.message-attachment');
$.each( message_attachment, function( index, value ){
$('#lead-mail-form').append('<input type="hidden" name="message_attachment_id[]" value="'+$(value).data('id')+'">');
});
$( "#lead-mail-form" ).submit();
});
$("#preview-mail-attachment .mail-att-delete").click(function(event) {
_self = $(this);
if(!confirm('Angang wirklick löschen?')){
event.preventDefault();
return;
}
ajax_object_action(event, $(this), function (data) {
console.log(data);
if(data.status === 'success'){
_self.parents('.message-attachment').remove();
}
});
});
var emailTempplateTable = $('#datatables-email-templates').DataTable({
"processing": true,
"serverSide": true,
"searching": true,
"autoWidth": false,
ajax: {
url: '{!! route( 'email_template_data_table' ) !!}',
data: function(d) {
d.filter_email_templates_directory = $('select[name=filter_email_templates_directory]').val();
}
},
"columns": [
{ data: 'id', width: '8%', searchable: true },
{ data: 'name', name: 'name', width: '', searchable: true },
{ data: 'email_template_dir.name', name: 'email_template_dir.name', width: '25%', orderable: false, searchable: false },
{ data: 'action', width: '8%', orderable: false, searchable: false},
],
"bLengthChange": false,
"iDisplayLength": 10,
"orderSequence": ["desc", "asc"],
"order": [[ 0, "desc" ]],
"language": {
"url": "/js/German.json"
},
"drawCallback": function( settings ) {
$('#datatables-email-templates [rel="tooltip"]').tooltip({trigger: "hover"});
$('#datatables-email-templates .email-template-action').on('click', function (event) {
ajax_object_action(event, $(this), callback_email_template_data_table);
});
}
});
$('#filter_email_templates_directory').on('change', function(){
emailTempplateTable.draw();
});
function callback_email_template_data_table(data) {
if(data.status === 'success'){
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');
}
}
Dropzone.autoDiscover = false;
$("#uploadAttachmentFile").dropzone({
uploadMultiple: false,
parallelUploads: 1,
maxFilesize: 32,
addRemoveLinks: true,
dictDefaultMessage: '<i class="ion ion-ios-cloud-upload "></i>Hier klicken, oder Datei hier reinziehen (Drag&Drop)',
dictFallbackMessage: 'Ihr Browser unterstützt Drag&Drop Dateiuploads nicht',
dictFallbackText: 'Benutzen Sie das Formular um Ihre Dateien hochzuladen',
dictFileTooBig: "Die Datei ist zu groß. Die maximale Dateigröße beträgt 32 MB",
dictInvalidFileType: 'Eine Datei dieses Typs kann nicht hochgeladen werden',
dictResponseError: "Der Server hat ihre Anfrage mit Status error abgelehnt",
dictCancelUpload: 'Hochladen abbrechen',
dictCancelUploadConfirmation: null,
dictRemoveFile: 'Datei entfernen',
dictMaxFilesExceeded: 'Sie können keine weiteren Dateien mehr hochladen',
acceptedFiles: "image/jpeg,image/pjpeg,image/png,image/gif,application/pdf,text/plain",
// The setting up of the dropzone
init:function() {
this.on("removedfile", function(file) {
var _ele = $('.alert-danger');
_ele.fadeOut();
});
this.on("addedfile", function (file) {
var _ele = $('.alert-danger');
_ele.fadeOut();
});
},
error: function(file, response) {
var message
if($.type(response) === "string")
message = response; //dropzone sends it's own error messages in string
else
message = response.message;
var _ele = $('.alert-danger');
_ele.fadeIn();
console.log(message);
_ele.text(message);
},
success: function(file,response) {
// console.log(file);
// console.log(response);
if(response.error === false){
add_mail_attachment_preview(response);
this.removeFile(file);
}
}
});
});
</script>

View file

@ -0,0 +1,142 @@
<div class="card mb-2">
<!-- Header -->
<div class="media px-4 pt-4 pb-2">
<a href="javascript:void(0)" class="messages-sidebox-toggler d-lg-none d-block align-self-center text-muted text-large pr-3 mr-3"><i class="ion ion-md-more"></i></a>
<!-- Sender photo -->
<div class="media-body">
<!-- Sender & date -->
<div class="mb-1">
@if($lead_mail->is_answer)
Antwort von:<br>
@else
Gesendet an:<br>
@endif
&lt;<a href="mailto:{{$lead_mail->email}}">{{$lead_mail->email}}</a>&gt; {{$lead_mail->sent_at }}
@if($lead_mail->recipient)
<div>TO: {{\App\Services\Util::_implodeLines($lead_mail->recipient, ', ')}}</div>
@endif
@if($lead_mail->cc)
<div>CC: {{\App\Services\Util::_implodeLines($lead_mail->cc, ', ')}}</div>
@endif
@if($lead_mail->bcc)
<div>BCC: {{\App\Services\Util::_implodeLines($lead_mail->bcc, ', ')}}</div>
@endif
</div>
<!-- Subject -->
<h5 class="line-height-inherit m-0">{{$lead_mail->subject}}</h5>
</div>
</div>
<hr class="border-light m-0">
<div class="p-4">
{!! nl2br($lead_mail->message) !!}
</div>
<hr class="border-light m-0">
<!-- Message infos -->
<div class="px-4 pt-4 pb-2">
@if($lead_mail->customer)
<p><strong>Kunde: </strong>
{{ $lead_mail->customer->getSalutation() }} {{ $lead_mail->customer->title }} {{ $lead_mail->customer->firstname }} {{ $lead_mail->customer->name }}
@if($lead_mail->lead)
({{$lead_mail->lead->id}})
@endif
</p>
@endif
@if($lead_mail->lead)
<p><strong>Anfrage: </strong>
({{ $lead_mail->lead_id }})
</p>
@endif
@if($lead_mail->send)
<span class="badge badge-success">Mail gesendet</span>
<p>Datum: {{$lead_mail->sent_at}}</p>
@endif
@if($lead_mail->fail)
<span class="badge badge-danger">Mail Fehler</span>
<p>{{$lead_mail->error }}</p>
@endif
</div>
<!-- Message attachments -->
@if($lead_mail->lead_files)
<hr class="border-light m-0">
<div class="px-4 pt-4 pb-2">
<h6 class="small font-weight-semibold mb-4">Datei-Anhänge</h6>
<div class="row">
@foreach($lead_mail->lead_files as $file)
<div class="col-sm-12 col-md-6 col-xl-4">
<div class="message-attachment ui-bordered p-2 mr-3 mb-3">
<div class="message-attachment-file display-4"><i class="{{$file->getIconExt()}}"></i></div>
<div class="media-body ml-3">
<strong class="message-attachment-filename">{{$file->original_name}}</strong>
<div class="text-muted small">{{$file->formatBytes()}}</div>
<div>
<a href="{{$file->getURL()}}" target="_blank" class="mail-att-show">Vorschau</a> &nbsp;
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
@endif
@if(isset($show_move_dirs) && $show_move_dirs)
<hr class="border-light m-0">
<div class="px-4 pt-4 pb-2">
{!! Form::open(['url' => route('lead_mail_detail', [$lead_mail->id, 'move-mail-lead']), 'class' => 'move-mail-form']) !!}
<div class="form-row">
<div class="col-sm-6">
<label for="lead_mail_dir" class="form-label">Ablegen unter:</label>
<select class="custom-select lead_mail_dir" name="dir" id="lead_mail_dir">
@foreach(\App\Services\Lead::getCustomerMailDirs() as $lead_mail_dir)
<option value="{{$lead_mail_dir->pos}}" @if($lead_mail->dir == $lead_mail_dir->pos) selected @endif>{{$lead_mail_dir->name}}</option>
@endforeach
</select>
</div>
<div class="col-sm-6">
<button type="submit" class="btn btn-xs btn-default float-right mt-1"><i class="ion ion-ios-redo"></i>&nbsp; verschieben</button>
<label for="subdir" class="form-label">&nbsp;</label>
{{-- TODO load subdirs by pos id
@if($lead_mail->booking->travel_country)
@foreach(\App\Services\Booking::getCustomerMailDirs() as $lead_mail_dir)
@if($lead_mail_dir->pos > 0)
<select class="custom-select lead_mail_subdir" name="subdir" id="lead_mail_subdir_{{$lead_mail_dir->pos}}">
<option value="0">keinen Unterordner</option>
@foreach($lead_mail->booking->travel_country->getMailDirs($lead_mail_dir->pos) as $mail_dir_id)
@php ($mail_dir_name = \App\Services\Booking::getCustomerMailName($lead_mail_dir, $mail_dir_id))
<option value="{{$mail_dir_id}}" @if($lead_mail->subdir == $mail_dir_id) selected @endif>{{$mail_dir_name}}</option>
@endforeach
</select>
@endif
@endforeach
@endif
--}}
</div>
</div>
{!! Form::close() !!}
<hr>
{!! Form::open(['url' => route('lead_mail_detail', [$lead_mail->id, 'forward-mail-lead']), 'class' => 'forward-mail-form']) !!}
<div class="form-row">
<div class="col-sm-6">
<label for="lead_mail_forward_email" class="form-label">E-Mail weiterleiten:</label>
{{ Form::text('lead_mail_forward_email', $lead_mail->email, array('placeholder'=>'E-Mail', 'id'=>'lead_mail_forward_email', 'class'=>'form-control', 'required')) }}
</div>
<div class="col-sm-6">
<button type="submit" class="btn btn-xs btn-default float-right mt-1" onclick="return confirm('{{__('Wirklich weiterleiten? E-Mail wird erneut gesendet!')}}');"><i class="ion ion-ios-send"></i>&nbsp; weiterleiten</button>
</div>
</div>
{!! Form::close() !!}
</div>
@endif
</div>
@if(isset($lead_mail->lead_mail))
<hr>
@include('lead.modal-show-mail-inner', ['lead_mail' => $lead_mail->lead_mail, 'show_move_dirs' => false])
@endif

View file

@ -0,0 +1,50 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">
{{ $value->title }}
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
</div>
<div class="modal-body">
@include('lead.modal-show-mail-inner', ['lead_mail' => $lead_mail, 'show_move_dirs' => true])
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">schließen</button>
</div>
</div>
<script type="text/javascript">
function change_mail_subdir_select(_form){
var $dir_id = _form.find('#lead_mail_dir').val();
$('.lead_mail_subdir').each(function () {
var lead_mail_subdir = 'lead_mail_subdir_' + $dir_id;
if($(this).attr('id') === lead_mail_subdir){
$(this).prop('disabled', false);
$(this).show();
}else{
$(this).prop('disabled', true);
$(this).val(0);
$(this).hide();
}
})
}
$(document).ready(function() {
$('form.move-mail-form').each(function () {
var _form = $(this);
$(this).find('.lead_mail_dir').on('change', function () {
change_mail_subdir_select(_form);
_form.find('.btn-default').removeClass('btn-default').addClass('btn-primary');
});
$(this).find('.lead_mail_subdir').on('change', function () {
_form.find('.btn-default').removeClass('btn-default').addClass('btn-primary');
});
change_mail_subdir_select(_form);
});
});
</script>

View file

@ -73,6 +73,7 @@
</a>
@endforeach
@foreach($travel_user_booking_fewo::$customer_mail_dirs as $dir_id => $customer_mail_dir)
@php($badge = "badge-outline-primary")
<a href="javascript:void(0)" class="d-flex justify-content-between align-items-center py-2 px-4 sidebox-nav-item"
data-dir="{{$dir_id}}" data-subdir="0" data-icon="{{$customer_mail_dir['icon']}}" data-name="{{$customer_mail_dir['name']}}">
<div class="item">

View file

@ -41,7 +41,7 @@
<div class="card-datatable table-responsive py-2">
<input type="hidden" name="sort_travel_country_id" value="">
<input type="hidden" name="sort_travelagenda_id" value="">
<table id="datatables-default" class="table table-striped table-bordered">
<table id="datatables-fewos" class="table table-striped table-bordered">
<thead>
<tr>
<th style="max-width: 10px;">&nbsp;</th>
@ -52,6 +52,7 @@
<th>{{__('bis')}}</th>
<th>{{__('Eingetragen')}}</th>
<th>{{__('Mails')}}</th>
<th>{{__('N.')}}</th>
<th>{{__('Kanal')}}</th>
<th>{{__('Datum')}}</th>
<th>{{__('R.-Nr.')}}</th>
@ -67,7 +68,7 @@
<script>
$( document ).ready(function() {
var table =$('#datatables-default').DataTable({
var table =$('#datatables-fewos').DataTable({
"processing": true,
"serverSide": true,
"searching": true,
@ -87,6 +88,7 @@
{ data: 'to_date', name: 'to_date' },
{ data: 'is_calendar', name: 'is_calendar', orderable: false },
{ data: 'is_mail', name: 'is_mail', orderable: false },
{ data: 'booking_fewo_notice', name: 'booking_fewo_notice', orderable: false },
{ data: 'travel_booking_fewo_channel.name', name: 'travel_booking_fewo_channel.name' },
{ data: 'booking_date', name: 'booking_date' },
{ data: 'invoice_number', name: 'invoice_number' },
@ -97,6 +99,10 @@
"iDisplayLength": 50,
"language": {
"url": "/js/German.json"
},
drawCallback: function () {
$('#datatables-fewos [rel="tooltip"]').tooltip({trigger: "hover"});
$('#datatables-fewos [data-toggle="popover"]').popover({trigger: "hover", content: get_popover_content, html: true,});
}
});
$('#option_fewo_id').on('change', function(){
@ -105,7 +111,38 @@
$('#option_channel_id').on('change', function(){
table.draw();
});
$('#datatables-default').tooltip({selector: '[data-toggle="tooltip"]'});
$('#datatables-fewos').tooltip({selector: '[data-toggle="tooltip"]'});
function get_popover_content() {
if ($(this).data('travel_user_booking_fewo_id')) {
var data = {};
data['action'] = $(this).data('action');
data['travel_user_booking_fewo_id'] = $(this).data('travel_user_booking_fewo_id');
$(this).addClass("loading");
var icontent = $.ajax({
url: '{!! route( 'travel_user_booking_fewo_ajax_requests' ) !!}',
data: data,
type: "POST",
dataType: "html",
cache: false,
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
encode: true,
async: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function() {
// just get the response
},
error: function() {
// nothing
}
}).responseText;
$(this).removeClass("loading");
return icontent;
}
return "Keine Buchungs-ID";
}
});
</script>

View file

@ -30,26 +30,7 @@
</div>
</div>
<hr class="border-light m-0">
<!-- / Header -->
{{-- <!-- Controls -->
<div class="media flex-wrap align-items-center p-2">
<div class="media-body d-flex flex-wrap flex-basis-100 flex-basis-sm-auto">
<button type="button" class="btn btn-default borderless md-btn-flat icon-btn messages-tooltip text-muted mr-3" title="Back"><i class="ion ion-md-arrow-back"></i></button>
<button type="button" class="btn btn-default borderless md-btn-flat icon-btn messages-tooltip text-muted" title="Mark as unread"><i class="ion ion-md-mail-unread"></i></button>
<button type="button" class="btn btn-default borderless md-btn-flat icon-btn messages-tooltip text-muted" title="Mark as important"><i class="ion ion-md-alert"></i></button>
<button type="button" class="btn btn-default borderless md-btn-flat icon-btn messages-tooltip text-muted" title="Move to spam"><i class="ion ion-md-folder-open"></i></button>
<button type="button" class="btn btn-default borderless md-btn-flat icon-btn messages-tooltip text-muted" title="Move to trash"><i class="ion ion-md-trash"></i></button>
</div>
<div class="d-flex flex-wrap align-items-center ml-auto">
<button type="button" class="btn btn-default borderless md-btn-flat text-muted px-3"><i class="ion ion-ios-undo"></i>&nbsp; Reply</button>
<div class="text-lighter">|</div>
<button type="button" class="btn btn-default borderless md-btn-flat text-muted px-3">Forward &nbsp;<i class="ion ion-ios-redo"></i></button>
</div>
</div>
<hr class="border-light m-0">
<!-- / Controls -->
--}}
<div class="p-4">
{!! nl2br($customer_mail->message) !!}
</div>
@ -61,7 +42,7 @@
<p><strong>Kunde: </strong>
{{ $customer_mail->customer->getSalutation() }} {{ $customer_mail->customer->title }} {{ $customer_mail->customer->firstname }} {{ $customer_mail->customer->name }}
@if($customer_mail->booking)
({{$customer_mail->booking->id}})1
({{$customer_mail->booking->id}})
@endif
</p>
@endif
@ -149,7 +130,7 @@
</div>
<div class="col-sm-6">
<button type="submit" class="btn btn-xs btn-default float-right mt-1" onclick="return confirm('{{__('Wirklich weiterleiten? E-Mail wird erneut gesendet!')}}');"><i class="ion ion-ios-send"></i>&nbsp; weiterleiten</button>
</div
</div>
</div>
{!! Form::close() !!}
</div>

View file

@ -124,10 +124,12 @@ Route::group(['middleware' => ['admin']], function()
Route::post('/lead_mail/send/mail', 'LeadMailController@sendMail')->name('lead_mail_send_mail');
Route::post('/lead_mail/reply/mail', 'LeadMailController@replyMail')->name('lead_mail_reply_mail');
Route::get('/lead_mail/data/table', 'LeadMailController@getRequests')->name('lead_mail_data_table');
Route::get('/email_fewo_template/data/table', 'LeadMailController@getEmailTemplates')->name('email_fewo_template_data_table');
Route::get('/email_lead_template/data/table', 'LeadMailController@getEmailTemplates')->name('email_lead_template_data_table');
Route::get('/lead_mail/delete/{id}', 'LeadMailController@delete')->name('lead_mail_delete');
Route::post('lead_mail/ajax', 'LeadMailController@ajax')->name('lead_mail_ajax');
Route::post('/lead_mail/modal/load', 'LeadMailController@loadModal')->name('lead_mail_modal_load');
Route::post('lead_mail/detail{id}/{action?}', 'LeadMailController@store')->name('lead_mail_detail');
Route::group(['middleware' => ['auth.permission:cms-iq-assets']], function() {
@ -197,6 +199,8 @@ Route::group(['middleware' => ['admin']], function()
Route::post('/lead/detail/{id}', 'LeadController@store')->name('lead_detail');
Route::get('/lead/delete/{id}/{del?}', 'LeadController@delete')->name('lead_delete');
Route::post('/lead/modal/load', 'LeadController@loadModal')->name('lead_modal_load');
Route::post('lead/ajax/requests', 'LeadController@getAjaxRequests')->name('lead_ajax_requests');
});
Route::group(['middleware' => ['auth.permission:crm-bo-cu']], function() {
//Buchungen > Kunden
@ -231,6 +235,8 @@ Route::group(['middleware' => ['admin']], function()
Route::post('/travel_user_booking_fewo/detail/{id}', 'TravelUserBookingFewoController@store')->name('travel_user_booking_fewo_detail');
Route::get('/travel_user_booking_fewo/delete/{id}/{del?}', 'TravelUserBookingFewoController@delete')->name('travel_user_booking_fewo_delete');
Route::post('/travel_user_booking_fewo/modal/load', 'TravelUserBookingFewoController@loadModal')->name('travel_user_booking_fewo_modal_load');
Route::post('travel_user_booking_fewo/ajax/requests', 'TravelUserBookingFewoController@getAjaxRequests')->name('travel_user_booking_fewo_ajax_requests');
});
Route::group(['middleware' => ['auth.permission:cms-cn-in']], function() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB