Mehrere Tickets 49, 50, 51, 52, 53

This commit is contained in:
Kevin Adametz 2021-10-08 17:07:28 +02:00
parent ae70577289
commit e3495be8b8
61 changed files with 1904 additions and 344 deletions

View file

@ -2,21 +2,22 @@
namespace App\Http\Controllers\Admin;
use App\Exports\ReportCollectionExport;
use App\Http\Controllers\Controller;
use App\Models\Booking;
use App\Models\ServiceProvider;
use App\Models\ServiceProviderEntry;
use App\Models\TravelAgenda;
use App\Services\Util;
use Carbon\Carbon;
use HTMLHelper;
use Illuminate\Validation\Rules\In;
use Maatwebsite\Excel\Facades\Excel;
use Request;
use Response;
use HTMLHelper;
use Carbon\Carbon;
use App\Models\Status;
use App\Services\Util;
use App\Models\Booking;
use App\Models\TravelAgenda;
use App\Models\ServiceProvider;
use Illuminate\Validation\Rules\In;
use App\Http\Controllers\Controller;
use App\Models\ServiceProviderEntry;
use Maatwebsite\Excel\Facades\Excel;
use App\Exports\ReportCollectionExport;
class ReportController extends Controller
{
public function __construct()
@ -27,7 +28,7 @@ class ReportController extends Controller
public function bookings()
{
$data = [
//'serviceProviders' => ServiceProvider::all(),
'filter_lead_status' => Status::get()->pluck('name', 'id')->toArray(),
];
return view('admin.report.bookings', $data);
}
@ -36,6 +37,7 @@ class ReportController extends Controller
{
$data = [
'serviceProviders' => ServiceProvider::all(),
'filter_lead_status' => Status::get()->pluck('name', 'id')->toArray(),
];
return view('admin.report.service_providers', $data);
}
@ -45,6 +47,18 @@ class ReportController extends Controller
$query = Booking::with( 'customer', 'lead', 'booking_strono','service_provider_entries', 'service_provider_entries.service_provider')->select('booking.*');
if(Request::get('filter_db_lead_status_id') != ""){
$query->whereHas('lead', function ($q) {
$q->whereIn('status_id', Request::get('filter_db_lead_status_id'));
});
}
if(Request::get('filter_lead_status_id') != ""){
$query->whereHas('lead', function ($q) {
$q->whereIn('status_id', Request::get('filter_lead_status_id'));
});
}
if(Request::get('filter_travel_date_from') != ""){
$travel_date_from = Carbon::parse(Request::get('filter_travel_date_from'))->format("Y-m-d");
$query->where("start_date", '>=', $travel_date_from);
@ -149,6 +163,8 @@ class ReportController extends Controller
->orderColumn('end_date', 'end_date $1')
->orderColumn('booking_date', 'booking_date $1')
->orderColumn('customer.fullName', 'customer.firstname $1')
->orderColumn('customer.firstname', 'customer.firstname $1')
->orderColumn('customer.name', 'customer.name $1')
//->orderColumn('lead.status_id', 'lead.status_id $1')
//->orderColumn('is_cleared', 'is_cleared $1')
->rawColumns(['id', 'lead.status_id', 'service_provider.names'])
@ -296,9 +312,25 @@ class ReportController extends Controller
private function prozessProvidersSearch(){
$query = ServiceProviderEntry::with('booking', 'service_provider', 'booking.customer')->select('service_provider_entry.*')
$query = ServiceProviderEntry::with('booking', 'service_provider', 'booking.customer', 'booking.lead')->select('service_provider_entry.*')
->join('booking', 'service_provider_entry.booking_id', '=', 'booking.id' );
if(Request::get('filter_db_lead_status_id') != ""){
$query->whereHas('booking', function ($qe) {
$qe->whereHas('lead', function ($q) {
$q->whereIn('status_id', Request::get('filter_db_lead_status_id'));
});
});
}
if(Request::get('filter_lead_status_id') != ""){
$query->whereHas('booking', function ($qe) {
$qe->whereHas('lead', function ($q) {
$q->whereIn('status_id', Request::get('filter_lead_status_id'));
});
});
}
if(Request::get('filter_is_cleared') != ""){
$query->where('is_cleared', '=', Request::get('filter_is_cleared'));
}
@ -389,6 +421,21 @@ class ReportController extends Controller
->addColumn('is_cleared', function (ServiceProviderEntry $serviceProviderEntry) {
return $serviceProviderEntry->is_cleared ? ' <span data-order="1" class="badge badge-pill badge-success"><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('booking.lead.status_id', function (ServiceProviderEntry $serviceProviderEntry) {
if($serviceProviderEntry->booking->lead && $serviceProviderEntry->booking->lead->status_id){
$color = $serviceProviderEntry->booking->lead->status->color;
$icon = "";
if($serviceProviderEntry->booking->lead->status_id == 14 && $serviceProviderEntry->booking->lead->is_rebook){
$color = '#94ae59';
$icon = '<i class="fa fa-check-circle"></i> ';
}
if($serviceProviderEntry->booking->lead->status_id == 14 && !$serviceProviderEntry->booking->lead->is_rebook){
$icon = '<i class="fa fa-times-circle"></i> ';
}
return '<span data-order="'.$serviceProviderEntry->booking->lead->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$serviceProviderEntry->booking->lead->status->name.'</span></span>';
}
return '<span data-order="0">-</span>';
})
->filterColumn('booking.customer.fullName', function ($query, $keyword) {
if ($keyword != "") {
$query->whereHas('booking', function ($q) use ($keyword) {
@ -402,8 +449,11 @@ class ReportController extends Controller
->orderColumn('booking.id', 'booking.id $1')
->orderColumn('booking.start_date', 'booking.start_date $1')
->orderColumn('booking.end_date', 'booking.end_date $1')
->orderColumn('booking.customer.firstname', 'booking.customer.firstname $1')
->orderColumn('booking.customer.name', 'booking.customer.name $1')
->orderColumn('is_cleared', 'is_cleared $1')
->rawColumns(['is_cleared', 'booking.id'])
->rawColumns(['is_cleared', 'booking.id', 'booking.lead.status_id'])
->make(true);
}
@ -415,12 +465,12 @@ class ReportController extends Controller
$orderByNum = [
0 => "id",
1 => "booking.id", //booking
3 => "booking.merlin_order_number",//booking
4 => "booking.price",//booking
5 => "booking.price_total",//booking
8 => "booking.start_date",//booking
9 => "booking.end_date",//booking
10 => "is_cleared",
4 => "booking.merlin_order_number",//booking
5 => "booking.price",//booking
6 => "booking.price_total",//booking
9 => "booking.start_date",//booking
10 => "booking.end_date",//booking
11 => "is_cleared",
];
if(isset($order[0])){
@ -431,6 +481,7 @@ class ReportController extends Controller
$filename = "file-".date('Y-m-d-H-i-s');
$exports = $query->get();
$ctemps = [];
$columns = [];
if(Request::get('export') === "export"){
@ -460,14 +511,14 @@ class ReportController extends Controller
$total_amount_final = 0;
$total_proceeds = 0;
foreach($exports as $export) {
$new = in_array($export->booking->lead_id, $isset) ? false : true;
$new = in_array($export->booking->id, $isset) ? false : true;
if($new){
$total_price += $export->booking->getPriceRaw();
$total_price_total += $export->booking->getPriceTotalRaw();
$total_proceeds += $export->booking->proceeds(true);
}
$total_amount_final += $export->getAmountFinalEurRaw();
$columns[] = array(
$ctemps[$export->booking->id][] = array(
'Zähler' => $new ? $export->getCounter() : "",
'MyJack Nr.' => $new ? $export->booking->merlin_order_number : "",
'CRM Nr' => $new ? $export->booking->lead_id : "",
@ -475,8 +526,8 @@ class ReportController extends Controller
'Reisedatum' => $new ? $export->booking->getStartDateFormat() : "",
'Organisation' => $new ? $export->booking->price : "",
'Gesamtreisepreis' => $new ? $export->booking->price_total : "",
'Reiseland' => $new ? $export->booking->travel_country->name : "",
'Reiseprogramm' => $new ? $export->booking->travel_agenda->name : "",
'Reiseland' => $new && $export->booking->travel_country ? $export->booking->travel_country->name : "",
'Reiseprogramm' => $new && $export->booking->travel_agenda ? $export->booking->travel_agenda->name : "",
'Reiseteilnehmer' => $new ? $export->booking->pax : "",
'Leistungsträger' => $export->service_provider->name,
'Rechnungsnummer' => $export->invoice_number,
@ -485,7 +536,10 @@ class ReportController extends Controller
'Erlös' => $new ? $export->booking->proceeds() : "",
'Konto' => $export->booking->getKontoNumber()
);
$isset[] = $export->booking->lead_id;
$isset[] = $export->booking->id;
}
foreach($ctemps as $bid => $value){
$columns = array_merge($columns, $value);
}
$columns[] = array(
'Zähler' => "Total",
@ -527,26 +581,29 @@ class ReportController extends Controller
$total_amount_final = 0;
$payments_total = 0;
foreach($exports as $export) {
$new = in_array($export->booking->lead_id, $isset) ? false : true;
$new = in_array($export->booking->id, $isset) ? false : true;
if($new) {
$payments_total += $export->booking->getServiceProviderPaymentsTotal(true);
}
$total_amount_final += $export->getAmountFinalEurRaw();
$columns[] = array(
$ctemps[$export->booking->id][] = array(
'Zähler' => $new ? $export->getCounter() : "",
'MyJack Nr.' => $new ? $export->booking->merlin_order_number : "",
'CRM Nr' => $new ? $export->booking->lead_id : "",
'Kunde' => $new ? $export->booking->customer->name : "",
'Reisedatum' => $new ? $export->booking->getStartDateFormat() : "",
'Reiseland' => $new ? $export->booking->travel_country->name : "",
'Reiseprogramm' => $new ? $export->booking->travel_agenda->name : "",
'Reiseland' => $new && $export->booking->travel_country ? $export->booking->travel_country->name : "",
'Reiseprogramm' => $new && $export->booking->travel_agenda ? $export->booking->travel_agenda->name : "",
'Reiseteilnehmer' => $new ? $export->booking->pax : "",
'Leistungsträger' => $export->service_provider->name,
'Rechnungsnummer' => $export->invoice_number,
'Zahlung' => $export->getAmountFinalEur(),
'ZahlungVorgang' => $export->booking->getServiceProviderPaymentsTotal(),
);
$isset[] = $export->booking->lead_id;
$isset[] = $export->booking->id;
}
foreach($ctemps as $bid => $value){
$columns = array_merge($columns, $value);
}
$columns[] = array(
'Zähler' => "Total",

View file

@ -0,0 +1,288 @@
<?php
namespace App\Http\Controllers\CMS;
use App\Http\Controllers\Controller;
use App\Models\CMSContent;
use App\Models\FewoLodging;
use App\Services\BookingFewo;
use App\Services\CreatePDF;
use App\Services\Util;
use Request;
class CMSBookingController extends Controller
{
protected $identifier_general_name;
protected $identifier_content_name;
protected $identifier_content;
protected $identifier_general;
public function __construct()
{
$this->identifier_general_name = config('booking.identifier_general_name');
$this->identifier_content_name = config('booking.identifier_content_name');
$this->identifier_general = config('booking.identifier_general');
$this->identifier_content = config('booking.identifier_content');
}
/*
* ALL
*/
public function all()
{
$data = [
'values' => CMSContent::where('identifier', '=', $this->identifier_general_name)->get()->sortBy('pos'),
];
return view('cms.booking.all.index', $data);
}
public function detailAll($id)
{
$general_name = CMSContent::findOrFail($id);
$identifier_general = $this->identifier_general.$general_name->id;
$data = [
'contents' => CMSContent::where('identifier', '=', $identifier_general)->get()->sortBy('pos'),
'general_name' => $general_name,
'identifier_general' => $identifier_general,
];
return view('cms.booking.all.detail', $data);
}
public function storeAll($id = null)
{
$data = Request::all();
if($data['action'] === 'newOrSaveName'){
if($data['id'] === 'new'){
$create = [
'name' => $data['name'],
'field' => 'text',
'decimal' => 1,
'identifier' => $this->identifier_general_name,
'pos' => CMSContent::where('identifier', '=', $this->identifier_general_name)->count() + 1,
];
$content = CMSContent::create($create);
//store in cms old Datebase
\App\Models\Sym\CmsContent::create($create);
return redirect(route('cms_booking_all_detail', [$content->id]));
}else{
$content = CMSContent::findOrFail($data['id']);
$content->name = $data['name'];
$content->slug = null;
$content->save();
return redirect(route('cms_booking_all'));
}
}
if($data['action'] === 'addItem'){
$general_name = CMSContent::findOrFail($id);
$identifier_general = $this->identifier_general.$general_name->id;
$create = [
'name' => 'Abschnitt',
'field' => 'full_text',
'decimal' => 1,
'identifier' => $identifier_general,
'pos' => CMSContent::where('identifier', '=', $identifier_general)->count() + 1,
];
CMSContent::create($create);
//store in cms old Datebase
\App\Models\Sym\CmsContent::create($create);
\Session()->flash('alert-save', '1');
return redirect(route('cms_booking_all_detail', [$id]));
}
if($data['action'] === 'saveAll'){
$i = 1;
if(isset($data['contents'] )) {
foreach ($data['contents'] as $content_id => $item) {
$content = CMSContent::findOrFail($content_id);
$content->setObjectBy('page-break', (isset($item['page-break']) ? true : false));
$content->name = $item['name'];
$content->slug = null;
$content->decimal = isset($item['in_pdf']) ? 1 : 0;
$content->full_text = $item['full_text'];
$content->pos = $i++;
$content->save();
}
}
\Session()->flash('alert-save', '1');
return redirect(route('cms_booking_all_detail', [$id]));
}
\Session()->flash('alert-save', '1');
return redirect(route('cms_booking_all'));
}
public function deleteAll($id, $do){
if($do === 'name'){
$general_name = CMSContent::findOrFail($id);
$identifier_general = $this->identifier_general.$general_name->id;
$contents = CMSContent::where('identifier', '=', $identifier_general)->get();
foreach($contents as $con){
$con->delete();
}
$contents = \App\Models\Sym\CmsContent::where('identifier', '=', $identifier_general)->get();
foreach($contents as $con){
$con->delete();
}
\Session()->flash('alert-success', __('Vorlage gelöscht'));
}
if($do === 'item'){
\Session()->flash('alert-success', __('Abschnitt gelöscht'));
}
$content = CMSContent::findOrFail($id);
$content->delete();
$m = \App\Models\Sym\CmsContent::find($id);
$m->delete();
return back();
}
/*
* CONTENT
*/
public function content()
{
$data = [
'values' => CMSContent::where('identifier', '=', $this->identifier_content_name)->get()->sortBy('pos'),
'identifier_general_name' => $this->identifier_general_name,
];
return view('cms.booking.content.index', $data);
}
public function detailContent($id)
{
$content_name = CMSContent::findOrFail($id);
$identifier_content = $this->identifier_content.$content_name->id;
$gerneral_id = $content_name->getObjectBy('general_id');
$identifier_general = $this->identifier_general.$gerneral_id;
$data = [
'contents' => CMSContent::where('identifier', '=', $identifier_general)->get()->sortBy('pos'),
'content_name' => $content_name,
'identifier_content' => $identifier_content,
'identifier_general' => $identifier_general,
];
return view('cms.booking.content.detail', $data);
}
public function storeContent($id = null)
{
$data = Request::all();
if($data['action'] === 'newOrSaveName'){
if($data['id'] === 'new'){
$create = [
'name' => $data['name'],
'field' => 'text',
'decimal' => 1,
'identifier' => $this->identifier_content_name,
'pos' => CMSContent::where('identifier', '=', $this->identifier_content_name)->count() + 1,
];
$content = CMSContent::create($create);
$content->setObjectBy('general_id', (isset($data['general_id']) ? $data['general_id'] : 0));
$content->save();
//store in cms old Datebase
\App\Models\Sym\CmsContent::create($create);
return redirect(route('cms_booking_content_detail', [$content->id]));
}else{
$content = CMSContent::findOrFail($data['id']);
$content->setObjectBy('general_id', (isset($data['general_id']) ? $data['general_id'] : 0));
$content->name = $data['name'];
$content->slug = null;
$content->save();
return redirect(route('cms_booking_content'));
}
}
$content_name = CMSContent::findOrFail($id);
$identifier_content = $this->identifier_content.$content_name->id;
$gerneral_id = $content_name->getObjectBy('general_id');
$identifier_general = $this->identifier_general.$gerneral_id;
if($data['action'] === 'addItem' && isset($data['content_pos_id'])) {
$create = [
'name' => 'Abschnitt',
'field' => 'full_text',
'decimal' => 1,
'integer' => $data['content_pos_id'],
'identifier' => $identifier_content,
'pos' => 0,
];
CMSContent::create($create);
//store in cms old Datebase
\App\Models\Sym\CmsContent::create($create);
\Session()->flash('alert-save', '1');
return redirect(route('cms_booking_content_detail', [$id]));
}
if($data['action'] === 'saveAll'){
$i = 1;
$last_content_id = null;
if(isset($data['contents'] )) {
foreach ($data['contents'] as $content_id => $item) {
$content = CMSContent::findOrFail($content_id);
if ($item['identifier'] === $identifier_general) {
$last_content_id = $content->id;
}
if ($item['identifier'] === $identifier_content) {
$content->setObjectBy('page-break', (isset($item['page-break']) ? true : false));
$content->name = $item['name'];
$content->slug = null;
$content->decimal = isset($item['in_pdf']) ? 1 : 0;
$content->full_text = $item['full_text'];
$content->integer = $last_content_id != null ? $last_content_id : $content->integer; //is the main obj
$content->pos = $i++;
$content->save();
}
}
}
\Session()->flash('alert-save', '1');
return redirect(route('cms_booking_content_detail', [$id]));
}
/* if($data['action'] === 'previewPDF'){
$pdf_content = BookingFewo::getFeWoCMSContentForPDF($this->identifier_content, $identifier_fewo);
$pdf_file = new CreatePDF('pdf.fewo_instructions');
return $pdf_file->create([
'contents' => $pdf_content,
'fewo' => $fewo
]
);
}
*/
\Session()->flash('alert-save', '1');
return redirect(route('cms_booking_content'));
}
public function deleteContent($id, $do){
if($do === 'name'){
$content_name = CMSContent::findOrFail($id);
$identifier_content = $this->identifier_content.$content_name->id;
$contents = CMSContent::where('identifier', '=', $identifier_content)->get();
foreach($contents as $con){
$con->delete();
}
$contents = \App\Models\Sym\CmsContent::where('identifier', '=', $identifier_content)->get();
foreach($contents as $con){
$con->delete();
}
\Session()->flash('alert-success', __('Vorlage gelöscht'));
}
if($do === 'item'){
\Session()->flash('alert-success', __('Abschnitt gelöscht'));
}
$content = CMSContent::findOrFail($id);
$content->delete();
$m = \App\Models\Sym\CmsContent::find($id);
$m->delete();
return back();
}
}

View file

@ -6,9 +6,10 @@ use Carbon;
use Request;
use App\Models\Lead;
use App\Models\LeadFile;
use App\Models\LeadMail;
use App\Models\LeadNotice;
use App\Models\LeadParticipant;
use App\Models\StatusHistory;
use App\Models\LeadParticipant;
use App\Repositories\LeadRepository;
use App\Repositories\CustomerRepository;
use App\Repositories\LeadFileRepository;
@ -132,6 +133,19 @@ class LeadController extends Controller
}
return $ret;
}
if(isset($data['action']) && $data['action'] === "get_popover_lead_last_email"){
$lead = Lead::findOrFail($data['lead_id']);
$ret = "";
if($lead->lead_mails->count()){
$lead_mail = $lead->lead_mails_sent_at->last();
return "<h6>".$lead_mail->subject."</h6>".$lead_mail->message;
}
if($ret === ""){
return 'keine E-Mail';
}
return $ret;
}
}
}
@ -214,7 +228,6 @@ class LeadController extends Controller
return Carbon::parse($lead->request_date)->format(\Util::formatDateDB());
})
->addColumn('status', function (Lead $lead) {
//umbuchen
return $lead->getStatusBadge();
})
->addColumn('lead_notice', function (Lead $lead) {
@ -222,10 +235,21 @@ class LeadController extends Controller
'<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 '<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->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 '.($lead_mail->is_answer ? 'badge-default' : 'badge-secondary').'">'.$lead_mail->sent_at.'</span>
</a>';
}
return '<span data-order="">-</span>';
})
@ -236,6 +260,19 @@ class LeadController extends Controller
->orderColumn('customer_id', 'customer_id $1')
->orderColumn('status', 'status_id $1')
->orderColumn('last_lead_email', function ($query, $order) {
$query->whereHas('lead_mails',
function ($q) use ($order) {
// $q->select('sent_at')->where('sent_at', DB::raw("(select max('sent_at') customer_mails)")); //)
})->orderBy(
LeadMail::select('sent_at')
->whereColumn('lead_id', 'lead.id')
->orderBy('sent_at', 'DESC')
->limit(1)
, $order);
})
->filterColumn('id', function($query, $keyword) {
if($keyword != ""){
$query->where('id', 'LIKE', '%'.$keyword.'%');

View file

@ -298,7 +298,7 @@ class LeadMailController extends Controller
$ret = '<a href="javascript:void(0)" class="btn btn-xs btn-secondary" data-toggle="modal"
data-target="#modals-load-content" data-id="reply-send" data-model="LeadMail" data-action="new-lead-mail"
data-url="'.route('lead_mail_send_mail').'" data-redirect="back" data-lead_mail_id="'.$lead_mail->id.'"
data-lead_id="'.$lead_mail->lead_id.'" data-route="'.route('lead_mail_modal_load').'" data-lead_mail_dir="'.$lead_mail->dir.'" data-customer_subdir="'.$lead_mail->subdir.'">
data-lead_id="'.$lead_mail->lead_id.'" data-route="'.route('lead_mail_modal_load').'" data-lead_mail_dir="'.$lead_mail->dir.'" data-lead_mail_subdir="'.$lead_mail->subdir.'">
<span title="Antwort auf E-Mail senden" data-placement="left" rel="tooltip"><i class="ion ion-ios-redo"></i> <i class="ion ion-md-mail-open"></i></span>
</a>
&nbsp;

View file

@ -48,6 +48,20 @@ class MailController extends Controller
->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('action_see', function (LeadMail $lead_mail) {
return '<a data-order="'.$lead_mail->getSentAtRaw().'" class="btn icon-btn btn-sm btn-secondary" 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').'">
<i class="fa fa-eye"></i>
</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>';
})
@ -74,7 +88,7 @@ class MailController extends Controller
$query->where('lead_id', 'LIKE', '%'.$keyword.'%');
}
})
->rawColumns(['action_edit', 'send', 'date', 'lead_id'])
->rawColumns(['action_edit', 'send', 'date', 'lead_id', 'action_see'])
->make(true);
}
@ -86,6 +100,20 @@ class MailController extends Controller
->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('action_see', function (CustomerMail $customer_mail) {
return '<a data-order="'.$customer_mail->getSentAtRaw().'" class="btn icon-btn btn-sm btn-secondary" 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').'">
<i class="fa fa-eye"></i>
</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."" : "-";
@ -117,7 +145,7 @@ class MailController extends Controller
$query->where('booking_id', 'LIKE', '%'.$keyword.'%');
}
})
->rawColumns(['action_edit', 'send', 'date', 'booking_id'])
->rawColumns(['action_edit', 'send', 'date', 'booking_id', 'action_see'])
->make(true);
}
@ -129,6 +157,21 @@ class MailController extends Controller
->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('action_see', function (CustomerFewoMail $customer_fewo_mail) {
return '<a data-order="'.$customer_fewo_mail->getSentAtRaw().'" class="btn icon-btn btn-sm btn-secondary" href="#" data-toggle="modal"
data-target="#modals-load-content"
data-id="show-mail"
data-url="mail"
data-preview="true"
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').'">
<i class="fa fa-eye"></i>
</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;
@ -159,7 +202,7 @@ class MailController extends Controller
$query->where('booking_id', 'LIKE', '%'.$keyword.'%');
}
})
->rawColumns(['action_edit', 'send', 'date', 'booking_id'])
->rawColumns(['action_edit', 'send', 'date', 'booking_id', 'action_see'])
->make(true);
}

