Mails etc. in Lead finish
This commit is contained in:
parent
66ca252bfa
commit
b362b93bca
45 changed files with 1460 additions and 418 deletions
|
|
@ -7,6 +7,7 @@ use Request;
|
|||
use App\Models\Lead;
|
||||
use App\Models\LeadFile;
|
||||
use App\Models\LeadNotice;
|
||||
use App\Models\StatusHistory;
|
||||
use App\Repositories\LeadRepository;
|
||||
use App\Repositories\CustomerRepository;
|
||||
use App\Repositories\LeadFileRepository;
|
||||
|
|
@ -88,6 +89,26 @@ class LeadController extends Controller
|
|||
return back();
|
||||
}
|
||||
|
||||
public function getAjaxRequests(){
|
||||
|
||||
$data = Request::all();
|
||||
if(Request::ajax()) {
|
||||
if(isset($data['action']) && $data['action'] === "get_popover_lead_notice"){
|
||||
$lead = Lead::findOrFail($data['lead_id']);
|
||||
$ret = "";
|
||||
|
||||
if($lead->lead_notices->count()){
|
||||
$lead_notice = $lead->lead_notices->first();
|
||||
return $lead_notice->getSmallerMessage(500);
|
||||
}
|
||||
if($ret === ""){
|
||||
return 'keine Notiz';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function loadModal(){
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
|
|
@ -100,12 +121,10 @@ class LeadController extends Controller
|
|||
return response()->json(['response' => $data, 'html'=>$ret]);
|
||||
}
|
||||
|
||||
public function delete($id, $del="lead"){
|
||||
public function delete($id, $del=false){
|
||||
|
||||
if($del === 'lead') {
|
||||
$lead = Lead::findOrFail($id);
|
||||
dump($lead);
|
||||
dd('TODO check delete');
|
||||
//Files
|
||||
$leadFiles = LeadFile::where('lead_id', $lead->id)->get();
|
||||
foreach ($leadFiles as $leadFile) {
|
||||
|
|
@ -114,12 +133,16 @@ class LeadController extends Controller
|
|||
$fileRepo->delete();
|
||||
$leadFile->delete();
|
||||
}
|
||||
//history
|
||||
$leadHistories = StatusHistory::where('lead_id', $lead->id)->get();
|
||||
foreach ($leadHistories as $leadHistory) {
|
||||
$leadHistory->delete();
|
||||
}
|
||||
//Mails Files CASCADE
|
||||
$lead->delete();
|
||||
\Session()->flash('alert-success', __('Anfrage gelöscht'));
|
||||
}
|
||||
|
||||
|
||||
if($del === 'lead_notice'){
|
||||
$leadNotice = LeadNotice::findOrFail($id);
|
||||
$lead = $leadNotice->lead;
|
||||
|
|
@ -160,7 +183,22 @@ class LeadController extends Controller
|
|||
})
|
||||
->addColumn('status', function (Lead $lead) {
|
||||
//umbuchen
|
||||
return $lead->getStatusBadge();
|
||||
return $lead->getStatusBadge();
|
||||
})
|
||||
->addColumn('lead_notice', function (Lead $lead) {
|
||||
return $lead->lead_notices->count() ? '<span data-order="1" class="badge badge-pill badge-success" data-lead_id="'.$lead->id.'" data-action="get_popover_lead_notice" data-placement="top" data-toggle="popover" title="letzte Notiz"><i class="fa fa-check"></i></span>' :
|
||||
'<span data-order="0" class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('last_lead_email', function (Lead $lead) {
|
||||
//umbuchen
|
||||
if($lead->lead_mails->count()){
|
||||
$lead_mail = $lead->lead_mails_sent_at->last();
|
||||
return '<a data-order="'.$lead_mail->getSentAtRaw().'" href="'.route('lead_detail', [$lead->id]).'#collapseLeadMails" data-order="'.$lead_mail->sent_at.'"><span class="badge '.($lead_mail->is_answer ? 'badge-default' : 'badge-secondary').'">'.$lead_mail->sent_at.'</span></a>';
|
||||
}
|
||||
return '<span data-order="">-</span>';
|
||||
})
|
||||
->addColumn('action_delete', function (Lead $lead) {
|
||||
return '<a href="' . route('lead_delete', [$lead->id, 'lead']) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('customer_id', 'customer_id $1')
|
||||
|
|
@ -176,7 +214,7 @@ class LeadController extends Controller
|
|||
$query->where('customer_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'customer_id', 'sf_guard_user_id', 'id', 'status'])
|
||||
->rawColumns(['action_edit', 'customer_id', 'sf_guard_user_id', 'id', 'status', 'last_lead_email', 'lead_notice', 'action_delete'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue