Edit / PDF / Mail / ->Leads

This commit is contained in:
Kevin Adametz 2021-05-07 17:44:02 +02:00
parent 5d55e5be3f
commit 66ca252bfa
43 changed files with 2915 additions and 76 deletions

View file

@ -51,6 +51,13 @@ class FileController extends Controller
$path = $file->getPath();
}
if ($disk === 'lead'){
$file = \App\Models\LeadFile::findOrFail($id);
$filename = $file->original_name;
$path = $file->getPath();
}
if ($disk === 'cms_file'){
$file = \App\Models\CMSContent::findOrFail($id);
$filename = $file->name;

View file

@ -2,20 +2,27 @@
namespace App\Http\Controllers;
use App\Models\Lead;
use App\Repositories\LeadRepository;
use Carbon;
use Request;
use App\Models\Lead;
use App\Models\LeadFile;
use App\Models\LeadNotice;
use App\Repositories\LeadRepository;
use App\Repositories\CustomerRepository;
use App\Repositories\LeadFileRepository;
class LeadController extends Controller
{
protected $leadRepo;
protected $custRepo;
public function __construct(LeadRepository $leadRepo)
public function __construct(LeadRepository $leadRepo, CustomerRepository $custRepo)
{
$this->middleware('admin');
$this->leadRepo = $leadRepo;
$this->custRepo = $custRepo;
}
public function index($step = false)
@ -46,18 +53,92 @@ class LeadController extends Controller
public function store($id)
{
$data = Request::all();
if($data['action'] === 'saveCustomer'){
$customer = $this->custRepo->updateCustomerFromLead($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('lead_detail', [$id]).'#collapseLeadCustomer');
}
if($data['action'] === 'saveLead'){
$lead = $this->leadRepo->updateLead($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('lead_detail', [$id]).'#collapseLeadDetail');
}
if($data['action'] === 'saveStatus'){
$lead = $this->leadRepo->updateLeadStatus($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('lead_detail', [$id]).'#collapseLeadStatus');
}
if($data['action'] === 'save_notice'){
$lead = $this->leadRepo->updateNotice($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('lead_detail', [$lead->id])."#collapseLeadNotice");
}
if($data['action'] === 'edit_notice'){
$lead = $this->leadRepo->updateNotice($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('lead_detail', [$lead->id])."#collapseLeadNotice");
}
return back();
/* $data = Request::all();
\Session()->flash('alert-save', '1');
return redirect(route('lead_detail', [$lead->id]));*/
}
public function delete($id){
/*
\Session()->flash('alert-success', __('Eintrag gelöscht'));
return redirect(route('lead_detail', [$lead->id]));*/
public function loadModal(){
$data = Request::all();
$ret = "";
if(Request::ajax()) {
if($data['action'] === "edit_notice") {
$value = LeadNotice::findOrFail($data['id']);
$ret = view("lead.edit_notice_modal", compact('data', 'value'))->render();
}
}
return response()->json(['response' => $data, 'html'=>$ret]);
}
public function delete($id, $del="lead"){
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) {
$fileRepo = new LeadFileRepository($leadFile);
$fileRepo->_set('disk', 'lead');
$fileRepo->delete();
$leadFile->delete();
}
//Mails Files CASCADE
$lead->delete();
\Session()->flash('alert-success', __('Anfrage gelöscht'));
}
if($del === 'lead_notice'){
$leadNotice = LeadNotice::findOrFail($id);
$lead = $leadNotice->lead;
$leadNotice->delete();
\Session()->flash('alert-success', 'Notiz gelöscht');
return redirect(route('lead_detail', [$lead->id]));
}
if($del === 'lead_files'){
$leadFile = LeadFile::findOrFail($id);
$lead = $leadFile->lead;
$fileRepo = new LeadFileRepository($leadFile);
$fileRepo->_set('disk', 'lead');
$fileRepo->delete();
$leadFile->delete();
\Session()->flash('alert-success', 'Datei gelöscht');
return redirect(route('lead_detail', [$lead->id]));
}
return redirect(route('leads'));
}
public function getLeads()
@ -77,8 +158,14 @@ class LeadController extends Controller
->addColumn('request_date', function (Lead $lead) {
return Carbon::parse($lead->request_date)->format(\Util::formatDateDB());
})
->addColumn('status', function (Lead $lead) {
//umbuchen
return $lead->getStatusBadge();
})
->orderColumn('id', 'id $1')
->orderColumn('customer_id', 'customer_id $1')
->orderColumn('status', 'status_id $1')
->filterColumn('id', function($query, $keyword) {
if($keyword != ""){
$query->where('id', 'LIKE', '%'.$keyword.'%');
@ -89,7 +176,7 @@ class LeadController extends Controller
$query->where('customer_id', 'LIKE', '%'.$keyword.'%');
}
})
->rawColumns(['action_edit', 'customer_id', 'sf_guard_user_id', 'id'])
->rawColumns(['action_edit', 'customer_id', 'sf_guard_user_id', 'id', 'status'])
->make(true);
}

View file

@ -0,0 +1,387 @@
<?php
namespace App\Http\Controllers;
use Carbon;
use Request;
use Response;
use App\Services\Util;
use App\Models\LeadFile;
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;
use App\Repositories\BookingFewoFileRepository;
use App\Repositories\CustomerFewoFileRepository;
use App\Repositories\CustomerFewoMailRepository;
class LeadMailController extends Controller
{
protected $customerMailRepo;
public function __construct(LeadMailRepository $customerMailRepo)
{
$this->middleware('admin');
$this->customerMailRepo = $customerMailRepo;
}
/* public function index()
{
$data = [
];
return view('customer.mail.index', $data);
}
public function detail($id)
{
if($id === "new") {
$customer_mail = new CustomerFewoMail();
$id = 'new';
}else{
$customer_mail = CustomerFewoMail::findOrFail($id);
$id = $customer_mail->id;
}
$data = [
'customer_mail' => $customer_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);
if($action === 'move-mail'){
$data['subdir'] = isset($data['subdir']) && $data['subdir'] ? $data['subdir'] : null;
$customer_mail->dir = $data['dir'];
$customer_mail->subdir = $data['subdir'];
$customer_mail->save();
}
return back();
}
public function delete($id){
$customer_mail = CustomerFewoMail::find($id);
$customer_mail->dir = 12;
$customer_mail->subdir = 0;
$customer_mail->save();
\Session()->flash('alert-success', __('Mail gelöscht'));
return back();
}*/
public function loadModal(){
$data = Request::all();
$ret = "";
if(Request::ajax()) {
/* if ($data['action'] === "new-customer-mail" || $data['action'] === "reply-customer-mail" || $data['action'] === "show-customer-mail" || $data['action'] === "edit-customer-mail"){
$data['customers'] = [];
if ($data['action'] === "new-customer-mail" && isset($data['travel_user_booking_fewo_id']) && $TravelUserBookingFewo = TravelUserBookingFewo::find($data['travel_user_booking_fewo_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;
}
$ret = CustomerFewoMailRepository::loadModal($data);
}*/
if($data['action'] === "modal-upload-lead-file") {
$ret = view("lead.upload_modal", compact('data'))->render();
}
if($data['action'] === "upload-lead-file"){
if($data['lead_id']){
$bookingFileRepo = new LeadFileRepository(new LeadFile());
$bookingFileRepo->_set('disk', 'lead');
$bookingFileRepo->_set('lead_id', $data['lead_id']);
$bookingFileRepo->_set('dir', '/files/'.date('Y/m').'/');
$bookingFileRepo->_set('identifier', 'lead');
return $bookingFileRepo->uploadFile(Request::all());
}
}
}
return response()->json(['response' => $data, 'html'=>$ret]);
}
public function sendMail(CustomerFewoMailRepository $customerFewoMailRepository){
$data = Request::all();
$customerFewoMailRepository->sendAndStore($data);
if($data['action'] == 'draft'){
\Session()->flash('alert-success', "Entwurf gespeichert!");
}else{
\Session()->flash('alert-success', "Mail gesendet!");
}
return back();
}
public function replyMail(CustomerFewoMailRepository $customerFewoMailRepository){
$data = Request::all();
$customerFewoMailRepository->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);
if(Request::get('filter_email_templates_directory') != ""){
$query->where('email_template_dir_id', '=', Request::get('filter_email_templates_directory'));
}
return \DataTables::eloquent($query)
->addColumn('action', function (EmailTemplate $emailTemplate) {
return '<a href="javascript:void(0)" class="btn icon-btn btn-sm btn-primary email-template-action"
data-url="'.route('customer_mail_ajax').'" data-id="'.$emailTemplate->id.'" data-action="load_email_template"
title="Vorlage laden" data-placement="left" rel="tooltip"><span class="ion ion-ios-arrow-dropup"></span></a>';
})
->addColumn('email_template_dir.name', function (EmailTemplate $emailTemplate) {
return $emailTemplate->email_template_dir ? '<span class="badge badge-default" style="background-color: '.$emailTemplate->email_template_dir->color.'">'.$emailTemplate->email_template_dir->name.'</span>' : '&nbsp;';
})
->orderColumn('id', 'id $1')
->orderColumn('subject', 'subject $1')
->orderColumn('name', 'name $1')
->orderColumn('email_template_dir.name', 'email_template_dir.name $1')
->orderColumn('message', 'message $1')
->filterColumn('id', function($query, $keyword) {
if($keyword != ""){
$query->where('id', 'LIKE', '%'.$keyword.'%');
}
})
->filterColumn('subject', function($query, $keyword) {
if($keyword != ""){
$query->where('name', 'LIKE', '%'.$keyword.'%');
$query->OrWhere('subject', 'LIKE', '%'.$keyword.'%');
$query->OrWhere('message', 'LIKE', '%'.$keyword.'%');
}
})
->rawColumns(['action', 'email_template_dir.name'])
->make(true);
}
public function uploadAttachment($id){
$fileRepo = new CustomerFewoFileRepository(new CustomerFewoFile());
if($id === 'tmp'){
$fileRepo->_set('disk', 'travel_user');
$fileRepo->_set('dir', '/attachment/'.date('Y/m').'/');
$fileRepo->_set('travel_user_id', NULL);
$fileRepo->_set('customer_fewo_mail_id', NULL);
$fileRepo->_set('identifier', 'tmp');
return $fileRepo->uploadFile(Request::all());
}
return Response::json([
'error' => true,
'code' => 200
], 200);
}
public function ajax(){
$data = Request::all();
$ret = "";
$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();
$status = 'success';
}
if($data['action'] === 'load_email_template'){
$email_template = EmailTemplate::find($data['id']);
$ret = $email_template->message;
$data['subject'] = $email_template->subject;
$status = 'success';
}
if($data['action'] === 'delete_mail_attachment'){
$customer_file = CustomerFewoFile::find($data['id']);
$fileRepo = new CustomerFewoFileRepository($customer_file);
$fileRepo->_set('disk', 'travel_user');
$ret = $fileRepo->delete();
$status = 'success';
}
if($data['action'] === 'add_attachment'){
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$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->_set('dir', '/attachment/'.date('Y/m').'/');
$fileRepo->_set('travel_user_id', NULL);
$fileRepo->_set('customer_fewo_mail_id', NULL);
$fileRepo->_set('identifier', 'tmp');
$fileRepo->_set('originalName', $data['name']);
$fileRepo->_set('mine', $mine);
$fileRepo->_set('extension', $extension);
return $fileRepo->storeFile($contents);
}
}
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
}
private function getSearchRequests()
{
if (!Request::get('travel_user_booking_fewo_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->where('draft', '=', true)->where('dir', '!=', 12);
}else{
$query->where('dir', '=', Request::get('customer_mail_dir')); //with('lead'
}
if (Request::get('customer_mail_subdir')) {
$query->where('subdir', '=', Request::get('customer_mail_subdir'));
}
return $query;
}
public function getRequests(){
$query = $this->getSearchRequests();
return \DataTables::eloquent($query)
->addColumn('checkbox', function (CustomerFewoMail $customer_mail) {
return '<div class="message-checkbox mr-1">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input">
<span class="custom-control-label"></span>
</label>
</div>';
})
->addColumn('important', function (CustomerFewoMail $customer_mail) {
$icon = ($customer_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>';
})
->addColumn('subject', function (CustomerFewoMail $customer_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') : '';
return '<a href="javascript:void(0)" class="badge '.$badge.'" data-toggle="modal"
data-target="#modals-load-content" data-id="'.$id.'" data-model="CustomerFewoMail"
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>' : '');
})
->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>';
}
return '<span class="badge badge-default"><i class="fa fa-times-circle"></i> '.$customer_mail->sent_at.'</span>';
})
->addColumn('action', function (CustomerFewoMail $customer_mail) {
$ret = '';
if(!$customer_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.'">
<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.'">
<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>';
return '<div style="white-space: nowrap;">'.$ret.'</div>';
})
->orderColumn('date', 'sent_at $1')
->orderColumn('subject', 'subject $1')
->orderColumn('important', 'important $1')
->rawColumns(['checkbox', 'important', 'subject', 'date', 'action'])
->make(true);
}
}

View file

@ -389,23 +389,8 @@ class RequestController extends Controller
})
->addColumn('lead.status_id', function (Booking $booking) {
//umbuchen
if($booking->lead->status_id){
$color = $booking->lead->status->color;
$icon = "";
if($booking->lead->status_id == 14 && $booking->lead->is_rebook){
$color = '#94ae59';
$icon = '<i class="fa fa-check-circle"></i> ';
}
if($booking->lead->status_id == 14 && !$booking->lead->is_rebook){
$icon = '<i class="fa fa-times-circle"></i> ';
}
if($booking->lead->status_id == 15){
$icon = '<i class="fa fa-balance-scale"></i> ';
if($booking->lawyer_date){
return '<span data-order="'.$booking->lead->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$booking->lawyer_date->format('d.m.Y').'</span></span>';
}
}
return '<span data-order="'.$booking->lead->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$booking->lead->status->name.'</span></span>';
if($booking->lead){
return $booking->lead->getStatusBadge($booking);
}
return '<span data-order="0">-</span>';
})

View file

@ -9,6 +9,7 @@ use App\Models\EmailTemplate;
use App\Models\EmailTemplateDir;
use App\Services\Booking;
use App\Services\BookingFewo;
use App\Services\Lead;
use App\Services\Util;
use Request;
@ -22,6 +23,8 @@ class EmailsController extends Controller
{
$this->identifier_booking_file = 'booking-email-file';
$this->identifier_fewo_file = 'fewo-email-file';
$this->identifier_lead_file = 'lead-email-file';
$this->middleware('admin');
}
@ -36,8 +39,11 @@ class EmailsController extends Controller
'customer_mail_dirs' => Booking::getCustomerMailDirs(),
'identifier_booking_file' => $this->identifier_booking_file,
'identifier_fewo_file' => $this->identifier_fewo_file,
'identifier_lead_file' => $this->identifier_lead_file,
'fewo_email_files' => CMSContent::where('identifier', '=', $this->identifier_fewo_file)->get()->sortByDesc('pos'),
'customer_fewo_mail_dirs' => BookingFewo::getCustomerMailDirs(),
'lead_email_files' => CMSContent::where('identifier', '=', $this->identifier_lead_file)->get()->sortByDesc('pos'),
'customer_lead_mail_dirs' => Lead::getCustomerMailDirs(),
'step' => $step
];

View file

@ -6,6 +6,7 @@
namespace App\Models;
use App\Models\Sym\TravelCountry;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@ -123,6 +124,11 @@ class Customer extends Model
'country_id',
];
public static $salutationType = [
1 => 'Mann',
2 => 'Frau'
];
public function travel_country()
{
return $this->belongsTo(TravelCountry::class, 'country_id');
@ -154,6 +160,10 @@ class Customer extends Model
}
return $this->name;
}
public static function getCustomerCountriesArray(){
return TravelCountry::where('is_customer_country', 1)->get()->pluck('name', 'id');
}
}

View file

@ -6,6 +6,7 @@
namespace App\Models;
use App\Models\Lead as ModelsLead;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@ -157,9 +158,12 @@ class Lead extends Model
if(!$date){
$carbon = Carbon::now();
$this->next_due_date = $carbon->modify('+ '.$this->status->handling_days.' days')->format("Y-m-d");
$this->save();
}
}else{
$carbon = Carbon::parse($date);
}
$this->next_due_date = $carbon->modify('+ '.$this->status->handling_days.' days')->format("Y-m-d");
$this->save();
}
public function customer()
{
@ -242,6 +246,83 @@ class Lead extends Model
public function status_histories()
{
return $this->hasMany(StatusHistory::class);
return $this->hasMany(StatusHistory::class)->orderByDesc('id')->orderByDesc('date');
}
public function lead_files()
{
//no lead_mail_id
return $this->hasMany(LeadFile::class, 'lead_id')->where('lead_mail_id', null);
}
public function lead_mails()
{
return $this->hasMany(LeadMail::class, 'lead_id', 'id');
}
public function lead_mails_sent_at()
{
return $this->hasMany(LeadMail::class, 'lead_id')->orderBy('sent_at', 'ASC');
}
public function lead_mail_last()
{
return $this->hasOne(LeadMail::class, 'lead_id')->latest();
}
public function lead_notices()
{
return $this->hasMany(LeadNotice::class, 'lead_id')->orderBy('created_at', 'DESC');
}
public static function getSfGuardUserArray(){
return SfGuardUser::where('is_active', 1)->get()->pluck('fullname', 'id');
}
public static function getTravelCountryArray($emtpy = false){
$TravelCountry = TravelCountry::where('active_backend', 1)->orderBy('name')->get()->pluck('name', 'id');
return $emtpy ? $TravelCountry->prepend('-', 0) : $TravelCountry;
}
public static function getTravelCategoryArray($emtpy = false){
$TravelCategory = TravelCategory::orderBy('name')->get()->pluck('name', 'id');
return $emtpy ? $TravelCategory->prepend('-', 0) : $TravelCategory;
}
public static function getTravelAgendaArray($emtpy = false){
$TravelAgenda = TravelAgenda::orderBy('name')->get()->pluck('name', 'id');
return $emtpy ? $TravelAgenda->prepend('-', 0) : $TravelAgenda;
}
public static function getStatusArray($emtpy = false){
$Status = Status::orderBy('name')->get()->pluck('name', 'id');
return $emtpy ? $Status->prepend('-', 0) : $Status;
}
public function getStatusBadge($booking = null)
{
if($this->status_id && $this->status){
$color = $this->status->color;
$icon = "";
if($this->status_id == 14 && $this->is_rebook){
$color = '#94ae59';
$icon = '<i class="fa fa-check-circle"></i> ';
}
if($this->status_id == 14 && !$this->is_rebook){
$icon = '<i class="fa fa-times-circle"></i> ';
}
if($this->status_id == 15){
$icon = '<i class="fa fa-balance-scale"></i> ';
if($booking && $booking->lawyer_date){
return '<span data-order="'.$this->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$booking->lawyer_date->format('d.m.Y').'</span></span>';
}
}
return '<span data-order="'.$this->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$this->status->name.'</span></span>';
}
return '<span data-order="0">-</span>';
}
}

100
app/Models/LeadFile.php Normal file
View file

@ -0,0 +1,100 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class LeadFile
*
* @property int $id
* @property int $lead_id
* @property int $lead_mail_id
* @property string $identifier
* @property string $filename
* @property string $dir
* @property string $original_name
* @property string $ext
* @property string $mine
* @property int $size
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property Lead $lead
* @property LeadMail $lead_mail
*
* @package App\Models
*/
class LeadFile extends Model
{
protected $table = 'lead_files';
protected $casts = [
'lead_id' => 'int',
'lead_mail_id' => 'int',
'size' => 'int'
];
protected $fillable = [
'lead_id',
'lead_mail_id',
'identifier',
'filename',
'dir',
'original_name',
'ext',
'mine',
'size'
];
public static $icon_ext = [
'default' => 'fa fa-file',
'pdf'=> 'fa fa-file-pdf',
'jpg'=> 'fa fa-file-image',
'png'=> 'fa fa-file-image',
];
public function lead()
{
return $this->belongsTo(Lead::class);
}
public function lead_mail()
{
return $this->belongsTo(LeadMail::class);
}
public function getIconExt(){
return isset(self::$icon_ext[$this->ext]) ? self::$icon_ext[$this->ext] : self::$icon_ext['default'];
}
public function getURL($do=false){
return route('storage_file', [$this->id, 'lead', $do]);
}
public function getPath(){
return \Storage::disk('lead')->path($this->dir.$this->filename);
}
public function formatBytes($precision = 2)
{
$size = $this->size;
if ($size > 0) {
$size = (int) $size;
$base = log($size) / log(1024);
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
} else {
return $size;
}
}
}

114
app/Models/LeadMail.php Normal file
View file

@ -0,0 +1,114 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class LeadMail
*
* @property int $id
* @property int $lead_id
* @property int $customer_id
* @property bool $is_answer
* @property int $reply_id
* @property string $email
* @property string $recipient
* @property string $cc
* @property string $bcc
* @property string $subject
* @property string $message
* @property int $dir
* @property int $subdir
* @property bool $draft
* @property bool $important
* @property bool $send
* @property bool $fail
* @property string $error
* @property string $forward
* @property Carbon $sent_at
* @property Carbon $scheduled_at
* @property Carbon $delivered_at
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property Customer $customer
* @property Lead $lead
* @property CustomerMail $customer_mail
* @property Collection|LeadFile[] $lead_files
*
* @package App\Models
*/
class LeadMail extends Model
{
protected $table = 'lead_mails';
protected $casts = [
'lead_id' => 'int',
'customer_id' => 'int',
'is_answer' => 'bool',
'reply_id' => 'int',
'dir' => 'int',
'subdir' => 'int',
'draft' => 'bool',
'important' => 'bool',
'send' => 'bool',
'fail' => 'bool'
];
protected $dates = [
'sent_at',
'scheduled_at',
'delivered_at'
];
protected $fillable = [
'lead_id',
'customer_id',
'is_answer',
'reply_id',
'email',
'recipient',
'cc',
'bcc',
'subject',
'message',
'dir',
'subdir',
'draft',
'important',
'send',
'fail',
'error',
'forward',
'sent_at',
'scheduled_at',
'delivered_at'
];
public function customer()
{
return $this->belongsTo(Customer::class);
}
public function lead()
{
return $this->belongsTo(Lead::class);
}
public function customer_mail()
{
return $this->belongsTo(CustomerMail::class, 'reply_id');
}
public function lead_files()
{
return $this->hasMany(LeadFile::class);
}
}

91
app/Models/LeadNotice.php Normal file
View file

@ -0,0 +1,91 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use App\User;
/**
* Class LeadNotice
*
* @property int $id
* @property int $lead_id
* @property int $from_user_id
* @property int $to_user_id
* @property string $message
* @property bool $show
* @property bool $important
* @property Carbon $edit_at
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property User $user
* @property Lead $lead
*
* @package App\Models
*/
class LeadNotice extends Model
{
protected $table = 'lead_notices';
protected $casts = [
'lead_id' => 'int',
'from_user_id' => 'int',
'to_user_id' => 'int',
'show' => 'bool',
'important' => 'bool'
];
protected $dates = [
'edit_at'
];
protected $fillable = [
'lead_id',
'from_user_id',
'to_user_id',
'message',
'show',
'important',
'edit_at'
];
public function to_user()
{
return $this->belongsTo(User::class, 'to_user_id');
}
public function from_user()
{
return $this->belongsTo(User::class, 'from_user_id');
}
public function lead()
{
return $this->belongsTo(Lead::class);
}
public function getName(){
if($this->from_user){
if($this->from_user->sf_guard_user){
return $this->from_user->sf_guard_user->first_name." ".$this->from_user->sf_guard_user->last_name;
}else{
$this->from_user->name;
}
}
}
public function getSmallerMessage($max = 500){
$ret = substr($this->message, 0, $max);
if(strlen($this->message) > 500){
$ret .= " ...";
}
return $ret;
}
}

View file

@ -66,4 +66,9 @@ class SfGuardUser extends Model
return $this->belongsTo(User::class, 'user_id');
}
public function getFullnameAttribute(){
return $this->first_name." ".$this->last_name;
}
}

View file

@ -47,9 +47,20 @@ class Status extends Model
'color'
];
public function leads()
public function getStatusBadge()
{
return $this->hasMany(Lead::class);
$color = $this->color;
$icon = "";
if($this->id == 14){
$icon = '<i class="fa fa-times-circle"></i> ';
}
if($this->id == 15){
$icon = '<i class="fa fa-balance-scale"></i> ';
}
return '<span data-order="'.$this->id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$this->name.'</span></span>';
}
/*public function status_histories()

View file

@ -52,7 +52,8 @@ class StatusHistory extends Model
protected $dates = [
'date',
'target_date'
'target_date',
'created_at'
];
protected $fillable = [
@ -61,7 +62,8 @@ class StatusHistory extends Model
'sf_guard_user_id',
'date',
'remarks',
'target_date'
'target_date',
'created_at'
];
public function lead()

View file

@ -2,26 +2,20 @@
namespace App\Repositories;
use App\Models\BookingFile;
use App\Models\TravelUserBookingFile;
use Response;
class BookingFewoFileRepository extends FileRepository {
protected $booking_fewo_file;
protected $travel_user_booking_fewo_id;
protected $identifier;
public function __construct(TravelUserBookingFile $model){
parent::__construct();
$this->model = $model;
}
public function save(){
$this->booking_fewo_file = TravelUserBookingFile::create([
'travel_user_booking_fewo_id' => $this->travel_user_booking_fewo_id,
@ -35,7 +29,6 @@ class BookingFewoFileRepository extends FileRepository {
]);
}
public function response(){
return Response::json([
'error' => false,

View file

@ -3,19 +3,46 @@
namespace App\Repositories;
use App\Models\Booking;
use App\Models\Customer;
use App\Models\Lead;
class CustomerRepository extends BaseRepository {
public function __construct(Booking $model)
public function __construct(Customer $model)
{
$this->model = $model;
}
public function update($data)
public function updateCustomer($id, $data)
{
$this->model = Customer::findOrFail($id);
$fill = [
'salutation_id' => $data['salutation_id'],
'name' => $data['name'],
'firstname' => $data['firstname'],
'street' => $data['street'],
'zip' => $data['zip'],
'city' => $data['city'],
'email' => $data['email'],
'phone' => $data['phone'],
'phonemobile' => $data['phonemobile'],
'country_id' => $data['country_id'],
];
$this->model->fill($fill);
$this->model->save();
return $this->model;
}
public function updateCustomerFromLead($id, $data){
$lead = Lead::findOrFail($id);
if(isset($data['customer']) && $lead->customer){
return $this->updateCustomer($lead->customer->id, $data['customer']);
}
}
}

View file

@ -0,0 +1,46 @@
<?php
namespace App\Repositories;
use App\Models\LeadFile;
use Response;
class LeadFileRepository extends FileRepository {
protected $lead_file;
protected $lead_id;
protected $identifier;
public function __construct(LeadFile $model){
parent::__construct();
$this->model = $model;
}
public function save(){
$this->lead_file = LeadFile::create([
'lead_id' => $this->lead_id,
'identifier' => $this->identifier,
'filename' => $this->allowed_filename,
'dir' => $this->dir,
'original_name' => $this->originalName,
'ext' => $this->extension,
'mine' => $this->mine,
'size' => $this->size
]);
}
public function response(){
return Response::json([
'error' => false,
'filename' => $this->allowed_filename,
'file_id' =>$this->lead_file->id,
'file_data' => $this->extension,
'file_icon' => $this->lead_file->getIconExt(),
'file_format_bytes' => $this->lead_file->formatBytes(),
'file_url' => $this->lead_file->getURL(),
'redirect' => '',
'code' => 200
], 200);
}
}

View file

@ -0,0 +1,387 @@
<?php
namespace App\Repositories;
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 Illuminate\Support\Facades\Mail;
class LeadMailRepository extends BaseRepository {
public function __construct(CustomerFewoMail $model)
{
$this->model = $model;
}
public function update($data)
{
return $this->model;
}
public function sendAndStore($data){
//send or draft
//$data['action']
if(isset($data['send_mail_to']) && is_array($data['send_mail_to'])) {
//has Attachments
$customer_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;
}
}
}
foreach ($data['send_mail_to'] as $booking_fewo_id => $on) {
$booking_fewo = TravelUserBookingFewo::find($booking_fewo_id);
if ($booking_fewo->travel_user) {
$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']);
}
$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;
$file->identifier = 'mail';
$file->save();
}
if(isset($data['action']) && $data['action'] === 'send'){ //not at draft
$this->sendMail($customer_mail);
}
}
}
}
}
public function forwardMail($customer_mail, $data){
//send or draft
//$data['action']
if(isset($data['customer_mail_forward_email']) && !empty($data['customer_mail_forward_email'])) {
$to_mails = [];
if(strpos($data['customer_mail_forward_email'], ',')){
$to_mails = array_map('trim', explode(',', $data['customer_mail_forward_email']));
}else{
$to_mails[] = $data['customer_mail_forward_email'];
}
$customer_files = $customer_mail->customer_files;
$full_message = $this->prepareMessageFull($customer_mail);
try {
//
Mail::to($to_mails)
->bcc($customer_mail->bcc ?: [])
->send(new MailSendInfo($customer_mail->subject, $full_message, $customer_files));
}
catch(\Exception $e){
// Never reached
$forward = array();
$forward[now()->format("d.m.Y H:i:s")] = ['fail'=> true, 'to'=> $data['customer_mail_forward_email'], 'error'=>$e->getMessage()];
$customer_mail->setForwardMessage($forward);
return false;
}
$forward = array();
$forward[now()->format("d.m.Y H:i:s")] = ['sent'=> true, 'to'=> $data['customer_mail_forward_email']];
$customer_mail->setForwardMessage($forward);
return true;
}
}
public function replyStore($data){
if(isset($data['travel_user_booking_fewo_id']) && $booking_fewo = TravelUserBookingFewo::find($data['travel_user_booking_fewo_id'])) {
//has Attachments
$customer_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 ($booking_fewo->travel_user) {
$data['draft'] = (isset($data['action']) && $data['action'] === 'draft' ? true : false);
$mail_from = isset($data['mail_from']) ? $data['mail_from'] : $booking_fewo->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;
$file->identifier = 'mail';
$file->save();
}
}
}
}
public function store($booking_fewo, $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,
'is_answer' => $is_answer,
'reply_id' => $reply_id,
'email' => $mail_from,
'recipient' => isset($data['recipient']) ? Util::_explodeLines($data['recipient']) : null,
'cc' => isset($data['cc']) ? Util::_explodeLines($data['cc']) : null,
'bcc' => isset($data['bcc']) ? Util::_explodeLines($data['bcc']) : null,
'subject' => $data['subject'],
'message' => $data['message'],
'dir' => isset($data['dir']) ? $data['dir'] : 0,
'subdir' => isset($data['subdir']) ? $data['subdir'] : 0,
'draft' => $data['draft'],
'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,
'is_answer' => $is_answer,
'reply_id' => $reply_id,
'email' => $mail_from,
'recipient' => isset($data['recipient']) ? Util::_explodeLines($data['recipient']) : null,
'cc' => isset($data['cc']) ? Util::_explodeLines($data['cc']) : null,
'bcc' => isset($data['bcc']) ? Util::_explodeLines($data['bcc']) : null,
'subject' => $data['subject'],
'message' => $data['message'],
'dir' => isset($data['dir']) ? $data['dir'] : 0,
'subdir' => isset($data['subdir']) ? $data['subdir'] : 0,
'draft' => $data['draft'],
'sent_at' => $sent_at ? $sent_at : now(),
]);
}
return $customer_mail;
}
private function sendMail($customer_mail){
$to_mails = [];
if(strpos($customer_mail->email, ',')){
$to_mails = array_map('trim', explode(',', $customer_mail->email));
}else{
$to_mails[] = $customer_mail->email;
}
if($customer_mail->recipient){
$to_mails = array_merge($to_mails, $customer_mail->recipient);
}
$customer_files = $customer_mail->customer_files;
$full_message = $this->prepareMessageFull($customer_mail);
try {
//
Mail::to($to_mails)
->cc($customer_mail->cc ?: [])
->bcc($customer_mail->bcc ?: [])
->send(new MailSendInfo($customer_mail->subject, $full_message, $customer_files));
}
catch(\Exception $e){
// Never reached
$customer_mail->fail = true;
$customer_mail->error = $e->getMessage();
$customer_mail->save();
return false;
}
$customer_mail->send = true;
$customer_mail->sent_at = now();
$customer_mail->save();
return true;
}
private function prepareMessageFull($customer_mail, $deep = 0){
$ret = "";
if($deep === 0){
$ret .= $customer_mail->message;
}else{
$ret .= "--------------------------------\n";
$ret .= $customer_mail->is_answer ? "Antwort von: " : "Gesendet an: ";
$ret .= "&lt;".$customer_mail->email."&gt; ".$customer_mail->sent_at."\n";
$ret .= "<strong>".$customer_mail->subject."</strong>\n";
$ret .= $customer_mail->message;
}
if($customer_mail->customer_mail){
$ret .= $this->prepareMessageFull($customer_mail->customer_mail, $deep+1);
}
return $ret;
}
private function prepareContent($booking_fewo, $content){
$content = Placeholder::replaceBookingFewo($booking_fewo, $content);
return $content;
}
private static function prepareContactMails($value){
if(isset($value->customers)){ //&& $value->customer_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){
$value->recipient = Util::_implodeLines($contact_emails);
return $value;
}else{
if($contact_emails && count($contact_emails) > 0) {
$first_mail = array_shift($contact_emails);
if (count($contact_emails) > 0) {
$value->recipient = Util::_implodeLines($contact_emails);
}
}
}
}
foreach ($value->customers as $key=>$val){
$val['email'] = $first_mail;
$value->customers[$key] = $val;
}
}
return $value;
}
public static function loadModal($data)
{
$value = new Collection();
$value->title = "";
$value->subtitle = "";
$value->url = "";
$value->recipient = "";
$value->cc = "";
$value->bcc = "";
$value->lead_title_id = "";
$value->filter_email_templates_directories = EmailTemplate::join('email_template_dirs', 'email_template_dir_id', '=', 'email_template_dirs.id')->get()->pluck('name', 'id')->unique()->toArray();
/*Ansicht*/
if ($data['action'] === "show-customer-mail") {
if (isset($data['customer_mail_id']) && $customer_mail = CustomerFewoMail::find($data['customer_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();
}
}
/* neue Mail */
if ($data['action'] === "edit-customer-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;
$value->draft = true;
$value->id = $customer_mail->travel_user_booking_fewo_id;
$value->booking = $booking;
$value->show = 'single';
$value->lead_title_id = " - (".$value->booking->invoice_number.")";
$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;
$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->title = "E-Mail- Nachricht an Kunden senden";
$value->subtitle = "Dem Kunden wird eine E-Mail zugesendet.";
if($customer_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->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;
return view("travel.user.booking.mail.modal-new-mail", compact('data', 'value'))->render();
}
/* neue Mail */
if ($data['action'] === "new-customer-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;
$value->show = 'single';
$value->draft = true;
$value->lead_title_id = " - (".$value->booking->invoice_number.")";
}else{
//multi
$value->show = 'multi';
}
$value->customers = $data['customers'];
$value->subject = $value->lead_title_id;
$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;
}
$value->title = "E-Mail- Nachricht an Kunden senden";
$value->subtitle = "Dem Kunden wird eine E-Mail zugesendet.";
if($data['id'] === 'reply-send'){
$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->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 = self::prepareContactMails($value);
return view("travel.user.booking.mail.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'];
$value->draft = false;
$value->booking = $booking_fewo;
$value->message = "";
$value->subject = " - (".$value->booking->invoice_number.")";
$value->lead_title_id = " - (".$value->booking->invoice_number.")";
$value->s_placeholder = "Betreff des Kunden";
$value->m_placeholder = "Nachricht des Kunden";
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;
}
$value->title = "E-Mail Antwort speichern";
$value->subtitle = "Die E-Mail wird im System gespeichert.";
if($data['id'] === 'reply-save'){
$value->subtitle = "Die E-Mail wird im System als Antwort gespeichert.";
}
$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 = self::prepareContactMails($value);
return view("travel.user.booking.mail.modal-new-mail", compact('data', 'value'))->render();
}
}
}
}

View file

@ -3,18 +3,96 @@
namespace App\Repositories;
use App\Models\Booking;
use App\Models\Lead;
use App\Models\LeadNotice;
use App\Models\StatusHistory;
class LeadRepository extends BaseRepository {
public function __construct(Booking $model)
public function __construct(Lead $model)
{
$this->model = $model;
}
public function update($data)
{
return $this->model;
}
public function updateNotice($id, $data){
$model = Lead::findOrFail($id);
if($data['action'] === 'edit_notice' && isset($data['notice_id'])){
$BookingNotice = LeadNotice::findOrFail($data['notice_id']);
$BookingNotice->message = isset($data['lead_notice']) ? $data['lead_notice'] : "";
$BookingNotice->edit_at = now();
$BookingNotice->save();
}else{
//save_notice
LeadNotice::create([
'lead_id' => $model->id,
'from_user_id' => \Auth::user()->id,
'message' => isset($data['lead_notice']) ? $data['lead_notice'] : "",
]
);
}
return $model;
}
public function updateLead($id, $data)
{
$this->model = Lead::findOrFail($id);
$fill = [
'request_date' => _reformat_date($data['request_date']),
'travelperiod_start' => $data['travelperiod_start'] ? _reformat_date($data['travelperiod_start']) : null,
'travelperiod_end' => $data['travelperiod_end'] ? _reformat_date($data['travelperiod_end']) : null,
'travelperiod_length' => $data['travelperiod_length'],
'travelcountry_id' => $data['travelcountry_id'] ? $data['travelcountry_id'] : null,
'travelagenda_id' => $data['travelagenda_id'] ? $data['travelagenda_id'] : null,
'remarks' => $data['remarks'],
'sf_guard_user_id' => $data['sf_guard_user_id'],
'travelcategory_id' => $data['travelcategory_id'] ? $data['travelcategory_id'] : null,
'pax' => $data['pax'],
];
$this->model->fill($fill);
$this->model->save();
return $this->model;
}
public function updateLeadStatus($id, $data)
{
$this->model = Lead::findOrFail($id);
if(isset($data['status'])){
if($data['status']['id'] != $this->model->status_id || $data['status']['remarks'] !== null){
$this->model->status_id = $data['status']['id'];
$this->model->save();
$date = $data['status']['date'] ? _reformat_date($data['status']['date']) : _reformat_date(now());
$this->model->updateNextDueDate($date);
$fill = [
'status_id' => $data['status']['id'],
'lead_id' => $this->model->id,
'sf_guard_user_id' => $this->model->sf_guard_user_id,
'date' => $date,
'remarks' => $data['status']['remarks'],
'target_date' => $this->model->next_due_date,
'created_at' => now(),
];
StatusHistory::create($fill);
}
}
return $this->model;
}

104
app/Services/Lead.php Normal file
View file

@ -0,0 +1,104 @@
<?php
namespace App\Services;
use App\Models\Airline;
use App\Models\CMSContent;
use App\Models\Insurance;
use App\Models\TravelCompany;
class Lead
{
public static function contentFiles(){
$lead_files = CMSContent::where('identifier', '=', 'lead-email-file')->get()->sortByDesc('pos')->pluck('slug', 'id');
return $lead_files;
}
public static function getCustomerMailDirs(){
$customer_mail_dirs = CMSContent::where('identifier', '=', 'customer-lead-mail-dirs')->get()->sortBy('pos');
return $customer_mail_dirs;
}
public static function getCustomerMailDir($id){
return CMSContent::where('identifier', '=', 'customer-lead-mail-dirs')->where('pos', '=', $id)->first();
}
/* public static function getCustomerMailName($customer_mail_dir, $mail_dir_id){
switch ($customer_mail_dir->getArrayContent('model')){
case 'TravelCountry':
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
break;
case 'Airline':
$model = Airline::find($mail_dir_id);
break;
case 'Insurance':
$model = Insurance::find($mail_dir_id);
break;
case 'TravelCompany':
$model = TravelCompany::find($mail_dir_id);
break;
default:
return '';
}
if($model){
if($customer_mail_dir->getArrayContent('model') === 'TravelCountry'){
return $model->mail_dir_name;
}
return $model->name;
}
return "";
}
public static function getCustomerMailEmails($customer_mail_dir, $mail_dir_id){
switch ($customer_mail_dir->getArrayContent('model')){
case 'TravelCountry':
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
break;
case 'Airline':
$model = Airline::find($mail_dir_id);
break;
case 'Insurance':
$model = Insurance::find($mail_dir_id);
break;
case 'TravelCompany':
$model = TravelCompany::find($mail_dir_id);
break;
default:
//direkt from CMSContent
return $customer_mail_dir->getArrayContent('emails');
}
if($model){
return $model->contact_emails;
}
return [];
}
public static function getFeWoInstructionPDFName($fewo){
return "HINWEISE-FERIENWOHNUNG-".$fewo->pdf_name.".pdf";
}
public static function getFeWoCMSContent($content, $identifier_fewo){
return CMSContent::where('identifier', '=', $identifier_fewo)->where('integer', $content->id)->get()->sortBy('pos');
}
public static function getFeWoCMSContentForPDF($identifier_content, $identifier_fewo){
$pdf_content = [];
$contents = CMSContent::where('identifier', '=', $identifier_content)->get()->sortBy('pos');
foreach ($contents as $content){
if($content->decimal > 0){ //in_pdf
$pdf_content[] = $content;
}
if($fewo_contents = BookingFewo::getFeWoCMSContent($content, $identifier_fewo)){
foreach ($fewo_contents as $fewo_content){
if($fewo_content->decimal > 0){ //in_pdf
$pdf_content[] = $fewo_content;
}
}
}
}
return $pdf_content;
}*/
}

View file

@ -84,6 +84,12 @@ return [
'url' => env('APP_URL').'/storage/booking_fewo',
'visibility' => 'public',
],
'lead' => [
'driver' => 'local',
'root' => storage_path('app/lead'),
'url' => env('APP_URL').'/storage/lead',
'visibility' => 'public',
],
'fewo_invoices' => [
'driver' => 'local',
'root' => storage_path('app/fewo/invoices'),

View file

@ -0,0 +1,77 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLeadMailsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('lead_mails', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('lead_id');
$table->bigInteger('customer_id');
$table->boolean('is_answer')->default(false);
$table->unsignedBigInteger('reply_id');
$table->string('email', 255);
$table->text('recipient')->nullable();
$table->text('cc')->nullable();
$table->text('bcc')->nullable();
$table->string('subject', 255);
$table->text('message')->nullable();
$table->unsignedTinyInteger('dir')->default(0);
$table->bigInteger('subdir')->nullable();
$table->boolean('draft')->default(false);
$table->boolean('important')->default(false);
$table->boolean('send')->default(false);
$table->boolean('fail')->default(false);
$table->text('error')->nullable();
$table->text('forward')->nullable();
$table->timestamp('sent_at')->nullable();
$table->timestamp('scheduled_at')->nullable();
$table->timestamp('delivered_at')->nullable();
$table->timestamps();
$table->foreign('customer_id')
->references('id')
->on('customer')
->onDelete('CASCADE');
$table->foreign('lead_id')
->references('id')
->on('lead')
->onDelete('CASCADE');
$table->foreign('reply_id')
->references('id')
->on('customer_mails')
->onDelete('CASCADE');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('lead_mails');
}
}

View file

@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLeadFilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('lead_files', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('lead_id');
$table->unsignedBigInteger('lead_mail_id')->nullable();
$table->string('identifier')->index();
$table->string('filename');
$table->string('dir');
$table->string('original_name');
$table->string('ext');
$table->string('mine');
$table->unsignedInteger('size');
$table->timestamps();
$table->foreign('lead_id')
->references('id')
->on('lead')
->onDelete('CASCADE');
$table->foreign('lead_mail_id')
->references('id')
->on('lead_mails')
->onDelete('CASCADE');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('lead_files');
}
}

View file

@ -0,0 +1,58 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLeadNoticesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('lead_notices', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('lead_id');
//from
$table->unsignedInteger('from_user_id');
//to
$table->unsignedInteger('to_user_id')->nullable();
$table->text('message')->nullable();
$table->boolean('show')->default(false);
$table->boolean('important')->default(false);
$table->timestamp('edit_at')->nullable();
$table->timestamps();
$table->foreign('lead_id')
->references('id')
->on('lead')
->onDelete('CASCADE');
$table->foreign('from_user_id')
->references('id')
->on('users')
->onDelete('CASCADE');
$table->foreign('to_user_id')
->references('id')
->on('users')
->onDelete('CASCADE');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('lead_notices');
}
}

View file

@ -102,9 +102,6 @@
</li>
</ul>
{!! Form::open(['url' => route('booking_detail', [$id]), 'class' => 'form-horizontal', 'id'=>'lead-form-validation']) !!}
<input type="hidden" name="id" id="id" value="{{$id}}">

View file

@ -14,7 +14,7 @@
<div class="modal-body">
<div class="form-group">
<label for="full_text" class="form-label">{{ __('Notiz') }}</label>
<label for="booking_notice" class="form-label">{{ __('Notiz') }}</label>
{{ Form::textarea('booking_notice', $value->message, array('placeholder'=>__('Notiz bearbeiten'), 'class'=>'form-control', 'rows'=>8)) }}
</div>
</div>

View file

@ -0,0 +1,83 @@
<div class="card mb-2 border-primary">
<h6 class="card-header bg-primary text-white py-2" data-toggle="collapse" data-target="#collapseLeadCustomer" aria-expanded="false" aria-controls="collapseLeadCustomer">
<strong style="line-height: 1.6em">Kunde</strong>
</h6>
<div class="collapse" id="collapseLeadCustomer">
<div class="card-body">
@if($lead->customer->count())
<div class="form-row">
<div class="form-group col-sm-6">
<label class="form-label" for="customer_id">{{ __('Kunden ID') }}</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<a class="text-primary" href="{{route('customer_detail', [$lead->customer->id])}}"><i class="fa fa-edit"></i></a></span>
</div>
{{ Form::text('customer[id]', $lead->customer->id, array('placeholder'=>__('Kunden ID'), 'class'=>'form-control', 'id'=>'customer_id', 'readonly')) }}
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col-sm-3">
<label for="salutation_id" class="form-label">{{ __('Anrede') }}*</label>
{{ Form::select('customer[salutation_id]', \App\Models\Customer::$salutationType , $lead->customer->salutation_id, array('class'=>'custom-select', 'required'=>true)) }}
</div>
<div class="form-group col-sm-4">
<label class="form-label" for="customer_firstname">{{ __('Vorname') }}*</label>
{{ Form::text('customer[firstname]', $lead->customer->firstname, array('placeholder'=>__('Vorname'), 'class'=>'form-control', 'id'=>'customer_firstname', 'required'=>true)) }}
</div>
<div class="form-group col-sm-5">
<label class="form-label" for="customer_name">{{ __('Nachname') }}*</label>
{{ Form::text('customer[name]', $lead->customer->name, array('placeholder'=>__('Nachname'), 'class'=>'form-control', 'id'=>'customer_name', 'required'=>true)) }}
</div>
<div class="form-group col-sm-12">
<label class="form-label" for="customer_street">{{ __('Straße') }}</label>
{{ Form::text('customer[street]', $lead->customer->street, array('placeholder'=>__('Straße'), 'class'=>'form-control', 'id'=>'customer_street')) }}
</div>
<div class="form-group col-sm-3">
<label class="form-label" for="customer_zip">{{ __('PLZ') }}</label>
{{ Form::text('customer[zip]', $lead->customer->zip, array('placeholder'=>__('PLZ'), 'class'=>'form-control', 'id'=>'customer_zip')) }}
</div>
<div class="form-group col-sm-4">
<label class="form-label" for="customer_city">{{ __('Stadt') }}</label>
{{ Form::text('customer[city]', $lead->customer->city, array('placeholder'=>__('Stadt'), 'class'=>'form-control', 'id'=>'customer_city')) }}
</div>
<div class="form-group col-sm-5">
<label class="form-label" for="customer_country_id">{{ __('Land') }}*</label>
{{ Form::select('customer[country_id]', \App\Models\Customer::getCustomerCountriesArray() , $lead->customer->country_id, array('class'=>'custom-select', 'required'=>true)) }}
</div>
<div class="form-group col-sm-6">
<label class="form-label" for="customer_phone">{{ __('Telefon') }}</label>
{{ Form::text('customer[phone]', $lead->customer->phone, array('placeholder'=>__('Telefon'), 'class'=>'form-control', 'id'=>'customer_phone')) }}
</div>
<div class="form-group col-sm-6">
<label class="form-label" for="customer_phonemobile">{{ __('Telefon Mobil') }}</label>
{{ Form::text('customer[phonemobile]', $lead->customer->phonemobile, array('placeholder'=>__('Telefon Mobil'), 'class'=>'form-control', 'id'=>'customer_phonemobile')) }}
</div>
<div class="form-group col-sm-12">
<label class="form-label" for="customer_email">{{ __('E-Mail') }}*</label>
{{ Form::text('customer[email]', $lead->customer->email, array('placeholder'=>__('E-Mail'), 'class'=>'form-control', 'id'=>'customer_email', 'required'=>true)) }}
</div>
<div class="col-sm-12">
<div class="text-left mt-2">
<button type="submit" name="action" value="saveCustomer" class="btn btn-sm btn-secondary">Änderungen speichern</button>&nbsp;
<a href="{{route('leads')}}" class="btn btn-sm btn-default">{{ __('zur Übersicht') }}</a>
</div>
</div>
</div>
@endif
</div>
</div>
</div>

View file

@ -0,0 +1,92 @@
<!-- Files -->
<div class="card mb-2">
<h6 class="card-header bg-primary text-white py-2" data-toggle="collapse" data-target="#collapseLeadFiles" aria-expanded="false" aria-controls="collapseLeadFiles">
<strong style="line-height: 1.6em">PDF Dateien</strong>
</h6>
<div class="collapse" id="collapseLeadFiles">
@php($lead_files_count = 1)
<div class="card-body row">
<div class="table-responsive" id="lead_files_table">
<table class="table table-striped table-sm">
<thead>
<tr>
<th>#</th>
<th>Datei</th>
<th>Inhalt</th>
<th>Datum</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
@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>
<a href="{{ $file->getURL('download') }}" class="btn btn-xs btn-default"
title="Download" data-placement="left" rel="tooltip">
<i class="fa fa-download"></i>
</a>
</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>
<a href="{{ $lead_file->getURL('download') }}" class="btn btn-xs btn-default"
title="Download" data-placement="left" rel="tooltip">
<i class="fa fa-download"></i>
</a>
<a class="ml-2 btn btn-xs btn-danger" href="{{ route('lead_delete', [$lead_file->id, 'lead_files']) }}" onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a>
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
<div class="text-right d-block w-100">
@if(Auth::user()->isPermission('sua-st-em'))
<div class="float-left small">Allgemeine Dateien unter: <a href="{{route('admin_settings_emails', ['settings'])}}">Einstellungen -> E-Mails / Einstellungen</a></div>
@endif
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal"
data-target="#modals-load-content"
data-id="new-file"
data-model="LeadFile"
data-action="modal-upload-lead-file"
data-url=""
data-redirect="back"
data-lead_id="{{$lead->id}}"
data-route="{{ route('lead_mail_modal_load') }}"><i class="ion ion-md-cloud-upload"></i>&nbsp;Datei hinzufügen</button>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,79 @@
<div class="card mb-2 border-primary">
<h6 class="card-header bg-primary text-white py-2" data-toggle="collapse" data-target="#collapseLeadInfo" aria-expanded="false" aria-controls="collapseLeadInfo">
<strong style="line-height: 1.6em">Kunde</strong>
</h6>
<div class="collapse" id="collapseLeadInfo">
<div class="card-body">
@if($lead->customer->count())
<div class="form-row">
<div class="form-group col-sm-6">
<label class="form-label" for="customer_id">{{ __('Kunden ID') }}</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<a class="text-primary" href="{{route('customer_detail', [$lead->customer->id])}}"><i class="fa fa-edit"></i></a></span>
</div>
{{ Form::text('customer[id]', $lead->customer->id, array('placeholder'=>__('Kunden ID'), 'class'=>'form-control', 'id'=>'customer_id', 'readonly')) }}
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col-sm-3">
<label for="salutation_id" class="form-label">{{ __('Anrede') }}*</label>
{{ Form::select('customer[salutation_id]', \App\Models\Customer::$salutationType , $lead->customer->salutation_id, array('class'=>'custom-select', 'required'=>true)) }}
</div>
<div class="form-group col-sm-4">
<label class="form-label" for="customer_firstname">{{ __('Vorname') }}*</label>
{{ Form::text('customer[firstname]', $lead->customer->firstname, array('placeholder'=>__('Vorname'), 'class'=>'form-control', 'id'=>'customer_firstname', 'required'=>true)) }}
</div>
<div class="form-group col-sm-5">
<label class="form-label" for="customer_name">{{ __('Nachname') }}*</label>
{{ Form::text('customer[name]', $lead->customer->name, array('placeholder'=>__('Nachname'), 'class'=>'form-control', 'id'=>'customer_name', 'required'=>true)) }}
</div>
<div class="form-group col-sm-12">
<label class="form-label" for="customer_street">{{ __('Straße') }}</label>
{{ Form::text('customer[street]', $lead->customer->street, array('placeholder'=>__('Straße'), 'class'=>'form-control', 'id'=>'customer_street')) }}
</div>
<div class="form-group col-sm-3">
<label class="form-label" for="customer_zip">{{ __('PLZ') }}</label>
{{ Form::text('customer[zip]', $lead->customer->zip, array('placeholder'=>__('PLZ'), 'class'=>'form-control', 'id'=>'customer_zip')) }}
</div>
<div class="form-group col-sm-4">
<label class="form-label" for="customer_city">{{ __('Stadt') }}</label>
{{ Form::text('customer[city]', $lead->customer->city, array('placeholder'=>__('Stadt'), 'class'=>'form-control', 'id'=>'customer_city')) }}
</div>
<div class="form-group col-sm-5">
<label class="form-label" for="customer_country_id">{{ __('Land') }}*</label>
{{ Form::select('customer[country_id]', \App\Models\Customer::getCustomerCountriesArray() , $lead->customer->country_id, array('class'=>'custom-select', 'required'=>true)) }}
</div>
<div class="form-group col-sm-6">
<label class="form-label" for="customer_phone">{{ __('Telefon') }}</label>
{{ Form::text('customer[phone]', $lead->customer->phone, array('placeholder'=>__('Telefon'), 'class'=>'form-control', 'id'=>'customer_phone')) }}
</div>
<div class="form-group col-sm-6">
<label class="form-label" for="customer_phonemobile">{{ __('Telefon Mobil') }}</label>
{{ Form::text('customer[phonemobile]', $lead->customer->phonemobile, array('placeholder'=>__('Telefon Mobil'), 'class'=>'form-control', 'id'=>'customer_phonemobile')) }}
</div>
<div class="form-group col-sm-12">
<label class="form-label" for="customer_email">{{ __('E-Mail') }}*</label>
{{ Form::text('customer[email]', $lead->customer->email, array('placeholder'=>__('E-Mail'), 'class'=>'form-control', 'id'=>'customer_email', 'required'=>true)) }}
</div>
</div>
@endif
<div class="text-left mt-3 pl-1">
<button type="submit" name="action" value="saveCustomer" class="btn btn-sm btn-secondary">Änderungen speichern</button>&nbsp;
<a href="{{route('leads')}}" class="btn btn-sm btn-default">{{ __('zur Übersicht') }}</a>
</div>
</div>
</div>
</div>

View file

@ -0,0 +1,79 @@
<div class="card mb-2 border-primary">
<h6 class="card-header bg-primary text-white py-2" data-toggle="collapse" data-target="#collapseLeadDetail" aria-expanded="false" aria-controls="collapseLeadDetail">
<strong style="line-height: 1.6em">Anfrage</strong>
</h6>
<div class="collapse" id="collapseLeadDetail">
<div class="card-body row">
@if($lead->count())
<div class="form-group col-sm-6 col-md-4">
<label class="form-label" for="lead_id">{{ __('Anfrage ID') }}</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<a class="text-primary" href="{{route('lead_detail', [$lead->id])}}"><i class="fa fa-edit"></i></a></span>
</div>
{{ Form::text('lead[id]', $lead->id, array('placeholder'=>__('Anfrage ID'), 'class'=>'form-control', 'id'=>'lead_id', 'readonly')) }}
</div>
</div>
<div class="form-group col-sm-6 col-md-4">
<label for="sf_guard_user_id" class="form-label">{{ __('Sachbearbeiter') }}*</label>
{{ Form::select('sf_guard_user_id', \App\Models\Lead::getSfGuardUserArray() , $lead->sf_guard_user_id, array('class'=>'custom-select', 'required'=>true)) }}
</div>
<div class="form-group col-sm-6 col-md-4">
<label class="form-label" for="request_date">{{ __('Anfragedatum') }}*</label>
{{ Form::text('request_date', _format_date($lead->request_date), array('placeholder'=>__('Anfragedatum'), 'class'=>'form-control datepicker-base', 'id'=>'request_date', 'required'=>true)) }}
</div>
<div class="form-group col-sm-6 col-md-4">
<label class="form-label" for="travelperiod_start">{{ __('Reisezeitraum vom') }}</label>
{{ Form::text('travelperiod_start', _format_date($lead->travelperiod_start), array('placeholder'=>__('Reisezeitraum vom'), 'class'=>'form-control datepicker-base', 'id'=>'travelperiod_start')) }}
</div>
<div class="form-group col-sm-6 col-md-4">
<label class="form-label" for="travelperiod_end">{{ __('Reisezeitraum bis') }}</label>
{{ Form::text('travelperiod_end', _format_date($lead->travelperiod_end), array('placeholder'=>__('Reisezeitraum bis'), 'class'=>'form-control datepicker-base', 'id'=>'travelperiod_end')) }}
</div>
<div class="form-group col-sm-6 col-md-2">
<label class="form-label" for="travelperiod_length">{{ __('Reisedauer (Tage)') }}</label>
{{ Form::text('travelperiod_length', $lead->travelperiod_length, array('placeholder'=>__('Reisedauer (Tage)'), 'class'=>'form-control', 'id'=>'travelperiod_length')) }}
</div>
<div class="form-group col-sm-6 col-md-2">
<label class="form-label" for="pax">{{ __('Pax bis') }}</label>
{{ Form::text('pax', $lead->pax, array('placeholder'=>__('Pax'), 'class'=>'form-control', 'id'=>'pax')) }}
</div>
<div class="form-group col-sm-6 col-md-4">
<label for="travelcountry_id" class="form-label">{{ __('Reiseland') }}*</label>
{{ Form::select('travelcountry_id', \App\Models\Lead::getTravelCountryArray(true) , $lead->travelcountry_id, array('class'=>'custom-select')) }}
</div>
<div class="form-group col-sm-6 col-md-4">
<label class="form-label" for="travelagenda_id">{{ __('Reiseprogramm') }}</label>
{{ Form::select('travelagenda_id', \App\Models\Lead::getTravelAgendaArray(true) , $lead->travelagenda_id, array('class'=>'custom-select')) }}
</div>
<div class="form-group col-sm-6 col-md-4">
<label class="form-label" for="travelcategory_id">{{ __('Reiseart') }}</label>
{{ Form::select('travelcategory_id', \App\Models\Lead::getTravelCategoryArray(true) , $lead->travelcategory_id, array('class'=>'custom-select')) }}
</div>
<div class="col-sm-12">
<hr>
</div>
<div class="form-group col-sm-12">
<label for="remarks" class="form-label">{{ __('Anfrage') }}</label>
{{ Form::textarea('remarks', $lead->remarks, array('placeholder'=>__('Anfrage'), 'class'=>'form-control autoExpand', 'id'=>'remarks', 'rows'=>'1', 'data-min-rows'=>'1')) }}
</div>
<div class="col-sm-12">
<div class="text-left mt-2">
<button type="submit" name="action" value="saveLead" class="btn btn-sm btn-secondary">Änderungen speichern</button>&nbsp;
<a href="{{route('leads')}}" class="btn btn-sm btn-default">{{ __('zur Übersicht') }}</a>
</div>
</div>
@endif
</div>
</div>
</div>

View file

@ -0,0 +1,137 @@
<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">
<strong style="line-height: 1.6em">E-Mails</strong>
<span class="badge badge-secondary">{{$travel_user_booking_fewo->customer_fewo_mails->count()}}</span>
</h6>
<div class="collapse" id="collapseBookingMails">
<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-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>
<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-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>
</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>
</div>
<hr class="border-light mx-4 mt-0 mb-4">
<style>
.sidebox-nav-item {
color: #838387 !important;
}
.sidebox-nav-item_sub {
color: #a3a4a6 !important;
}
.sidebox-nav-item[href]:hover,
.sidebox-nav-item[href]:focus {
color: #606265 !important;
}
.sidebox-nav-item.active .item {
color: #3e4244 !important;
font-weight: 700 !important;
}
</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}}">
<div class="item">
<i class="ion {{$customer_mail_dir->getArrayContent('icon')}}"></i> {{$customer_mail_dir->name}}
</div>
<div class="badge {{$badge}}">{{$travel_user_booking_fewo->countCustomerMailsBy($customer_mail_dir->pos)}}</div>
</a>
@endforeach
@foreach($travel_user_booking_fewo::$customer_mail_dirs as $dir_id => $customer_mail_dir)
<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">
<i class="ion {{$customer_mail_dir['icon']}}"></i> {{$customer_mail_dir['name']}}
</div>
<div class="badge {{$badge}}">{{$travel_user_booking_fewo->countCustomerMailsBy($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>
<div class="media-body">&nbsp;
<i id="message-sidebox-title-icon" class="ion ion-ios-filing"></i> <span id="message-sidebox-title-name">Kunde</span>
</div>
<input type="text" class="form-control form-control-sm" placeholder="Suche ..." style="max-width: 10rem;" id="dataTableInputSearchField">
</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">
<thead>
<tr>
<th>&nbsp;</th>
{{-- <th>{{__('E-Mail')}}</th> --}}
<th>{{__('Betreff')}}</th>
<th>{{__('Datum')}}</th>
<th style="width: 100px">{{__('#')}}</th>
</tr>
</thead>
<tbody class="">
</tbody>
</table>
</div>
</div><!-- / .messages-content -->
</div>
</div>
</div><!-- / .messages-wrapper -->
</div>
</div>
</div>

View file

@ -0,0 +1,58 @@
<div class="card mb-2">
<h6 class="card-header bg-primary text-white py-2" data-toggle="collapse" data-target="#collapseLeadNotice" aria-expanded="false" aria-controls="collapseLeadNotice">
<strong style="line-height: 1.6em">Notizen</strong>
</h6>
<div class="collapse" id="collapseLeadNotice">
<div class="card-body row">
<div class="col-sm-12">
{!! Form::open(['url' => route('lead_detail', [$id]), 'class' => 'form-horizontal']) !!}
<input type="hidden" name="action" value="save_notice">
<div class="form-group">
{{ Form::textarea('lead_notice', '', array('placeholder'=>__('Neue Notiz hinzufügen …'), 'class'=>'form-control autoExpand', 'id'=>'booking_notice', 'rows'=>'1', 'data-min-rows'=>'1', 'required')) }}
</div>
<div class="form-group text-right">
<button type="submit" class="btn btn-sm btn-primary" ><i class="ion ion-ios-send"></i>&nbsp;Notiz hinzufügen</button>
<hr>
</div>
{!! Form::close() !!}
</div>
@if($lead->lead_notices)
@foreach($lead->lead_notices as $lead_notice)
<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">
<div class="font-weight-semibold mb-1">{{ $lead_notice->getName() }} | {{ $lead_notice->created_at->format("d.m.Y - H:i:s") }}
@else
<div class="bg-secondary rounded py-2 px-3 mr-3 mb-2">
<div class="font-weight-semibold mb-1">{{ $lead_notice->getName() }} | {{ $lead_notice->created_at->format("d.m.Y - H:i:s") }}
@endif
@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
@if($lead_notice->from_user_id === \Auth::user()->id || \Auth::user()->isPermission('sua-bo-n-edit'))
<div class="float-right"><a href="">
<a href="javascript:void(0)" class="btn btn-xs btn-white" data-toggle="modal" data-target="#modals-load-content"
data-id="{{ $lead_notice->id }}"
data-model="LeadNotice"
data-action="edit_notice"
data-url="{{ route('lead_detail', [$lead->id]) }}"
data-redirect="back"
data-lead_id="{{$lead->id}}"
data-route="{{ route('lead_modal_load') }}">
<i class="ion ion-ios-create"></i>
</a>
<a href="{{ route('lead_delete', [$lead_notice->id, 'lead_notice']) }}" class="btn btn-xs btn-white text-danger" onclick="return confirm('Wirklich löschen?');"><i class="ion ion-md-trash"></i></a>
</div>
@endif
</div>
{!! nl2br($lead_notice->message) !!}
</div>
</div>
@endforeach
@endif
</div>
</div>
</div>

View file

@ -0,0 +1,95 @@
<div class="card mb-2 border-primary">
<h6 class="card-header bg-primary text-white py-2" data-toggle="collapse" data-target="#collapseLeadStatus" aria-expanded="false" aria-controls="collapseLeadStatus">
<strong style="line-height: 1.6em">Status {!! $lead->getStatusBadge() !!}</strong>
</h6>
<div class="collapse" id="collapseLeadStatus">
<div class="card-body">
@if($lead->count())
<div class="row">
<div class="col-sm-6">
<label class="custom-control custom-checkbox mt-2">
{!! Form::checkbox('is_closed', 1, $lead->is_closed, ['class'=>'custom-control-input', 'readonly']) !!}
<span class="custom-control-label">{{__('Vorgang abgeschlossen')}}</span>
</label>
</div>
<div class="col-sm-6">
<label class="custom-control custom-checkbox mt-2">
{!! Form::checkbox('is_rebook', 1, $lead->is_rebook, ['class'=>'custom-control-input', 'readonly']) !!}
<span class="custom-control-label">{{__('Umbuchung abgeschlossen')}}</span>
</label>
</div>
<div class="col-sm-12">
<hr>
</div>
<div class="form-group col-sm-6 col-md-6">
<label class="form-label" for="status_id">{{ __('Status ändern') }} </label>
{{ Form::select('status[id]', \App\Models\Lead::getStatusArray() , $lead->status_id, array('class'=>'custom-select')) }}
</div>
<div class="form-group col-sm-12">
<label for="status_remarks" class="form-label">{{ __('Bemerkung für Statusänderung') }}</label>
{{ Form::textarea('status[remarks]', '', array('placeholder'=>__('Bemerkung'), 'class'=>'form-control autoExpand', 'id'=>'status_remarks', 'rows'=>'1', 'data-min-rows'=>'1')) }}
</div>
<div class="form-group col-sm-12">
<label class="form-label" for="status[date]">{{ __('Datum für Statusänderung') }}</label>
{{ Form::text('status[date]', _format_date(now()), array('placeholder'=>__('dd.mm.YY'), 'class'=>'form-control datepicker-base', 'id'=>'status[date]')) }}
</div>
<div class="col-sm-12">
<div class="text-left mt-2">
<button type="submit" name="action" value="saveStatus" class="btn btn-sm btn-secondary">Änderungen speichern</button>&nbsp;
<a href="{{route('leads')}}" class="btn btn-sm btn-default">{{ __('zur Übersicht') }}</a>
</div>
</div>
</div>
@if($lead->status_histories)
<div class="row">
<div class="col-sm-12"><hr></div>
<div class="col-sm-12">
<table class="table table-striped table-sm">
<thead>
<tr>
<th>Status</th>
<th>Sachbearbeiter</th>
<th>Datum</th>
<th>Zieldatum</th>
<th>Bemerkungen</th>
</tr>
</thead>
<tbody>
@foreach ($lead->status_histories as $status_history)
<tr>
<th scope="row">
@if($status_history->status)
{!! $status_history->status->getStatusBadge() !!}
@endif
</th>
<td>
@if($status_history->lead->sf_guard_user)
{{ $status_history->lead->sf_guard_user->fullname }}
@endif
</td>
<td>{{ _format_date($status_history->date) }}</td>
<td>{{ _format_date($status_history->target_date) }}</td>
<td>{{ $status_history->remarks }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endif
@endif
</div>
</div>
</div>

View file

@ -36,42 +36,207 @@
</style>
<div class="float-right mt-3">
<a href="{{route('leads')}}" class="btn btn-sm btn-default">{{ __('zur Übersicht') }}</a>
<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>
<h4 class="font-weight-bold py-3 mb-1">
Anfrage verwalten
</h4>
<ul class="nav nav-sm nav-tabs nav-justified tabs-alt mb-3" id="top-nav-quick-jump">
<li class="nav-item">
<a class="nav-link" href="javascript:void(0)" data-collapse="#collapseLeadCustomer">
Kunde
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:void(0)" data-collapse="#collapseLeadDetail">
Anfrage
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:void(0)" data-collapse="#collapseLeadStatus">
Status
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:void(0)" data-collapse="#collapseLeadMails">
E-Mails
<span class="badge badge-outline-primary">{{ $lead->lead_mails->count() }}</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:void(0)" data-collapse="#collapseLeadFiles">
PDF Dateien
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:void(0)" data-collapse="#collapseLeadNotice">
Notizen
</a>
</li>
</ul>
{!! Form::open(['url' => route('lead_detail', [$id]), 'class' => 'form-horizontal', 'id'=>'lead-form-validation']) !!}
<input type="hidden" name="id" id="id" value="{{$id}}">
<!-- Kunde -->
@include('lead._detail_customer')
<!-- Anfrage -->
@include('lead._detail_lead')
<!-- Status -->
@include('lead._detail_status')
{!! Form::close() !!}
<!-- draft -->
<div class="card mb-2">
<div class="card-body row">
@if($id !== "new")
{{--
@include('lead._detail_mails')
--}}
@include('lead._detail_files')
@endif
<div class="form-group col-sm-6">
<label class="form-label" for="lead_id">{{ __('Nr.') }}*</label>
{{ Form::text('id', $lead->id, array('placeholder'=>__('Nr.'), 'class'=>'form-control', 'id'=>'lead_id', 'readonly')) }}
</div>
@include('lead._detail_notice')
</div>
<div class="float-right mt-3">
<a href="{{route('leads')}}" class="btn btn-sm btn-default">{{ __('zur Übersicht') }}</a>
<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>
<div class="text-left mt-3">
<button type="submit" name="action" value="saveAll" class="btn btn-submit">{{ __('save changes') }}</button>&nbsp;
<a href="{{route('leads')}}" class="btn btn-default">{{ __('zur Übersicht') }}</a>
<a href="{{ make_old_url('/index.php/leads/'.$lead->id.'/edit') }}" class="btn btn-default float-right">{{ __('zurück ins CRM v2') }}</a>
</div>
{!! Form::close() !!}
<script>
$(document).ready(function() {
var collapseHashValue = null;
$('[rel="tooltip"]').tooltip({trigger: "hover"});
$('#top-nav-quick-jump .nav-link').on('click', function (e) {
e.preventDefault();
$('#top-nav-quick-jump .nav-link').removeClass('active');
$(this).addClass('active');
var collapse_id = $(this).data('collapse');
//console.log(collapse_id);
$(collapse_id).collapse('show');
// animate
$('html, body').animate({
scrollTop: $(collapse_id).parent('.card').offset().top
}, 300, function(){
// when done, add hash to url
// (default click behaviour)
window.location.hash = collapse_id;
});
});
$(".collapse").on('shown.bs.collapse', function (){
if(collapseHashValue){
$('a[data-collapse="#'+collapseHashValue+'"]').click();
collapseHashValue = null;
}
CookiesAddJSONValue('lead_collapse', $(this).attr('id'));
window.location.hash = "#"+$(this).attr('id');
});
$(".collapse").on('hidden.bs.collapse', function (){
CookiesRemoveJSONValue('lead_collapse', $(this).attr('id'));
});
function init_site(){
if(window.location.hash){
value = $(window.location.hash).attr('id');
if(value){
collapseHashValue = value;
CookiesAddJSONValue('lead_collapse', value);
}
}
var lead_collapses = Cookies.get('lead_collapse');
if (lead_collapses != null)
{
lead_collapses = JSON.parse(lead_collapses);
for (var lead_collapse in lead_collapses){
$("#"+lead_collapses[lead_collapse]).collapse("show");
}
}
}
init_site();
/*
var oTable = $('#datatables-customer-mails').DataTable({
"processing": true,
"serverSide": true,
"searching": false,
ajax: {
url: '{!! route( 'customer_fewo_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.data_table_search = $('#dataTableInputSearchField').val();
}
},
"columns": [
{ data: 'important', width: '15px', searchable: false },
{ data: 'subject', name: 'subject', width: '', orderable: false, },
{ data: 'date', name: 'date', width: '' },
{ data: 'action', width: '100px', orderable: false, searchable: false},
],
"bLengthChange": false,
"iDisplayLength": 25,
"orderSequence": ["desc", "asc"],
"order": [[ 2, "desc" ]],
"language": {
"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);
});
}
});
function callback_customer_mails_data_table(data) {
if(data.status === 'success'){
oTable.draw();
}
}
$('.messages-wrapper .sidebox-nav-item').on('click', function (event) {
event.preventDefault();
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'));
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);
}else{
$('.btn-compare-customer-mails').prop('disabled', true);
}
oTable.draw();
$('.messages-wrapper .sidebox-nav-item').removeClass('active');
$(this).addClass('active');
$('#message-sidebox-title-icon').removeClass().addClass('fa ' + $(this).data('icon'));
$('#message-sidebox-title-name').html($(this).data('name'));
$('.messages-wrapper .sidebox-nav-item').find('.badge-primary').removeClass('badge-primary').addClass('badge-outline-primary');
$(this).find('.badge').removeClass('badge-outline-primary').addClass('badge-primary');
});
$('#dataTableInputSearchField').keyup(function(){
oTable.search($(this).val()).draw();
});
});
*/
});
</script>

View file

@ -0,0 +1,31 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">
{{ __('Notiz') }}
<span class="font-weight-light">bearbeiten</span>
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
</div>
{!! Form::open(['url' => $data['url'], 'class' => '', 'id'=>'edit-notice-form']) !!}
{{ Form::hidden('lead_id', $data['lead_id']) }}
{{ Form::hidden('action', $data['action']) }}
{{ Form::hidden('notice_id', $data['id']) }}
<div class="modal-body">
<div class="form-group">
<label for="full_text" class="form-label">{{ __('Notiz') }}</label>
{{ Form::textarea('lead_notice', $value->message, array('placeholder'=>__('Notiz bearbeiten'), 'class'=>'form-control', 'rows'=>8)) }}
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">schließen</button>
<button type="submit" class="btn btn-primary" name="update-action" value="save-edit-notice">speichern</button>
</div>
{!! Form::close() !!}
</div>
<script type="text/javascript">
</script>

View file

@ -43,7 +43,7 @@
{ data: 'customer.email', name: 'customer.email' },
{ data: 'request_date', name: 'request_date' },
{ data: 'sf_guard_user.last_name', name: 'sf_guard_user.last_name', searchable: false },
{ data: 'status.name', name: 'status.name' },
{ data: 'status', name: 'status' },
],
"bLengthChange": false,

View file

@ -0,0 +1,105 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">
{{ __('Datei') }}
<span class="font-weight-light">hinzufügen</span>
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
</div>
<div class="modal-body">
<div class="form-row show-content-file">
<div class="col-12">
<div class="alert alert-danger alert-dismissable" style="display:none;"></div>
</div>
<div class="col-12 mt-2 mb-4">
{!! Form::open([ 'url' => route('lead_mail_modal_load'), 'method' => 'post', 'files' => true, 'enctype' => 'multipart/form-data', 'class' => 'dropzone', 'id' => 'uploadLeadFile' ]) !!}
<input type="hidden" name="lead_id" value="{{ $data['lead_id'] }}">
<input type="hidden" name="action" value="upload-lead-file">
<div class="fallback">
<input name="file" type="file" multiple>
</div>
{!! Form::close() !!}
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">schließen</button>
</div>
</div>
<script type="text/javascript">
var responseReaload = false;
$('#modals-load-content').on('hide.bs.modal', function (event) {
$(this).off('hide.bs.modal');
if(responseReaload){
responseReaload = false;
window.location.reload();
}
});
$( document ).ready(function() {
Dropzone.autoDiscover = false;
$("#uploadLeadFile").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
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
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();
$(file.previewElement).find('.dz-error-message').text(message);
$(file.previewElement).addClass('dz-error');
_ele.text(message);
},
success: function(file, response) {
// console.log(file);
// console.log(response);
$(file.previewElement).addClass('dz-success');
if(response.error === false){
responseReaload = true;
//window.location.href = window.location.href; //This is a possibility
// window.location.reload(); //Another possiblity
}
}
});
});
</script>

