Customer Mail, Mails, Views Lead Customer
This commit is contained in:
parent
f1e0900a7a
commit
f53f17f9c1
46 changed files with 2217 additions and 1489 deletions
|
|
@ -5,7 +5,9 @@ namespace App\Http\Controllers;
|
|||
use App\Models\Booking;
|
||||
use App\Models\Sym\TravelCountry;
|
||||
use App\Models\TravelAgenda;
|
||||
use App\Repositories\CustomerMailRepository;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Request;
|
||||
use DataTables;
|
||||
|
||||
|
|
@ -21,7 +23,6 @@ class RequestController extends Controller
|
|||
public function index($step = false)
|
||||
{
|
||||
|
||||
|
||||
$d = Booking::join('travel_country', 'travel_country_id', '=', 'travel_country.id')->get()->pluck('name', 'travel_country_id')->unique()->toArray();
|
||||
|
||||
$data = [
|
||||
|
|
@ -31,6 +32,17 @@ class RequestController extends Controller
|
|||
return view('request.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
|
||||
$d = Booking::join('travel_country', 'travel_country_id', '=', 'travel_country.id')->get()->pluck('name', 'travel_country_id')->unique()->toArray();
|
||||
|
||||
$data = [
|
||||
'travel_countries' => $d,
|
||||
];
|
||||
return view('request.index', $data);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
wirte old where has state to new has travel_documents
|
||||
|
|
@ -70,7 +82,6 @@ class RequestController extends Controller
|
|||
}
|
||||
|
||||
// $query->where('end_date', '<=', $now);
|
||||
|
||||
if(Request::get('travel_option_search')){
|
||||
$now = Carbon::now();
|
||||
|
||||
|
|
@ -146,8 +157,6 @@ class RequestController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(Request::get('sort_travel_country_id') != ""){
|
||||
$query->where('travel_country_id', '=', Request::get('sort_travel_country_id'));
|
||||
}
|
||||
|
|
@ -172,6 +181,7 @@ class RequestController extends Controller
|
|||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getAjaxRequests(){
|
||||
|
||||
$query = $this->getSearchRequests();
|
||||
|
|
@ -179,14 +189,58 @@ class RequestController extends Controller
|
|||
return TravelAgenda::whereIn('id', $ret)->get()->pluck('name', 'id');
|
||||
}
|
||||
|
||||
|
||||
public function loadModal(){
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
if(Request::ajax()){
|
||||
|
||||
$customers = [];
|
||||
$query = $this->getSearchRequests();
|
||||
$bookings = $query->orderBy('id', 'DESC')->limit(50)->get();
|
||||
foreach ($bookings as $booking){
|
||||
$tmp = "";
|
||||
$tmp .= $booking->customer ? $booking->customer->email." | " : "- | ";
|
||||
$tmp .= $booking->customer ? $booking->customer->firstname." ".$booking->customer->name." | " : "- | ";
|
||||
$tmp .= $booking->travel_country_id ? $booking->travel_country->name." | " : "- | ";
|
||||
$tmp .= $booking->travelagenda_id ? $booking->travel_agenda->name."" : "-";
|
||||
|
||||
$customers[$booking->id] = $tmp;
|
||||
}
|
||||
|
||||
// return TravelAgenda::whereIn('id', $ret)->get()->pluck('name', 'id');
|
||||
|
||||
if($data['action'] === "send-customer-mail"){
|
||||
$value = new Collection();
|
||||
$value->id = "add";
|
||||
$value->customers = $customers;
|
||||
$value->message = "Sehr #geehrte/r# #Anrede# #Vorname# #Nachname#,\n\nText ....";
|
||||
$data['title'] = "E-Mail-Nachricht an Auswahl";
|
||||
$url = route('requests_send_customer_mail');
|
||||
$ret = view("request.modal-mail", compact('data','value', 'url') )->render();
|
||||
}
|
||||
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret]);
|
||||
}
|
||||
|
||||
public function sendCustomerMail(CustomerMailRepository $customerMailRepository){
|
||||
$data = Request::all();
|
||||
|
||||
$customerMailRepository->sendAndStore($data);
|
||||
\Session()->flash('alert-success', "Mails gesendet!");
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function getRequests()
|
||||
{
|
||||
|
||||
$query = $this->getSearchRequests();
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (Booking $booking) {
|
||||
return ''; //'<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
->addColumn('action_lead_edit', function (Booking $booking) {
|
||||
return '<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('lead_id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->lead_id.'" href="'.make_old_url('leads/'.$booking->lead_id.'/edit').'" data-id="'.$booking->lead_id.'">'.$booking->lead_id.'</a>';
|
||||
|
|
@ -200,6 +254,9 @@ class RequestController extends Controller
|
|||
->addColumn('id', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->id.'" href="'.make_old_url('booking/'.$booking->id.'/edit').'" data-id="'.$booking->id.'">'.$booking->id.'</a>';
|
||||
})
|
||||
->addColumn('action_booking_edit', function (Booking $booking) {
|
||||
return '<a href="' . route('booking_detail', [$booking->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('travel_country_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->travel_country_id ? $booking->travel_country_id : 0).'">'.($booking->travel_country_id ? $booking->travel_country->name : "-").'</span>';
|
||||
})
|
||||
|
|
@ -245,11 +302,9 @@ class RequestController extends Controller
|
|||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('end_date', 'end_date $1')
|
||||
->orderColumn('travel_documents', 'travel_documents $1')
|
||||
->rawColumns(['action_edit', 'lead_id', 'participant_firstname', 'participant_name', 'travel_country_id', 'travelagenda_id', 'sf_guard_user_id', 'lead.status_id', 'id', 'travel_documents'])
|
||||
->rawColumns(['action_lead_edit', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'sf_guard_user_id', 'lead.status_id', 'id', 'travel_documents'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue