Edit / PDF / Mail / ->Leads
This commit is contained in:
parent
5d55e5be3f
commit
66ca252bfa
43 changed files with 2915 additions and 76 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
387
app/Http/Controllers/LeadMailController.php
Normal file
387
app/Http/Controllers/LeadMailController.php
Normal 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>' : ' ';
|
||||
})
|
||||
->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() ? ' <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>
|
||||
|
||||
<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>
|
||||
';
|
||||
}
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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>';
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue