08 2024
This commit is contained in:
parent
c1c613a4b9
commit
881fc84207
384 changed files with 50679 additions and 990 deletions
|
|
@ -2,17 +2,19 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Models\Lead;
|
||||
use App\Models\LeadFile;
|
||||
use App\Models\LeadMail;
|
||||
use App\Models\LeadNotice;
|
||||
use App\Models\StatusHistory;
|
||||
use App\Models\LeadParticipant;
|
||||
use App\Repositories\LeadRepository;
|
||||
use App\Models\StatusHistory;
|
||||
use App\Repositories\CustomerRepository;
|
||||
use App\Repositories\LeadFileRepository;
|
||||
use App\Repositories\LeadRepository;
|
||||
use App\Services\Util;
|
||||
use Carbon;
|
||||
use Request;
|
||||
use Session;
|
||||
|
||||
class LeadController extends Controller
|
||||
{
|
||||
|
|
@ -38,6 +40,7 @@ class LeadController extends Controller
|
|||
|
||||
public function detail($id)
|
||||
{
|
||||
|
||||
if($id === "new") {
|
||||
$lead = new Lead();
|
||||
$id = 'new';
|
||||
|
|
@ -47,6 +50,7 @@ class LeadController extends Controller
|
|||
$lead->getPassolutionPDF(true);
|
||||
$id = $lead->id;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'lead' => $lead,
|
||||
'id' => $id,
|
||||
|
|
@ -59,24 +63,34 @@ class LeadController extends Controller
|
|||
public function store($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
if(!isset($data['action'])){
|
||||
abort(403, 'keine Action');
|
||||
}
|
||||
//save
|
||||
|
||||
if($data['action'] === 'createBooking'){
|
||||
$lead = $this->leadRepo->createBooking($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('lead_detail', [$id]).'#collapseLeadBooking');
|
||||
}
|
||||
if($data['action'] === 'saveCustomer'){
|
||||
|
||||
|
||||
if($data['action'] === 'saveCustomer' || $data['action'] === 'saveLead' || $data['action'] === 'saveStatus' || $data['action'] === 'update_lead_participant'){
|
||||
//@dd($data);
|
||||
$customer = $this->custRepo->updateCustomerFromLead($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
$lead = $this->leadRepo->updateLead($id, $data);
|
||||
$lead = $this->leadRepo->updateLeadParticipant($id, $data);
|
||||
|
||||
}
|
||||
if($data['action'] === 'saveCustomer'){
|
||||
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'] === 'update_lead_participant'){
|
||||
return redirect(route('lead_detail', [$lead->id])."#collapseBookingParticipant");
|
||||
}
|
||||
if($data['action'] === 'saveStatus'){
|
||||
$lead = $this->leadRepo->updateLeadStatus($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
|
|
@ -93,11 +107,7 @@ class LeadController extends Controller
|
|||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('lead_detail', [$lead->id])."#collapseLeadNotice");
|
||||
}
|
||||
if($data['action'] === 'update_lead_participant'){
|
||||
$lead = $this->leadRepo->updateLeadParticipant($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('lead_detail', [$lead->id])."#collapseBookingParticipant");
|
||||
}
|
||||
|
||||
|
||||
|
||||
return back();
|
||||
|
|
@ -170,6 +180,11 @@ class LeadController extends Controller
|
|||
|
||||
if($del === 'lead') {
|
||||
$lead = Lead::findOrFail($id);
|
||||
|
||||
if($lead->bookings->count()){
|
||||
\Session()->flash('alert-error', 'Kann nicht gelöscht werden, die Anfrage hat Buchungen');
|
||||
return redirect(route('lead_detail', [$lead->id])."#collapseLeadBooking");
|
||||
}
|
||||
//Files
|
||||
$leadFiles = LeadFile::where('lead_id', $lead->id)->get();
|
||||
foreach ($leadFiles as $leadFile) {
|
||||
|
|
@ -233,21 +248,7 @@ class LeadController extends Controller
|
|||
return Carbon::parse($lead->request_date)->format(\Util::formatDateDB());
|
||||
})
|
||||
->addColumn('travel_country', function (Lead $lead) {
|
||||
$out = "";
|
||||
if($lead->bookings->count()){
|
||||
$out = '<span class="badge badge-success">';
|
||||
foreach ($lead->bookings as $booking){
|
||||
if($booking->travel_country_id && $booking->travel_country) {
|
||||
$out .= $booking->travel_country->destco;
|
||||
}
|
||||
}
|
||||
$out .= '</span>';
|
||||
return $out;
|
||||
}
|
||||
if($lead->travel_country){
|
||||
return '<span class="badge badge-secondary">'.$lead->travel_country->destco.'</span>';
|
||||
}
|
||||
return "-";
|
||||
return $lead->getTravelCountryDestco();
|
||||
})
|
||||
|
||||
->addColumn('status', function (Lead $lead) {
|
||||
|
|
@ -285,6 +286,7 @@ class LeadController extends Controller
|
|||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('customer_id', 'customer_id $1')
|
||||
->orderColumn('request_date', 'request_date $1')
|
||||
->orderColumn('status', 'status_id $1')
|
||||
|
||||
->orderColumn('last_lead_email', function ($query, $order) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue