207 lines
9.7 KiB
PHP
207 lines
9.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
use Carbon;
|
|
use Request;
|
|
use Response;
|
|
use App\Models\LeadMail;
|
|
use App\Models\CustomerMail;
|
|
use App\Models\CustomerFewoMail;
|
|
|
|
class MailController extends Controller
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
$this->middleware(['admin', '2fa']);
|
|
}
|
|
|
|
public function leads()
|
|
{
|
|
$data = [
|
|
];
|
|
return view('mails.lead', $data);
|
|
}
|
|
|
|
public function bookings()
|
|
{
|
|
$data = [
|
|
];
|
|
return view('mails.booking', $data);
|
|
}
|
|
|
|
public function bookingFewos()
|
|
{
|
|
$data = [
|
|
];
|
|
return view('mails.booking_fewo', $data);
|
|
}
|
|
|
|
|
|
public function leadDatatable()
|
|
{
|
|
$query = LeadMail::with('lead')->with('customer')->select('lead_mails.*');
|
|
|
|
return \DataTables::eloquent($query)
|
|
->addColumn('action_edit', function (LeadMail $lead_mail) {
|
|
return '<a href="'.route('lead_detail', [$lead_mail->lead_id]).'#collapseLeadMails" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
|
})
|
|
->addColumn('lead_id', function (LeadMail $lead_mail) {
|
|
return '<a data-order="'.$lead_mail->lead_id.'" href="'.route('lead_detail', [$lead_mail->lead_id]).'#collapseLeadMails">'.$lead_mail->lead_id.'</a>';
|
|
})
|
|
->addColumn('send', function (LeadMail $lead_mail) {
|
|
return $lead_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>';
|
|
})
|
|
->addColumn('date', function (LeadMail $lead_mail) {
|
|
$badge = $lead_mail->is_answer ? 'badge-default' : 'badge-secondary';
|
|
$badge = !$lead_mail->send ? $badge : 'badge-success';
|
|
return '<a data-order="'.$lead_mail->getSentAtRaw().'" href="#" data-toggle="modal"
|
|
data-target="#modals-load-content"
|
|
data-id="show-mail"
|
|
data-url="mail"
|
|
data-preview="true"
|
|
data-lead_id="'.$lead_mail->lead->id.'"
|
|
data-lead_mail_id="'.$lead_mail->id.'"
|
|
data-action="show-lead-mail"
|
|
data-redirect="back"
|
|
data-route="'.route('lead_mail_modal_load').'">
|
|
<span class="badge '.$badge.'">'
|
|
.($lead_mail->send ? '<i class="fa fa-check-circle"></i>' : '<i class="fa fa-times-circle"></i>').' '
|
|
.$lead_mail->sent_at.'</span>
|
|
</a>';
|
|
})
|
|
->orderColumn('lead_id', 'lead_id $1')
|
|
->orderColumn('send', 'send $1')
|
|
->orderColumn('date', 'sent_at $1')
|
|
|
|
->filterColumn('id', function($query, $keyword) {
|
|
if($keyword != ""){
|
|
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
|
}
|
|
})
|
|
->filterColumn('lead_id', function($query, $keyword) {
|
|
if($keyword != ""){
|
|
$query->where('lead_id', 'LIKE', '%'.$keyword.'%');
|
|
}
|
|
})
|
|
->rawColumns(['action_edit', 'send', 'date', 'lead_id'])
|
|
->make(true);
|
|
}
|
|
|
|
public function bookingDatatable()
|
|
{
|
|
$query = CustomerMail::with('booking')->with('customer')->select('customer_mails.*');
|
|
|
|
return \DataTables::eloquent($query)
|
|
->addColumn('action_edit', function (CustomerMail $customer_mail) {
|
|
return '<a href="'.route('booking_detail', [$customer_mail->booking_id]).'#collapseBookingMails" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
|
})
|
|
->addColumn('booking', function (CustomerMail $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('booking_id', function (CustomerMail $customer_mail) {
|
|
return '<a data-order="'.$customer_mail->booking_id.'" href="'.route('booking_detail', [$customer_mail->booking_id]).'#collapseBookingMails">'.$customer_mail->booking_id.'</a>';
|
|
})
|
|
->addColumn('send', function (CustomerMail $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>';
|
|
})
|
|
->addColumn('date', function (CustomerMail $customer_mail) {
|
|
$badge = $customer_mail->is_answer ? 'badge-default' : 'badge-secondary';
|
|
$badge = !$customer_mail->send ? $badge : 'badge-success';
|
|
return '<a data-order="'.$customer_mail->getSentAtRaw().'" href="#" data-toggle="modal"
|
|
data-target="#modals-load-content"
|
|
data-id="show-mail"
|
|
data-url="mail"
|
|
data-preview="true"
|
|
data-booking_id="'.$customer_mail->booking->id.'"
|
|
data-customer_mail_id="'.$customer_mail->id.'"
|
|
data-action="show-customer-mail"
|
|
data-redirect="back"
|
|
data-route="'.route('requests_modal_load').'">
|
|
<span class="badge '.$badge.'">'
|
|
.($customer_mail->send ? '<i class="fa fa-check-circle"></i>' : '<i class="fa fa-times-circle"></i>').' '
|
|
.$customer_mail->sent_at.'</span>
|
|
</a>';
|
|
})
|
|
->orderColumn('booking_id', 'booking_id $1')
|
|
->orderColumn('send', 'send $1')
|
|
->orderColumn('date', 'sent_at $1')
|
|
|
|
->filterColumn('id', function($query, $keyword) {
|
|
if($keyword != ""){
|
|
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
|
}
|
|
})
|
|
->filterColumn('booking_id', function($query, $keyword) {
|
|
if($keyword != ""){
|
|
$query->where('booking_id', 'LIKE', '%'.$keyword.'%');
|
|
}
|
|
})
|
|
->rawColumns(['action_edit', 'send', 'date', 'booking_id', 'action_see'])
|
|
->make(true);
|
|
}
|
|
|
|
public function bookingFewoDatatable()
|
|
{
|
|
$query = CustomerFewoMail::with('booking')->with('customer')->select('customer_fewo_mails.*');
|
|
|
|
return \DataTables::eloquent($query)
|
|
->addColumn('action_edit', function (CustomerFewoMail $customer_fewo_mail) {
|
|
return '<a href="'.route('travel_user_booking_fewo_detail', [$customer_fewo_mail->travel_user_booking_fewo_id]).'#collapseBookingMails" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
|
})
|
|
->addColumn('booking', function (CustomerFewoMail $customer_fewo_mail) {
|
|
$out = ($customer_fewo_mail->booking && $customer_fewo_mail->booking->fewo_lodging) ? $customer_fewo_mail->booking->fewo_lodging->name : "-";
|
|
return $out;
|
|
})
|
|
->addColumn('booking_id', function (CustomerFewoMail $customer_fewo_mail) {
|
|
return '<a data-order="'.$customer_fewo_mail->travel_user_booking_fewo_id.'" href="'.route('travel_user_booking_fewo_detail', [$customer_fewo_mail->travel_user_booking_fewo_id]).'#collapseBookingMails">'.$customer_fewo_mail->travel_user_booking_fewo_id.'</a>';
|
|
})
|
|
->addColumn('send', function (CustomerFewoMail $customer_fewo_mail) {
|
|
return $customer_fewo_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>';
|
|
})
|
|
->addColumn('date', function (CustomerFewoMail $customer_fewo_mail) {
|
|
$badge = $customer_fewo_mail->is_answer ? 'badge-default' : 'badge-secondary';
|
|
$badge = !$customer_fewo_mail->send ? $badge : 'badge-success';
|
|
return '<a data-order="'.$customer_fewo_mail->getSentAtRaw().'" href="#" data-toggle="modal"
|
|
data-target="#modals-load-content"
|
|
data-id="show-mail"
|
|
data-url="mail"
|
|
data-preview="'.$customer_fewo_mail->send.'"
|
|
data-travel_user_booking_fewo_id="'.$customer_fewo_mail->travel_user_booking_fewo_id.'"
|
|
data-customer_mail_id="'.$customer_fewo_mail->id.'"
|
|
data-action="show-customer-mail"
|
|
data-redirect="back"
|
|
data-route="'.route('customer_fewo_modal_load').'">
|
|
<span class="badge '.$badge.'">'
|
|
.($customer_fewo_mail->send ? '<i class="fa fa-check-circle"></i>' : '<i class="fa fa-times-circle"></i>').' '
|
|
.$customer_fewo_mail->sent_at.'</span>
|
|
</a>';
|
|
|
|
})
|
|
->orderColumn('booking_id', 'booking_id $1')
|
|
->orderColumn('send', 'send $1')
|
|
->orderColumn('date', 'sent_at $1')
|
|
|
|
->filterColumn('id', function($query, $keyword) {
|
|
if($keyword != ""){
|
|
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
|
}
|
|
})
|
|
->filterColumn('booking_id', function($query, $keyword) {
|
|
if($keyword != ""){
|
|
$query->where('booking_id', 'LIKE', '%'.$keyword.'%');
|
|
}
|
|
})
|
|
->rawColumns(['action_edit', 'send', 'date', 'booking_id'])
|
|
->make(true);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|