Mails, Strono, filter
This commit is contained in:
parent
f53f17f9c1
commit
62e84637b6
99 changed files with 2409 additions and 474 deletions
|
|
@ -3,11 +3,11 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Status;
|
||||
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;
|
||||
|
||||
|
|
@ -23,22 +23,36 @@ 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();
|
||||
$travel_countries = Booking::join('travel_country', 'travel_country_id', '=', 'travel_country.id')->get()->pluck('name', 'travel_country_id')->unique()->toArray();
|
||||
|
||||
$filter_lead_status = Status::get()->pluck('name', 'id')->toArray();
|
||||
|
||||
$filter_paying_out = Booking::$paying_out_types;
|
||||
$filter_paying_out_status = Booking::$paying_out_status_types;
|
||||
$filter_refund = Booking::$refund_types;
|
||||
$filter_xx_tkt = Booking::$xx_tkt_types;
|
||||
|
||||
unset($filter_paying_out[0]);
|
||||
unset($filter_refund[0]);
|
||||
unset($filter_xx_tkt[0]);
|
||||
|
||||
$data = [
|
||||
'step' => $step,
|
||||
'travel_countries' => $d,
|
||||
'travel_countries' => $travel_countries,
|
||||
'filter_lead_status' => $filter_lead_status,
|
||||
'filter_paying_out' => $filter_paying_out,
|
||||
'filter_paying_out_status' => $filter_paying_out_status,
|
||||
'filter_refund' => $filter_refund,
|
||||
'filter_xx_tkt' => $filter_xx_tkt,
|
||||
];
|
||||
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();
|
||||
|
||||
$travel_countries = Booking::join('travel_country', 'travel_country_id', '=', 'travel_country.id')->get()->pluck('name', 'travel_country_id')->unique()->toArray();
|
||||
$data = [
|
||||
'travel_countries' => $d,
|
||||
'travel_countries' => $travel_countries,
|
||||
];
|
||||
return view('request.index', $data);
|
||||
}
|
||||
|
|
@ -59,7 +73,7 @@ class RequestController extends Controller
|
|||
*/
|
||||
private function getSearchRequests(){
|
||||
|
||||
$query = Booking::where('lead_id', '!=', NULL);
|
||||
$query = Booking::with('lead')->where('lead_id', '!=', NULL);
|
||||
|
||||
if(Request::get('full_firstname_search') != ""){
|
||||
$query->where('participant_firstname', 'LIKE', '%'.Request::get('full_firstname_search').'%');
|
||||
|
|
@ -69,18 +83,34 @@ class RequestController extends Controller
|
|||
$query->where('participant_name', 'LIKE', '%'.Request::get('full_lastname_search').'%');
|
||||
}
|
||||
|
||||
|
||||
if(Request::get('travel_option_country_id') != ""){
|
||||
$country_ids = TravelCountry::where('contact_lands', 'LIKE', '%"'.Request::get('travel_option_country_id').'"%')->get()->pluck('id');
|
||||
$country_ids[] = Request::get('travel_option_country_id');
|
||||
$query->whereIn('travel_country_id', $country_ids);
|
||||
|
||||
}
|
||||
if(Request::get('travel_option_agenda_id') != ""){
|
||||
$query->where('travelagenda_id', '=', Request::get('travel_option_agenda_id'));
|
||||
|
||||
}
|
||||
|
||||
if(Request::get('travel_option_lead_status_id') != ""){
|
||||
$query->whereHas('lead', function ($q) {
|
||||
$q->where('status_id', '=', Request::get('travel_option_lead_status_id'));
|
||||
});
|
||||
}
|
||||
if(Request::get('travel_option_paying_out') != ""){
|
||||
$query->where('paying_out', '=', Request::get('travel_option_paying_out'));
|
||||
}
|
||||
if(Request::get('travel_option_paying_out_status') != ""){
|
||||
$query->where('paying_out_status', '=', Request::get('travel_option_paying_out_status'));
|
||||
}
|
||||
if(Request::get('travel_option_refund') != ""){
|
||||
$query->where('refund', '=', Request::get('travel_option_refund'));
|
||||
}
|
||||
if(Request::get('travel_option_xx_tkt') != ""){
|
||||
$query->where('xx_tkt', '=', Request::get('travel_option_xx_tkt'));
|
||||
}
|
||||
|
||||
|
||||
// $query->where('end_date', '<=', $now);
|
||||
if(Request::get('travel_option_search')){
|
||||
$now = Carbon::now();
|
||||
|
|
@ -172,7 +202,6 @@ class RequestController extends Controller
|
|||
$query->where('travel_documents', '=', Request::get('sort_travel_documents'));
|
||||
}
|
||||
|
||||
|
||||
if(Request::get('full_lead_id_search') != ""){
|
||||
$query->where('lead_id', 'LIKE', '%'.Request::get('full_lead_id_search'). '%');
|
||||
}
|
||||
|
|
@ -194,8 +223,7 @@ class RequestController extends Controller
|
|||
$data = Request::all();
|
||||
$ret = "";
|
||||
if(Request::ajax()){
|
||||
|
||||
$customers = [];
|
||||
$data['customers'] = [];
|
||||
$query = $this->getSearchRequests();
|
||||
$bookings = $query->orderBy('id', 'DESC')->limit(50)->get();
|
||||
foreach ($bookings as $booking){
|
||||
|
|
@ -204,41 +232,19 @@ class RequestController extends Controller
|
|||
$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;
|
||||
$data['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();
|
||||
}
|
||||
|
||||
$ret = CustomerMailRepository::loadModal($data);
|
||||
}
|
||||
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)
|
||||
return DataTables::eloquent($query)
|
||||
->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>';
|
||||
})
|
||||
|
|
@ -276,7 +282,56 @@ class RequestController extends Controller
|
|||
return '<span data-order="'.($booking->sf_guard_user_id ? $booking->sf_guard_user_id : 0).'">'.($booking->sf_guard_user_id? $booking->sf_guard_user->first_name." ".$booking->sf_guard_user->last_name : "-").'</span>';
|
||||
})
|
||||
->addColumn('lead.status_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->lead->status_id ? $booking->lead->status_id : 0).'">'.($booking->lead->status_id ? $booking->lead->status->name : "-").'</span>';
|
||||
//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> ';
|
||||
}
|
||||
return '<span data-order="'.$booking->lead->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$booking->lead->status->name.'</span></span>';
|
||||
|
||||
}
|
||||
return '<span data-order="0">-</span>';
|
||||
})
|
||||
->addColumn('last_customer_email', function (Booking $booking) {
|
||||
//umbuchen
|
||||
if($booking->customer_mails->count()){
|
||||
|
||||
$customer_mail = $booking->customer_mails_sent_at->last();
|
||||
|
||||
return '<a href="'.route('booking_detail', [$booking->id]).'#collapseBookingMails" data-order="'.$customer_mail->sent_at.'"><span class="badge '.($customer_mail->is_answer ? 'badge-default' : 'badge-secondary').'">'.$customer_mail->sent_at.'</span></a>';
|
||||
|
||||
}
|
||||
return '<span data-order="0">-</span>';
|
||||
})
|
||||
|
||||
->addColumn('paying_out', function (Booking $booking) {
|
||||
$icon = "";
|
||||
$badge = $booking->getPayingOutColor();
|
||||
if($booking->paying_out_status == 1){ //offen
|
||||
$icon = '<i class="fa fa-times-circle"></i> ';
|
||||
}
|
||||
if($booking->paying_out_status == 2){ //erledigt
|
||||
$badge = 'success';
|
||||
$icon = '<i class="fa fa-check-circle"></i> ';
|
||||
}
|
||||
return '<span data-order="'.$booking->paying_out.'"><span class="badge badge-'.$booking->getPayingOutColor().'">'.$icon.$booking->getPayingOutType().'</span></span>';
|
||||
})
|
||||
->addColumn('paying_out_status', function (Booking $booking) {
|
||||
return '<span data-order="'.$booking->paying_out_status.'"><span class="badge badge-'.$booking->getPayingOutStatusColor().'">'.$booking->getPayingOutStatusType().'</span></span>';
|
||||
})
|
||||
|
||||
|
||||
->addColumn('refund', function (Booking $booking) {
|
||||
return '<span data-order="'.$booking->refund_date.'"><span class="badge badge-'.$booking->getRefundColor().'">'.$booking->getRefundTypeList().'</span></span>';
|
||||
})
|
||||
->addColumn('xx_tkt', function (Booking $booking) {
|
||||
return '<span data-order="'.$booking->xx_tkt_date.'"><span class="badge badge-'.$booking->getXxTktColor().'">'.$booking->getXxTktTypeList().'</span></span>';
|
||||
})
|
||||
/* ->filterColumn('travel_country_id', function($query, $keyword) {
|
||||
|
||||
|
|
@ -301,8 +356,12 @@ class RequestController extends Controller
|
|||
->orderColumn('sf_guard_user_id', 'sf_guard_user_id $1')
|
||||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('end_date', 'end_date $1')
|
||||
->orderColumn('paying_out', 'paying_out $1')
|
||||
->orderColumn('paying_out_status', 'paying_out_status $1')
|
||||
->orderColumn('refund', 'refund_date $1')
|
||||
->orderColumn('xx_tkt', 'xx_tkt_date $1')
|
||||
->orderColumn('travel_documents', 'travel_documents $1')
|
||||
->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'])
|
||||
->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', 'last_customer_email', 'id', 'travel_documents', 'paying_out', 'paying_out_status', 'refund', 'xx_tkt'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue