diff --git a/app/Http/Controllers/FileController.php b/app/Http/Controllers/FileController.php index a4ac90c..3c2b386 100755 --- a/app/Http/Controllers/FileController.php +++ b/app/Http/Controllers/FileController.php @@ -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; diff --git a/app/Http/Controllers/LeadController.php b/app/Http/Controllers/LeadController.php index 444ecfd..0539f5b 100755 --- a/app/Http/Controllers/LeadController.php +++ b/app/Http/Controllers/LeadController.php @@ -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); } diff --git a/app/Http/Controllers/LeadMailController.php b/app/Http/Controllers/LeadMailController.php new file mode 100644 index 0000000..96b94d9 --- /dev/null +++ b/app/Http/Controllers/LeadMailController.php @@ -0,0 +1,387 @@ +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 ''; + }) + ->addColumn('id', function (CustomerFewoMail $customer_mail) { + return ''.$customer_mail->id.''; + }) + ->addColumn('booking', function (CustomerFewoMail $customer_mail) { + $out = $customer_mail->booking->travel_country_id ? $customer_mail->booking->travel_country->name." | " : "- | "; + $out .= $customer_mail->booking->travelagenda_id ? $customer_mail->booking->travel_agenda->name."" : "-"; + return $out; + }) + ->addColumn('travel_user_booking_fewo_id', function (CustomerFewoMail $customer_mail) { + return ''.$customer_mail->travel_user_booking_fewo_id.''; + }) + ->addColumn('customer_id', function (CustomerFewoMail $customer_mail) { + return ''.$customer_mail->customer_id.''; + }) + ->addColumn('send', function (CustomerFewoMail $customer_mail) { + return $customer_mail->send ? '' : ''; + }) + ->orderColumn('id', 'id $1') + ->orderColumn('travel_user_booking_fewo_id', 'travel_user_booking_fewo_id $1') + ->orderColumn('customer_id', 'customer_id $1') + ->orderColumn('send', 'send $1') + + ->filterColumn('id', function($query, $keyword) { + if($keyword != ""){ + $query->where('id', 'LIKE', '%'.$keyword.'%'); + } + }) + ->filterColumn('customer_id', function($query, $keyword) { + if($keyword != ""){ + $query->where('customer_id', 'LIKE', '%'.$keyword.'%'); + } + }) + ->filterColumn('travel_user_booking_fewo_id', function($query, $keyword) { + if($keyword != ""){ + $query->where('travel_user_booking_fewo_id', 'LIKE', '%'.$keyword.'%'); + } + }) + ->rawColumns(['action_edit', 'send', 'customer_id', 'travel_user_booking_fewo_id', 'id']) + ->make(true); + }*/ + + public function getEmailTemplates() + { + $query = EmailTemplate::with('email_template_dir')->select('email_templates.*')->where('active', '=', true); + + 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 ''; + }) + ->addColumn('email_template_dir.name', function (EmailTemplate $emailTemplate) { + return $emailTemplate->email_template_dir ? ''.$emailTemplate->email_template_dir->name.'' : ' '; + }) + ->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 '
+ +
'; + }) + ->addColumn('important', function (CustomerFewoMail $customer_mail) { + $icon = ($customer_mail->important ? 'ion-md-star' : 'ion-md-star-outline'); + return ''; + }) + ->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 ? '' : ''; + $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 ' + '.$to_icon.''.$customer_mail->subject.' + '.($customer_mail->customer_fewo_files->count() ? '  '.$customer_mail->customer_fewo_files->count().'' : ''); + + }) + ->addColumn('date', function (CustomerFewoMail $customer_mail) { + if($customer_mail->send){ + return ' '.$customer_mail->sent_at.''; + } + return ' '.$customer_mail->sent_at.''; + }) + ->addColumn('action', function (CustomerFewoMail $customer_mail) { + $ret = ''; + if(!$customer_mail->draft){ + $ret = ' + + +   + + + +  '; + } + $ret .= ''; + return '
'.$ret.'
'; + }) + + ->orderColumn('date', 'sent_at $1') + ->orderColumn('subject', 'subject $1') + ->orderColumn('important', 'important $1') + ->rawColumns(['checkbox', 'important', 'subject', 'date', 'action']) + ->make(true); + } +} + + diff --git a/app/Http/Controllers/RequestController.php b/app/Http/Controllers/RequestController.php index c1b0292..4506a67 100755 --- a/app/Http/Controllers/RequestController.php +++ b/app/Http/Controllers/RequestController.php @@ -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 = ' '; - } - if($booking->lead->status_id == 14 && !$booking->lead->is_rebook){ - $icon = ' '; - } - if($booking->lead->status_id == 15){ - $icon = ' '; - if($booking->lawyer_date){ - return ''.$icon.$booking->lawyer_date->format('d.m.Y').''; - } - } - return ''.$icon.$booking->lead->status->name.''; + if($booking->lead){ + return $booking->lead->getStatusBadge($booking); } return '-'; }) diff --git a/app/Http/Controllers/Settings/EmailsController.php b/app/Http/Controllers/Settings/EmailsController.php index eaa3a2f..b32e380 100755 --- a/app/Http/Controllers/Settings/EmailsController.php +++ b/app/Http/Controllers/Settings/EmailsController.php @@ -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 ]; diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 0419638..6581652 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -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'); + } } diff --git a/app/Models/Lead.php b/app/Models/Lead.php index 06e9b18..a81e2d3 100644 --- a/app/Models/Lead.php +++ b/app/Models/Lead.php @@ -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 = ' '; + } + if($this->status_id == 14 && !$this->is_rebook){ + $icon = ' '; + } + if($this->status_id == 15){ + $icon = ' '; + if($booking && $booking->lawyer_date){ + return ''.$icon.$booking->lawyer_date->format('d.m.Y').''; + } + } + return ''.$icon.$this->status->name.''; + } + return '-'; } } diff --git a/app/Models/LeadFile.php b/app/Models/LeadFile.php new file mode 100644 index 0000000..79c377d --- /dev/null +++ b/app/Models/LeadFile.php @@ -0,0 +1,100 @@ + '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; + } + } +} diff --git a/app/Models/LeadMail.php b/app/Models/LeadMail.php new file mode 100644 index 0000000..4147930 --- /dev/null +++ b/app/Models/LeadMail.php @@ -0,0 +1,114 @@ + '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); + } +} diff --git a/app/Models/LeadNotice.php b/app/Models/LeadNotice.php new file mode 100644 index 0000000..c1f15dc --- /dev/null +++ b/app/Models/LeadNotice.php @@ -0,0 +1,91 @@ + '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; + } +} diff --git a/app/Models/SfGuardUser.php b/app/Models/SfGuardUser.php index 43cb9e5..d3dbf4e 100755 --- a/app/Models/SfGuardUser.php +++ b/app/Models/SfGuardUser.php @@ -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; + } + } diff --git a/app/Models/Status.php b/app/Models/Status.php index 9e64280..6d560a4 100644 --- a/app/Models/Status.php +++ b/app/Models/Status.php @@ -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 = ' '; + } + if($this->id == 15){ + $icon = ' '; + + } + return ''.$icon.$this->name.''; } /*public function status_histories() diff --git a/app/Models/StatusHistory.php b/app/Models/StatusHistory.php index cba39cc..16b3fae 100644 --- a/app/Models/StatusHistory.php +++ b/app/Models/StatusHistory.php @@ -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() diff --git a/app/Repositories/BookingFewoFileRepository.php b/app/Repositories/BookingFewoFileRepository.php index fec742b..fe385a5 100644 --- a/app/Repositories/BookingFewoFileRepository.php +++ b/app/Repositories/BookingFewoFileRepository.php @@ -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, diff --git a/app/Repositories/CustomerRepository.php b/app/Repositories/CustomerRepository.php index 4b54124..2bfcc9e 100644 --- a/app/Repositories/CustomerRepository.php +++ b/app/Repositories/CustomerRepository.php @@ -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']); + } + } + } \ No newline at end of file diff --git a/app/Repositories/LeadFileRepository.php b/app/Repositories/LeadFileRepository.php new file mode 100644 index 0000000..54623fc --- /dev/null +++ b/app/Repositories/LeadFileRepository.php @@ -0,0 +1,46 @@ +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); + } + +} \ No newline at end of file diff --git a/app/Repositories/LeadMailRepository.php b/app/Repositories/LeadMailRepository.php new file mode 100644 index 0000000..4cdbb40 --- /dev/null +++ b/app/Repositories/LeadMailRepository.php @@ -0,0 +1,387 @@ +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 .= "<".$customer_mail->email."> ".$customer_mail->sent_at."\n"; + $ret .= "".$customer_mail->subject."\n"; + $ret .= $customer_mail->message; + } + if($customer_mail->customer_mail){ + $ret .= $this->prepareMessageFull($customer_mail->customer_mail, $deep+1); + } + return $ret; + } + + private function prepareContent($booking_fewo, $content){ + $content = Placeholder::replaceBookingFewo($booking_fewo, $content); + 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(); + } + + } + } + +} \ No newline at end of file diff --git a/app/Repositories/LeadRepository.php b/app/Repositories/LeadRepository.php index 0f8de18..4600798 100644 --- a/app/Repositories/LeadRepository.php +++ b/app/Repositories/LeadRepository.php @@ -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; } diff --git a/app/Services/Lead.php b/app/Services/Lead.php new file mode 100644 index 0000000..0d93f3c --- /dev/null +++ b/app/Services/Lead.php @@ -0,0 +1,104 @@ +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; + }*/ +} \ No newline at end of file diff --git a/config/filesystems.php b/config/filesystems.php index e8b21c1..2318ca2 100755 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -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'), diff --git a/database/migrations/2021_05_07_124246_create_lead_mails_table.php b/database/migrations/2021_05_07_124246_create_lead_mails_table.php new file mode 100644 index 0000000..9920453 --- /dev/null +++ b/database/migrations/2021_05_07_124246_create_lead_mails_table.php @@ -0,0 +1,77 @@ +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'); + } +} diff --git a/database/migrations/2021_05_07_124341_create_lead_files_table.php b/database/migrations/2021_05_07_124341_create_lead_files_table.php new file mode 100644 index 0000000..1b7b572 --- /dev/null +++ b/database/migrations/2021_05_07_124341_create_lead_files_table.php @@ -0,0 +1,53 @@ +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'); + } +} diff --git a/database/migrations/2021_05_07_124345_create_lead_notices_table.php b/database/migrations/2021_05_07_124345_create_lead_notices_table.php new file mode 100644 index 0000000..2c1a82d --- /dev/null +++ b/database/migrations/2021_05_07_124345_create_lead_notices_table.php @@ -0,0 +1,58 @@ +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'); + } +} diff --git a/resources/views/booking/detail.blade.php b/resources/views/booking/detail.blade.php index 275dee0..9af8e27 100755 --- a/resources/views/booking/detail.blade.php +++ b/resources/views/booking/detail.blade.php @@ -102,9 +102,6 @@ - - - {!! Form::open(['url' => route('booking_detail', [$id]), 'class' => 'form-horizontal', 'id'=>'lead-form-validation']) !!} diff --git a/resources/views/booking/edit_notice_modal.blade.php b/resources/views/booking/edit_notice_modal.blade.php index cfad1b0..0de0d5f 100644 --- a/resources/views/booking/edit_notice_modal.blade.php +++ b/resources/views/booking/edit_notice_modal.blade.php @@ -14,7 +14,7 @@ diff --git a/resources/views/lead/_detail_customer.blade.php b/resources/views/lead/_detail_customer.blade.php new file mode 100644 index 0000000..4d5c47a --- /dev/null +++ b/resources/views/lead/_detail_customer.blade.php @@ -0,0 +1,83 @@ +
+ +
+
+ @if($lead->customer->count()) +
+
+ +
+
+ + +
+ {{ Form::text('customer[id]', $lead->customer->id, array('placeholder'=>__('Kunden ID'), 'class'=>'form-control', 'id'=>'customer_id', 'readonly')) }} +
+
+
+
+ +
+ + {{ Form::select('customer[salutation_id]', \App\Models\Customer::$salutationType , $lead->customer->salutation_id, array('class'=>'custom-select', 'required'=>true)) }} +
+ +
+ + {{ Form::text('customer[firstname]', $lead->customer->firstname, array('placeholder'=>__('Vorname'), 'class'=>'form-control', 'id'=>'customer_firstname', 'required'=>true)) }} +
+ +
+ + {{ Form::text('customer[name]', $lead->customer->name, array('placeholder'=>__('Nachname'), 'class'=>'form-control', 'id'=>'customer_name', 'required'=>true)) }} +
+ +
+ + {{ Form::text('customer[street]', $lead->customer->street, array('placeholder'=>__('Straße'), 'class'=>'form-control', 'id'=>'customer_street')) }} +
+ +
+ + {{ Form::text('customer[zip]', $lead->customer->zip, array('placeholder'=>__('PLZ'), 'class'=>'form-control', 'id'=>'customer_zip')) }} +
+ +
+ + {{ Form::text('customer[city]', $lead->customer->city, array('placeholder'=>__('Stadt'), 'class'=>'form-control', 'id'=>'customer_city')) }} +
+ +
+ + {{ Form::select('customer[country_id]', \App\Models\Customer::getCustomerCountriesArray() , $lead->customer->country_id, array('class'=>'custom-select', 'required'=>true)) }} +
+ +
+ + {{ Form::text('customer[phone]', $lead->customer->phone, array('placeholder'=>__('Telefon'), 'class'=>'form-control', 'id'=>'customer_phone')) }} +
+ +
+ + {{ Form::text('customer[phonemobile]', $lead->customer->phonemobile, array('placeholder'=>__('Telefon Mobil'), 'class'=>'form-control', 'id'=>'customer_phonemobile')) }} +
+ +
+ + {{ Form::text('customer[email]', $lead->customer->email, array('placeholder'=>__('E-Mail'), 'class'=>'form-control', 'id'=>'customer_email', 'required'=>true)) }} +
+ +
+
+   + {{ __('zur Übersicht') }} +
+
+ +
+ @endif +
+
+
\ No newline at end of file diff --git a/resources/views/lead/_detail_files.blade.php b/resources/views/lead/_detail_files.blade.php new file mode 100644 index 0000000..bd6fafa --- /dev/null +++ b/resources/views/lead/_detail_files.blade.php @@ -0,0 +1,92 @@ + +
+ +
+ + @php($lead_files_count = 1) +
+
+ + + + + + + + + + + + + @foreach(\App\Services\Lead::contentFiles() as $content_file) + @if($file = \App\Models\CMSContent::getModelBySlug($content_file)) + + + + + + + + @endif + @endforeach + + @if($lead->lead_files) + @foreach($lead->lead_files as $lead_file) + + + + + + + + @endforeach + @endif + +
#DateiInhaltDatum 
{{$lead_files_count++}} + + {{$file->name}} + + + {{ $file->formatBytes() }} + {{\App\Services\Util::_format_date($file->created_at, 'date')}} + + + +
{{$lead_files_count++}} + + {{$lead_file->original_name}} + + + {{ $lead_file->mine }} | {{ $lead_file->formatBytes() }} + {{\App\Services\Util::_format_date($lead_file->created_at, 'date')}} + + + + + +
+ +
+ +
+ @if(Auth::user()->isPermission('sua-st-em')) + + @endif + +
+
+
+
+ diff --git a/resources/views/lead/_detail_info.blade.php b/resources/views/lead/_detail_info.blade.php new file mode 100644 index 0000000..4bb19b8 --- /dev/null +++ b/resources/views/lead/_detail_info.blade.php @@ -0,0 +1,79 @@ +
+ +
+
+ @if($lead->customer->count()) +
+
+ +
+
+ + +
+ {{ Form::text('customer[id]', $lead->customer->id, array('placeholder'=>__('Kunden ID'), 'class'=>'form-control', 'id'=>'customer_id', 'readonly')) }} +
+
+
+
+ +
+ + {{ Form::select('customer[salutation_id]', \App\Models\Customer::$salutationType , $lead->customer->salutation_id, array('class'=>'custom-select', 'required'=>true)) }} +
+ +
+ + {{ Form::text('customer[firstname]', $lead->customer->firstname, array('placeholder'=>__('Vorname'), 'class'=>'form-control', 'id'=>'customer_firstname', 'required'=>true)) }} +
+ +
+ + {{ Form::text('customer[name]', $lead->customer->name, array('placeholder'=>__('Nachname'), 'class'=>'form-control', 'id'=>'customer_name', 'required'=>true)) }} +
+ +
+ + {{ Form::text('customer[street]', $lead->customer->street, array('placeholder'=>__('Straße'), 'class'=>'form-control', 'id'=>'customer_street')) }} +
+ +
+ + {{ Form::text('customer[zip]', $lead->customer->zip, array('placeholder'=>__('PLZ'), 'class'=>'form-control', 'id'=>'customer_zip')) }} +
+ +
+ + {{ Form::text('customer[city]', $lead->customer->city, array('placeholder'=>__('Stadt'), 'class'=>'form-control', 'id'=>'customer_city')) }} +
+ +
+ + {{ Form::select('customer[country_id]', \App\Models\Customer::getCustomerCountriesArray() , $lead->customer->country_id, array('class'=>'custom-select', 'required'=>true)) }} +
+ +
+ + {{ Form::text('customer[phone]', $lead->customer->phone, array('placeholder'=>__('Telefon'), 'class'=>'form-control', 'id'=>'customer_phone')) }} +
+ +
+ + {{ Form::text('customer[phonemobile]', $lead->customer->phonemobile, array('placeholder'=>__('Telefon Mobil'), 'class'=>'form-control', 'id'=>'customer_phonemobile')) }} +
+ +
+ + {{ Form::text('customer[email]', $lead->customer->email, array('placeholder'=>__('E-Mail'), 'class'=>'form-control', 'id'=>'customer_email', 'required'=>true)) }} +
+
+ @endif +
+   + {{ __('zur Übersicht') }} +
+
+
+
\ No newline at end of file diff --git a/resources/views/lead/_detail_lead.blade.php b/resources/views/lead/_detail_lead.blade.php new file mode 100644 index 0000000..2bbd987 --- /dev/null +++ b/resources/views/lead/_detail_lead.blade.php @@ -0,0 +1,79 @@ +
+ +
+
+ @if($lead->count()) + +
+ +
+
+ + +
+ {{ Form::text('lead[id]', $lead->id, array('placeholder'=>__('Anfrage ID'), 'class'=>'form-control', 'id'=>'lead_id', 'readonly')) }} +
+
+
+ + {{ Form::select('sf_guard_user_id', \App\Models\Lead::getSfGuardUserArray() , $lead->sf_guard_user_id, array('class'=>'custom-select', 'required'=>true)) }} +
+
+ + {{ Form::text('request_date', _format_date($lead->request_date), array('placeholder'=>__('Anfragedatum'), 'class'=>'form-control datepicker-base', 'id'=>'request_date', 'required'=>true)) }} +
+ +
+ + {{ Form::text('travelperiod_start', _format_date($lead->travelperiod_start), array('placeholder'=>__('Reisezeitraum vom'), 'class'=>'form-control datepicker-base', 'id'=>'travelperiod_start')) }} +
+
+ + {{ Form::text('travelperiod_end', _format_date($lead->travelperiod_end), array('placeholder'=>__('Reisezeitraum bis'), 'class'=>'form-control datepicker-base', 'id'=>'travelperiod_end')) }} +
+ +
+ + {{ Form::text('travelperiod_length', $lead->travelperiod_length, array('placeholder'=>__('Reisedauer (Tage)'), 'class'=>'form-control', 'id'=>'travelperiod_length')) }} +
+
+ + {{ Form::text('pax', $lead->pax, array('placeholder'=>__('Pax'), 'class'=>'form-control', 'id'=>'pax')) }} +
+ +
+ + {{ Form::select('travelcountry_id', \App\Models\Lead::getTravelCountryArray(true) , $lead->travelcountry_id, array('class'=>'custom-select')) }} +
+ +
+ + {{ Form::select('travelagenda_id', \App\Models\Lead::getTravelAgendaArray(true) , $lead->travelagenda_id, array('class'=>'custom-select')) }} +
+ +
+ + {{ Form::select('travelcategory_id', \App\Models\Lead::getTravelCategoryArray(true) , $lead->travelcategory_id, array('class'=>'custom-select')) }} +
+ +
+
+
+ +
+ + {{ Form::textarea('remarks', $lead->remarks, array('placeholder'=>__('Anfrage'), 'class'=>'form-control autoExpand', 'id'=>'remarks', 'rows'=>'1', 'data-min-rows'=>'1')) }} +
+ +
+
+   + {{ __('zur Übersicht') }} +
+
+ @endif +
+
+
\ No newline at end of file diff --git a/resources/views/lead/_detail_mails.blade.php b/resources/views/lead/_detail_mails.blade.php new file mode 100644 index 0000000..317b927 --- /dev/null +++ b/resources/views/lead/_detail_mails.blade.php @@ -0,0 +1,137 @@ +
+ +
+
+ + +
+ +
+ +
+
+
+ + + +
+ × +
+
+
+ + + + + @foreach(\App\Services\BookingFewo::getCustomerMailDirs() as $customer_mail_dir) + @php($badge = $customer_mail_dir->pos === 0 ? "badge-primary" : "badge-outline-primary") + +
+ {{$customer_mail_dir->name}} +
+
{{$travel_user_booking_fewo->countCustomerMailsBy($customer_mail_dir->pos)}}
+
+ @endforeach + @foreach($travel_user_booking_fewo::$customer_mail_dirs as $dir_id => $customer_mail_dir) + +
+ {{$customer_mail_dir['name']}} +
+
{{$travel_user_booking_fewo->countCustomerMailsBy($dir_id)}}
+
+ @endforeach +
+
+ + + +
+ +
+

+ +
  + Kunde +
+ +

+
+
+ + + +
+ +
+ +
+ + + + + + + + {{-- --}} + + + + + + + +
 {{__('E-Mail')}}{{__('Betreff')}}{{__('Datum')}}{{__('#')}}
+
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/resources/views/lead/_detail_notice.blade.php b/resources/views/lead/_detail_notice.blade.php new file mode 100644 index 0000000..dba8fcf --- /dev/null +++ b/resources/views/lead/_detail_notice.blade.php @@ -0,0 +1,58 @@ +
+ +
+ +
+ +
+ {!! Form::open(['url' => route('lead_detail', [$id]), 'class' => 'form-horizontal']) !!} + +
+ {{ Form::textarea('lead_notice', '', array('placeholder'=>__('Neue Notiz hinzufügen …'), 'class'=>'form-control autoExpand', 'id'=>'booking_notice', 'rows'=>'1', 'data-min-rows'=>'1', 'required')) }} +
+
+ +
+
+ {!! Form::close() !!} +
+ + @if($lead->lead_notices) + @foreach($lead->lead_notices as $lead_notice) +
+ @if($lead_notice->from_user_id === \Auth::user()->id) +
+
{{ $lead_notice->getName() }} | {{ $lead_notice->created_at->format("d.m.Y - H:i:s") }} + @else +
+
{{ $lead_notice->getName() }} | {{ $lead_notice->created_at->format("d.m.Y - H:i:s") }} + @endif + @if($lead_notice->edit_at != null) + | {{ $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')) + + @endif +
+ {!! nl2br($lead_notice->message) !!} +
+
+ @endforeach + @endif +
+
+
\ No newline at end of file diff --git a/resources/views/lead/_detail_status.blade.php b/resources/views/lead/_detail_status.blade.php new file mode 100644 index 0000000..db75c88 --- /dev/null +++ b/resources/views/lead/_detail_status.blade.php @@ -0,0 +1,95 @@ +
+ +
+
+ @if($lead->count()) + + + +
+ +
+ +
+ +
+ +
+ +
+
+
+
+ + {{ Form::select('status[id]', \App\Models\Lead::getStatusArray() , $lead->status_id, array('class'=>'custom-select')) }} +
+ +
+ + {{ Form::textarea('status[remarks]', '', array('placeholder'=>__('Bemerkung'), 'class'=>'form-control autoExpand', 'id'=>'status_remarks', 'rows'=>'1', 'data-min-rows'=>'1')) }} +
+ +
+ + {{ Form::text('status[date]', _format_date(now()), array('placeholder'=>__('dd.mm.YY'), 'class'=>'form-control datepicker-base', 'id'=>'status[date]')) }} +
+ +
+
+   + {{ __('zur Übersicht') }} +
+
+
+ + @if($lead->status_histories) +
+

+
+ + + + + + + + + + + + @foreach ($lead->status_histories as $status_history) + + + + + + + + @endforeach + + +
StatusSachbearbeiterDatumZieldatumBemerkungen
+ @if($status_history->status) + {!! $status_history->status->getStatusBadge() !!} + @endif + + @if($status_history->lead->sf_guard_user) + {{ $status_history->lead->sf_guard_user->fullname }} + @endif + {{ _format_date($status_history->date) }}{{ _format_date($status_history->target_date) }}{{ $status_history->remarks }}
+
+
+ @endif + + @endif +
+
+
\ No newline at end of file diff --git a/resources/views/lead/detail.blade.php b/resources/views/lead/detail.blade.php index 48c0197..ec2d67e 100755 --- a/resources/views/lead/detail.blade.php +++ b/resources/views/lead/detail.blade.php @@ -36,42 +36,207 @@ + +

Anfrage verwalten

+ {!! Form::open(['url' => route('lead_detail', [$id]), 'class' => 'form-horizontal', 'id'=>'lead-form-validation']) !!} - + + @include('lead._detail_customer') + + @include('lead._detail_lead') + + @include('lead._detail_status') + {!! Form::close() !!} - -
-
+ @if($id !== "new") + {{-- + @include('lead._detail_mails') + + --}} + @include('lead._detail_files') + @endif -
- - {{ Form::text('id', $lead->id, array('placeholder'=>__('Nr.'), 'class'=>'form-control', 'id'=>'lead_id', 'readonly')) }} -
+ @include('lead._detail_notice') - -
+ - -
-   - {{ __('zur Übersicht') }} - {{ __('zurück ins CRM v2') }} - -
- - {!! Form::close() !!} + diff --git a/resources/views/lead/edit_notice_modal.blade.php b/resources/views/lead/edit_notice_modal.blade.php new file mode 100644 index 0000000..a72b6c9 --- /dev/null +++ b/resources/views/lead/edit_notice_modal.blade.php @@ -0,0 +1,31 @@ + + + + \ No newline at end of file diff --git a/resources/views/lead/index.blade.php b/resources/views/lead/index.blade.php index f35006e..f4194e9 100755 --- a/resources/views/lead/index.blade.php +++ b/resources/views/lead/index.blade.php @@ -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, diff --git a/resources/views/lead/upload_modal.blade.php b/resources/views/lead/upload_modal.blade.php new file mode 100644 index 0000000..2fd2eac --- /dev/null +++ b/resources/views/lead/upload_modal.blade.php @@ -0,0 +1,105 @@ + + + + + + + diff --git a/resources/views/settings/emails/index.blade.php b/resources/views/settings/emails/index.blade.php index 2af97e8..337f014 100755 --- a/resources/views/settings/emails/index.blade.php +++ b/resources/views/settings/emails/index.blade.php @@ -556,6 +556,172 @@ >Neue Datei anlegen
+ + + +

Ordner für Anfragen/E-Mail Ablage

+
+ + + + + + + + + + + + + @php($next_customer_lead_mail_dir_id = 0) + @foreach($customer_lead_mail_dirs as $customer_lead_mail_dir) + + + + + + + + {{-- --}} + + @php($next_customer_lead_mail_dir_id = $customer_lead_mail_dir->pos+1) + @endforeach + +
 {{__('ID')}}{{__('Name')}}{{__('Icon')}}{{__('Model')}}{{__('E-Mails')}}
+ + {{ $customer_lead_mail_dir->pos }}{{ $customer_lead_mail_dir->name }}{{ $customer_lead_mail_dir->getArrayContent('icon') }}{{ $customer_lead_mail_dir->getArrayContent('model') }} + {!! \App\Services\Util::_implodeLines( $customer_lead_mail_dir->getArrayContent('emails'), "
") !!} +
+
+ +
+
+ + + + +
+

Allgemeine PDF Dateien für Anfragen/E-Mail-Anhänge

+
+ + + + + + + + + + + + + + @foreach($lead_email_files as $value) + + + + + + + + + + @endforeach + +
 {{__('POS')}}{{__('Name')}}{{__('Slug')}}{{__('Inhalt')}}{{__('Type')}}
+ + {{ $value->pos }}{{ $value->name }}{{ $value->slug }}@if($value->isFile()) {!! $value->getPreviewContent() !!} @else {{ $value->getPreviewContent() }} @endif{{ $value->getFieldName() }}
+
+ +
+
+ + +
diff --git a/resources/views/settings/service_provider/detail.blade.php b/resources/views/settings/service_provider/detail.blade.php index e17950a..c84f017 100755 --- a/resources/views/settings/service_provider/detail.blade.php +++ b/resources/views/settings/service_provider/detail.blade.php @@ -33,7 +33,7 @@
- + {{ Form::select('type', \App\Models\ServiceProvider::$types , $model->type, array('class'=>'custom-select', 'required'=>true)) }}
diff --git a/routes/web.php b/routes/web.php index 3270698..a93805a 100755 --- a/routes/web.php +++ b/routes/web.php @@ -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 diff --git a/storage/app/lead/files/2021/05/60955ca9afcee2.92045692_8.jpg b/storage/app/lead/files/2021/05/60955ca9afcee2.92045692_8.jpg new file mode 100644 index 0000000..5f46042 Binary files /dev/null and b/storage/app/lead/files/2021/05/60955ca9afcee2.92045692_8.jpg differ diff --git a/storage/app/lead/files/2021/05/60955ca9dce874.45575986_9jpg4cf9ccb1-68b8-4d45-bf27-16456.jpg b/storage/app/lead/files/2021/05/60955ca9dce874.45575986_9jpg4cf9ccb1-68b8-4d45-bf27-16456.jpg new file mode 100644 index 0000000..c56a8a2 Binary files /dev/null and b/storage/app/lead/files/2021/05/60955ca9dce874.45575986_9jpg4cf9ccb1-68b8-4d45-bf27-16456.jpg differ diff --git a/storage/app/lead/files/2021/05/60955caa1648f2.54222167_10jpg07e366b0-503d-4075-b741-e29f.jpg b/storage/app/lead/files/2021/05/60955caa1648f2.54222167_10jpg07e366b0-503d-4075-b741-e29f.jpg new file mode 100644 index 0000000..6f20775 Binary files /dev/null and b/storage/app/lead/files/2021/05/60955caa1648f2.54222167_10jpg07e366b0-503d-4075-b741-e29f.jpg differ diff --git a/storage/app/public/cms_files/2021/05/60955aeb7644d5.23980862_qboardbroschürede012020.pdf b/storage/app/public/cms_files/2021/05/60955aeb7644d5.23980862_qboardbroschürede012020.pdf new file mode 100644 index 0000000..58bc8e3 Binary files /dev/null and b/storage/app/public/cms_files/2021/05/60955aeb7644d5.23980862_qboardbroschürede012020.pdf differ