View file

@ -2,18 +2,19 @@
namespace App\Http\Controllers;
use App\Models\Airline;
use App\Models\Booking;
use App\Models\CustomerMail;
use App\Models\Status;
use App\Models\Sym\TravelCountry;
use App\Models\TravelAgenda;
use App\Models\TravelCompany;
use App\Models\TravelCountryService;
use App\Repositories\CustomerMailRepository;
use Carbon\Carbon;
use Request;
use DataTables;
use Carbon\Carbon;
use App\Models\Status;
use App\Models\Airline;
use App\Models\Booking;
use App\Models\SfGuardUser;
use App\Models\CustomerMail;
use App\Models\TravelAgenda;
use App\Models\TravelCompany;
use App\Models\Sym\TravelCountry;
use App\Models\TravelCountryService;
use App\Repositories\CustomerMailRepository;
class RequestController extends Controller
{
@ -34,6 +35,10 @@ class RequestController extends Controller
$filter_paying_out_status = Booking::$paying_out_status_types;
$filter_refund = Booking::$refund_types;
$filter_xx_tkt = Booking::$xx_tkt_types;
$filter_sf_guard_user = SfGuardUser::where('is_active', 1)->where('user_id', '!=', NULL)
->whereHas('user', function ($q) {
$q->where('active', 1);
})->get()->pluck('username', 'id')->toArray();
$filter_airlines = Airline::get()->pluck('name', 'id')->toArray();
@ -51,6 +56,7 @@ class RequestController extends Controller
'filter_refund' => $filter_refund,
'filter_xx_tkt' => $filter_xx_tkt,
'filter_airlines' => $filter_airlines,
'filter_sf_guard_user' => $filter_sf_guard_user
];
return view('request.index', $data);
}
@ -121,7 +127,7 @@ class RequestController extends Controller
$query->where('xx_tkt', '=', Request::get('travel_option_xx_tkt'));
}
if(Request::get('travel_option_airline_id') != ""){
$query->where('airline_id', '=', Request::get('travel_option_airline_id'));
$query->where('airline_ids', 'LIKE', '%'.Request::get('travel_option_airline_id').'%');
}
@ -249,7 +255,6 @@ class RequestController extends Controller
}
}
}
if($booking->service_provider_entries->count()){
foreach($booking->service_provider_entries as $service_provider_entry){
if($service_provider_entry->service_provider->service_provider_services->count()){
@ -285,25 +290,48 @@ class RequestController extends Controller
}
}
}
if($ret === ""){
return 'keine Leistungen definiert';
}
return $ret;
return $ret === "" ? 'keine Leistungen definiert' : $ret;
}
if(isset($data['action']) && $data['action'] === "get_popover_booking_notice"){
$booking = Booking::findOrFail($data['booking_id']);
$ret = "";
if($booking->booking_notices->count()){
$booking_notice = $booking->booking_notices->first();
return $booking_notice->getSmallerMessage(500);
}
if($ret === ""){
return 'keine Notiz';
}
return $ret;
return $ret === "" ? 'keine E-Notiz' : $ret;
}
if(isset($data['action']) && $data['action'] === "get_popover_booking_last_email"){
$booking = Booking::findOrFail($data['booking_id']);
$ret = "";
if($booking->customer_mails->count()){
$customer_mail = $booking->customer_mails_sent_at->last();
return "<h6>".$customer_mail->subject."</h6>".$customer_mail->message;
}
return $ret === "" ? 'keine E-Mail' : $ret;
}
if(isset($data['action']) && $data['action'] === "get_popover_booking_participants_pass"){
$booking = Booking::findOrFail($data['booking_id']);
$ret = "";
if($booking->participant_firstname){
$ret .= $booking->participant_pass ?
'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$booking->participant_firstname." ".$booking->participant_lastname.'</span>' :
'<span class="badge badge-pill badge-danger""><i class="fa fa-times"></i> '.$booking->participant_firstname." ".$booking->participant_lastname.'</span>';
$ret .= "<br>";
}
if($booking->participants->count()){
foreach($booking->participants as $participant){
$ret .= $participant->participant_pass ?
'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$participant->participant_firstname." ".$participant->participant_lastname.'</span>' :
'<span class="badge badge-pill badge-danger""><i class="fa fa-times"></i> '.$participant->participant_firstname." ".$participant->participant_lastname.'</span>';
$ret .= "<br>";
}
}
return $ret === "" ? 'keine Teilnehmer' : $ret;
}
$query = $this->getSearchRequests();
$ret = $query->get()->pluck('travelagenda_id', 'id')->unique()->toArray();
return TravelAgenda::whereIn('id', $ret)->get()->pluck('name', 'id');
@ -314,18 +342,27 @@ class RequestController extends Controller
$data = Request::all();
$ret = "";
if(Request::ajax()){
$data['customers'] = [];
$query = $this->getSearchRequests();
$bookings = $query->orderBy('id', 'DESC')->limit(50)->get();
foreach ($bookings as $booking){
$tmp = [];
$tmp['email'] = $booking->customer ? $booking->customer->email : "";
$tmp['name'] = $booking->customer ? $booking->customer->firstname." ".$booking->customer->name." | " : "- | ";
$tmp['name'] .= $booking->travel_country_id ? $booking->travel_country->name." | " : "- | ";
$tmp['name'] .= $booking->travelagenda_id ? $booking->travel_agenda->name."" : "-";
$data['customers'][$booking->id] = $tmp;
if($data['action'] === 'new-customer-mail'){
$data['customers'] = [];
$query = $this->getSearchRequests();
$bookings = $query->orderBy('id', 'DESC')->limit(50)->get();
foreach ($bookings as $booking){
$tmp = [];
$tmp['email'] = $booking->customer ? $booking->customer->email : "";
$tmp['name'] = $booking->customer ? $booking->customer->firstname." ".$booking->customer->name." | " : "- | ";
$tmp['name'] .= $booking->travel_country_id ? $booking->travel_country->name." | " : "- | ";
$tmp['name'] .= $booking->travelagenda_id ? $booking->travel_agenda->name."" : "-";
$data['customers'][$booking->id] = $tmp;
}
$ret = CustomerMailRepository::loadModal($data);
}
if($data['action'] === 'show-customer-mail'){
$booking = Booking::findOrFail($data['booking_id']);
$ret = "";
if($booking->customer_mails->count()){
$ret = CustomerMailRepository::loadModal($data);
}
}
$ret = CustomerMailRepository::loadModal($data);
}
return response()->json(['response' => $data, 'html'=>$ret]);
}
@ -336,23 +373,17 @@ class RequestController extends Controller
$query = $this->getSearchRequests();
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>';
})
->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>';
})
/*->addColumn('participant_firstname', function (Booking $booking) {
return '<a data-order="'.$booking->participant_firstname.'" href="'.make_old_url('customer/'.$booking->customer_id.'/edit').'" data-id="'.$booking->customer_id.'">'.$booking->participant_firstname.'</a>';
})
->addColumn('participant_name', function (Booking $booking) {
return '<a data-order="'.$booking->participant_name.'" href="'.make_old_url('customer/'.$booking->customer_id.'/edit').'" data-id="'.$booking->customer_id.'">'.$booking->participant_name.'</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('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('action_lead_edit', function (Booking $booking) {
return '<a href="' . route('lead_detail', [$booking->lead_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>';
})
->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>';
@ -373,35 +404,49 @@ class RequestController extends Controller
return $booking->getEndDateFormat();
})
->addColumn('travel_documents', function (Booking $booking) {
return $booking->travel_documents ? '<span data-order="1" class="badge badge-pill badge-success" title="Reiseunterlagen" data-placement="top" rel="tooltip"><i class="fa fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger" title="Reiseunterlagen" data-placement="top" rel="tooltip"><i class="fa fa-times"></i></span>';
return $booking->travel_documents ? '<span data-order="1" class="badge badge-pill badge-success" title="Reiseunterlagen vollständig" data-placement="top" rel="tooltip"><i class="fa fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger" title="Reiseunterlagen nicht vollständig" data-placement="top" rel="tooltip"><i class="fa fa-times"></i></span>';
})
->addColumn('booking_services', function (Booking $booking) {
return $booking->hasBookingServicesUnchecked() ? '<span data-order="1" class="badge badge-pill badge-success" data-booking_id="'.$booking->id.'" data-action="get_popover_booking_services" data-placement="top" data-toggle="popover" title="ServiceLeistungen"><i class="fa fa-check"></i></span>' :
'<span data-order="0" class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
'<span data-order="0" class="badge badge-pill badge-danger" data-booking_id="'.$booking->id.'" data-action="get_popover_booking_services" data-placement="top" data-toggle="popover" title="ServiceLeistungen"><i class="fa fa-times"></i></span>';
})
->addColumn('booking_notice', function (Booking $booking) {
return $booking->booking_notices->count() ? '<span data-order="1" class="badge badge-pill badge-success" data-booking_id="'.$booking->id.'" data-action="get_popover_booking_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>';
'<span data-order="0" class="badge badge-pill badge-danger" title="keine Notiz" data-placement="top" rel="tooltip"><i class="fa fa-times"></i></span>';
})
->addColumn('sf_guard_user_id', function (Booking $booking) {
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) {
//umbuchen
if($booking->lead){
return $booking->lead->getStatusBadge($booking);
}
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 data-order="'.$customer_mail->getSentAtRaw().'" 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 '<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="'.$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 '.($customer_mail->is_answer ? 'badge-default' : 'badge-secondary').'">'.$customer_mail->sent_at.'</span>
</a>';
}
return '<span data-order="">-</span>';
})
->addColumn('booking_participants_pass', function (Booking $booking) {
return $booking->hasBookingParticipantsPass() ? '<span data-order="1" class="badge badge-pill badge-success" data-booking_id="'.$booking->id.'" data-action="get_popover_booking_participants_pass" data-placement="top" data-toggle="popover" title="Teilnehmer Pass"><i class="fa fa-check"></i></span>' :
'<span data-order="0" class="badge badge-pill badge-danger" data-booking_id="'.$booking->id.'" data-action="get_popover_booking_participants_pass" data-placement="top" data-toggle="popover" title="Teilnehmer Pass"><i class="fa fa-times"></i></span>';
})
->addColumn('paying_out', function (Booking $booking) {
$icon = "";
$badge = $booking->getPayingOutColor();
@ -417,8 +462,8 @@ class RequestController extends Controller
->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('airline_id', function (Booking $booking) {
return $booking->airline ? '<span data-order="'.$booking->airline_id.'">'.$booking->airline->name.'</span>' : '-';
->addColumn('airline_ids', function (Booking $booking) {
return $booking->airline_ids ? '<span data-order="'.$booking->getAirlinesIDs().'">'. $booking->getAirlinesAsNames().'</span>' : '-';
})
->addColumn('refund', function (Booking $booking) {
return '<span data-order="'.$booking->refund_date.'"><span class="badge badge-'.$booking->getRefundColor().'">'.$booking->getRefundTypeList().'</span></span>';
@ -452,8 +497,6 @@ class RequestController extends Controller
})
*/
->orderColumn('lead_id', 'lead_id $1')
->orderColumn('participant_firstname', 'participant_firstname $1')
->orderColumn('participant_name', 'participant_name $1')
->orderColumn('id', 'id $1')
->orderColumn('travel_country_id', 'travel_country_id $1')
->orderColumn('travelagenda_id', 'travelagenda_id $1')
@ -469,7 +512,7 @@ class RequestController extends Controller
->orderColumn('xx_tkt', 'xx_tkt_date $1')
->orderColumn('comfort', 'comfort $1')
//->orderColumn('travel_documents', 'travel_documents $1')
->rawColumns(['action_lead_edit', 'comfort', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'travel_company_id', 'sf_guard_user_id', 'lead.status_id', 'last_customer_email', 'id', 'travel_documents', 'booking_services', 'booking_notice', 'paying_out', 'paying_out_status', 'airline_id', 'refund', 'hold', 'xx_tkt'])
->rawColumns(['action_lead_edit', 'comfort', 'lead_id', 'booking_participants_pass', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'travel_company_id', 'sf_guard_user_id', 'airline_ids', 'lead.status_id', 'last_customer_email', 'id', 'travel_documents', 'booking_services', 'booking_notice', 'paying_out', 'paying_out_status', 'airline_id', 'refund', 'hold', 'xx_tkt'])
->make(true);
}
}