View file

@ -556,6 +556,172 @@
>Neue Datei anlegen</button>
</div>
</div>
<!-- Lead Anfragen -->
<h4 class="mt-4 mb-2 ml-4">Ordner für Anfragen/E-Mail Ablage</h4>
<div class="card-datatable table-responsive pt-0">
<table class="datatables-customer-lead-mail-dirs table table-striped table-bordered">
<thead>
<tr>
<th style="max-width: 60px;">&nbsp;</th>
<th style="width: 2%;">{{__('ID')}}</th>
<th>{{__('Name')}}</th>
<th>{{__('Icon')}}</th>
<th>{{__('Model')}}</th>
<th>{{__('E-Mails')}}</th>
</tr>
</thead>
<tbody>
@php($next_customer_lead_mail_dir_id = 0)
@foreach($customer_lead_mail_dirs as $customer_lead_mail_dir)
<tr>
<td class="not">
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-customer-lead-mail-dirs"
data-id="{{$customer_lead_mail_dir->id}}"
data-icon="{{$customer_lead_mail_dir->getArrayContent('icon')}}"
data-model="{{$customer_lead_mail_dir->getArrayContent('model')}}"
data-emails="{{\App\Services\Util::_implodeLines($customer_lead_mail_dir->getArrayContent('emails'))}}"
data-name="{{$customer_lead_mail_dir->name}}"
data-pos="{{$customer_lead_mail_dir->pos}}">
<span class="fa fa-edit"></span>
</button>
</td>
<td>{{ $customer_lead_mail_dir->pos }}</td>
<td>{{ $customer_lead_mail_dir->name }}</td>
<td>{{ $customer_lead_mail_dir->getArrayContent('icon') }}</td>
<td>{{ $customer_lead_mail_dir->getArrayContent('model') }}</td>
<td>
{!! \App\Services\Util::_implodeLines( $customer_lead_mail_dir->getArrayContent('emails'), "<br>") !!}
</td>
{{-- <td><a class="text-danger" href="" onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a></td> --}}
</tr>
@php($next_customer_lead_mail_dir_id = $customer_lead_mail_dir->pos+1)
@endforeach
</tbody>
</table>
<div class="mt-4 ml-3 text-left">
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-customer-lead-mail-dirs"
data-id="new"
data-icon=""
data-model=""
data-emails=""
data-name=""
data-pos="{{$next_customer_lead_mail_dir_id}}"
>Neuen Ordner anlegen</button>
</div>
</div>
<!-- Modal template -->
<div class="modal fade" id="modals-customer-lead-mail-dirs">
<div class="modal-dialog">
<form class="modal-content" action="{{ route('admin_settings_emails_update') }}" method="post">
@csrf
<input type="hidden" class="form-control" name="id">
<input type="hidden" class="form-control" name="action" value="customer_mail_dirs">
<input type="hidden" class="form-control" name="step" value="settings">
<input type="hidden" class="form-control" name="identifier" value="customer-lead-mail-dirs">
<input type="hidden" class="form-control" name="field" value="array">
<div class="modal-header">
<h5 class="modal-title">E-Mail Ordner <span class="font-weight-light">anlegen/bearbeiten</span></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
</div>
<div class="modal-body">
<div class="form-row">
<div class="form-group col">
<label for="pos" class="form-label">ID*</label>
<input type="text" class="form-control" name="pos" placeholder="{{__('ID')}}" required>
<em>Die ID definiert die Zuweisung der E-Mails in die jeweiligen Ordner, bei Änderungen der ID können schon zugeordnete E-Mails nicht mehr angezeigt werden.</em>
</div>
</div>
<div class="form-row">
<div class="form-group col">
<label for="name" class="form-label">Name*</label>
<input type="text" class="form-control" name="name" placeholder="{{__('Description')}}" required>
</div>
</div>
<div class="form-row">
<div class="form-group col">
<label for="icon" class="form-label">Icon*</label>
<input type="text" class="form-control" name="icon" placeholder="{{__('Icon')}}" required>
</div>
</div>
<div class="form-row">
<div class="form-group col">
<label for="model" class="form-label">Model <span class="text-muted">(wird benötigt um Unterordner unter Reiseländer zuzuweisen)</span></label>
<input type="text" class="form-control" name="model" placeholder="{{__('Model')}}">
<em>Das Model das muss vorab in der Programmierung erfasst werden.</em>
</div>
</div>
<div class="form-row">
<div class="form-group col">
<label class="form-label" for="emails">Für interene Mails <span class="text-muted">(jede E-Mail in eine extra Zeile)</span></label>
<textarea class="form-control" rows="4" name="emails" cols="50"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{__('close')}}</button>
<button type="submit" class="btn btn-primary">{{__('save')}}</button>
</div>
</form>
</div>
</div>
<hr>
<h4 class="mt-2 mb-0 ml-4">Allgemeine PDF Dateien für Anfragen/E-Mail-Anhänge</h4>
<div class="card-datatable table-responsive pt-0">
<table class="datatables-lead-email-files table table-striped table-bordered">
<thead>
<tr>
<th style="max-width: 60px;">&nbsp;</th>
<th style="width: 2%;">{{__('POS')}}</th>
<th>{{__('Name')}}</th>
<th>{{__('Slug')}}</th>
<th>{{__('Inhalt')}}</th>
<th>{{__('Type')}}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($lead_email_files as $value)
<tr>
<td class="not">
<button type="button" class="btn icon-btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
data-id="{{ $value->id }}"
data-pos="{{ $value->pos }}"
data-identifier="{{$identifier_lead_file}}"
data-model="content"
data-back="{{route('admin_settings_emails', ['settings'])}}"
data-route="{{ route('cms_content_all_load_modal') }}">
<span class="fa fa-edit"></span>
</button>
</td>
<td>{{ $value->pos }}</td>
<td>{{ $value->name }}</td>
<td>{{ $value->slug }}</td>
<td>@if($value->isFile()) {!! $value->getPreviewContent() !!} @else {{ $value->getPreviewContent() }} @endif</td>
<td>{{ $value->getFieldName() }}</td>
<td><a class="text-danger" href="{{ route('cms_content_all_delete', [$value->id]) }}" onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a></td>
</tr>
@endforeach
</tbody>
</table>
<div class="mt-4 ml-3 text-left">
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
data-id="new"
data-identifier="{{$identifier_lead_file}}"
data-field="file"
data-model="content"
data-back="{{route('admin_settings_emails', ['settings'])}}"
data-route="{{ route('cms_content_all_load_modal') }}"
>Neue Datei anlegen</button>
</div>
</div>
<script>
$( document ).ready(function() {
$('.datatables-booking-email-files').dataTable({
@ -590,6 +756,23 @@
"url": "/js/German.json"
}
});
$('.datatables-customer-lead-mail-dirs').dataTable({
"bLengthChange": false,
"iDisplayLength": 50,
"order": [[ 1, "asc" ]],
"language": {
"url": "/js/German.json"
}
});
$('.datatables-lead-email-files').dataTable({
"bLengthChange": false,
"iDisplayLength": 50,
"order": [[ 1, "desc" ]],
"language": {
"url": "/js/German.json"
}
});
$('#modals-customer-mail-dirs').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
@ -610,6 +793,16 @@
$(this).find(".modal-body input[name='model']").val(button.data('model'));
$(this).find(".modal-body textarea[name='emails']").val(button.data('emails'));
});
$('#modals-customer-lead-mail-dirs').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
$(this).find(".modal-content input[name='id']").val(button.data('id'));
$(this).find(".modal-body input[name='name']").val(button.data('name'));
$(this).find(".modal-body input[name='pos']").val(button.data('pos'));
$(this).find(".modal-body input[name='icon']").val(button.data('icon'));
$(this).find(".modal-body input[name='model']").val(button.data('model'));
$(this).find(".modal-body textarea[name='emails']").val(button.data('emails'));
});
});
</script>
</div>

View file

@ -33,7 +33,7 @@
</div>
<div class="form-row">
<div class="form-group col-sm-12">
<label for="percentage" class="form-label">Type</label>
<label for="type" class="form-label">Type</label>
{{ Form::select('type', \App\Models\ServiceProvider::$types , $model->type, array('class'=>'custom-select', 'required'=>true)) }}
</div>
</div>

View file

@ -120,6 +120,15 @@ Route::group(['middleware' => ['admin']], function()
Route::post('customer_fewo_mail/ajax', 'CustomerFewoMailController@ajax')->name('customer_fewo_mail_ajax');
Route::post('/customer_fewo_mail/modal/load', 'CustomerFewoMailController@loadModal')->name('customer_fewo_modal_load');
Route::post('/lead_mail/upload/attachment/{id}', 'LeadMailController@uploadAttachment')->name('lead_mail_upload_attachment');
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('/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::group(['middleware' => ['auth.permission:cms-iq-assets']], function() {
//assets
@ -186,7 +195,8 @@ Route::group(['middleware' => ['admin']], function()
Route::get('/leads/{step?}', 'LeadController@index')->name('leads');
Route::get('/lead/detail/{id}', 'LeadController@detail')->name('lead_detail');
Route::post('/lead/detail/{id}', 'LeadController@store')->name('lead_detail');
Route::get('/lead/delete/{id}', 'LeadController@delete')->name('lead_delete');
Route::get('/lead/delete/{id}/{del?}', 'LeadController@delete')->name('lead_delete');
Route::post('/lead/modal/load', 'LeadController@loadModal')->name('lead_modal_load');
});
Route::group(['middleware' => ['auth.permission:crm-bo-cu']], function() {
//Buchungen > Kunden

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 KiB