View file

@ -25,34 +25,44 @@ class AirlineController extends Controller
return view('settings.airline.index', $data);
}
public function detail($id, $step = false)
{
if($id === "new") {
$model = new Airline();
$id = 'new';
}else{
$model = Airline::findOrFail($id);
$id = $model->id;
}
public function update(){
$data = [
'model' => $model,
'id' => $id,
'step' => $step,
];
return view('settings.airline.detail', $data);
}
public function update($id){
$data = Request::all();
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
if($data['id'] === "new"){
if($id === "new"){
$model = Airline::create($data);
}else{
$model = Airline::find($data['id']);
$model->name = $data['name'];
$model->name_full = $data['name_full'];
$model->contact_emails = $data['contact_emails'];
$model = Airline::find($id);
$model->fill($data);
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_settings_airline'));
return redirect(route('admin_settings_airline_detail', [$model->id]));
}
public function delete($id){
//TODO check ist linked
/*if(Booking::where('travelagenda_id', $id)->count()){
\Session()->flash('alert-error', 'Eintrag wird verwendet');
return redirect()->back();
}*/
$model = Airline::findOrFail($id);

View file

@ -336,7 +336,18 @@ class TravelUserBookingFewoController extends Controller
//umbuchen
if($travel_user_booking_fewo->customer_fewo_mails->count()){
$fewo_mail = $travel_user_booking_fewo->customer_fewo_mail_last;
return '<a data-order="'.$fewo_mail->getSentAtRaw().'" href="'.route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]).'#collapseLeadMails" data-order="'.$fewo_mail->sent_at.'"><span class="badge '.($fewo_mail->is_answer ? 'badge-default' : 'badge-secondary').'">'.$fewo_mail->sent_at.'</span></a>';
return '<a data-order="'.$fewo_mail->getSentAtRaw().'" href="#" data-toggle="modal"
data-target="#modals-load-content"
data-id="show-mail"
data-url="mail"
data-preview="true"
data-travel_user_booking_fewo_id="'.$fewo_mail->travel_user_booking_fewo_id.'"
data-customer_mail_id="'.$fewo_mail->id.'"
data-action="show-customer-mail"
data-redirect="back"
data-route="'.route('customer_fewo_modal_load').'">
<span class="badge '.($fewo_mail->is_answer ? 'badge-default' : 'badge-secondary').'">'.$fewo_mail->sent_at.'</span>
</a>';
}
return '<span data-order="">-</span>';
})