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>';
})

View file

@ -43,6 +43,9 @@ class Airline extends Model
'name_full',
'emails',
'contact_emails',
'flight_info',
'check_in',
'baggage',
];
protected $casts = ['contact_emails' => 'array'];

View file

@ -6,11 +6,11 @@
namespace App\Models;
use App\Services\Passolution;
use App\Services\Util;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use App\Services\Util;
use App\Services\Passolution;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
/**
* Class Booking
@ -212,13 +212,13 @@ class Booking extends Model
'travelagenda_id' => 'int',
'paying_out' => 'int',
'hold' => 'int',
'airline_id' => 'int',
//'airline_id' => 'int',
'refund' => 'int',
'xx_tkt' => 'int',
'is_rail_fly' => 'bool',
'comfort' => 'bool'
'comfort' => 'bool',
'airline_ids' => 'array',
'participant_pass' => 'bool'
];
protected $dates = [
@ -255,6 +255,7 @@ class Booking extends Model
'participant_firstname',
'participant_birthdate',
'participant_salutation_id',
'participant_pass',
'nationality_id',
'ev_number',
'merlin_knr',
@ -271,7 +272,8 @@ class Booking extends Model
'travelagenda_id',
'paying_out',
'paying_out_status',
'airline_id',
//'airline_id',
'airline_ids',
'refund',
'refund_date',
'lawyer_date',
@ -398,11 +400,12 @@ class Booking extends Model
{
return $this->belongsTo(TravelAgenda::class, 'travelagenda_id');
}
public function airline()
/*public function airline()
{
return $this->belongsTo(Airline::class, 'airline_id');
}
*/
public function arrangements()
{
@ -540,30 +543,103 @@ class Booking extends Model
{
return $this->hasOne(BookingStorno::class);
}
public function getAirlinesAsNames()
{
$ret = "";
if($this->airline_ids){
foreach($this->airline_ids as $airline_id){
if($Airline = Airline::find($airline_id)){
$ret .= $Airline->name." ";
}
}
}
return $ret;
}
public function getAirlinesIds()
{
if($this->airline_ids){
return implode('', $this->airline_ids);
}
return "";
}
public function hasBookingServicesUnchecked(){
$country_services = true;
$provider_services = true;
$company_services = true;
if(!$this->booking_country_services->count() || $this->booking_country_services_checked->count() ||
$has_country_services = false;
$has_provider_services = false;
$has_company_services = false;
if($this->travel_country){
foreach($this->travel_country->getContactLandsModels() as $TravelCountry){
if($TravelCountry->stern_travel_country){
if($TravelCountry->stern_travel_country->travel_country_services->count()){
$has_country_services = true;
}
}
}
}
if($has_country_services && !$this->booking_country_services->count() || $this->booking_country_services_checked->count() ||
($this->booking_country_services->count() !== TravelCountryService::where('crm_travel_country_id', '=', $this->travel_country_id)->count())){
$country_services = false;
$country_services = false;
}
if(!$this->booking_provider_services->count() || $this->booking_provider_services_checked->count()){
$provider_services = false;
foreach($this->service_provider_entries as $service_provider_entry){
if($service_provider_entry->service_provider && $service_provider_entry->service_provider->service_provider_services->count()){
$has_provider_services = true;
}
}
if(!$this->booking_company_services->count() || $this->booking_company_services_checked->count()){
$company_services = false;
if($has_provider_services && !$this->booking_provider_services->count() || $this->booking_provider_services_checked->count()){
if($this->service_provider_entries->count()){
$provider_services = false;
}
}
if($country_services && $provider_services && $provider_services){
foreach($this->booking_service_items as $booking_service_item){
if($booking_service_item->travel_company && $booking_service_item->travel_company->travel_company_services->count()){
$has_company_services = true;
}
}
if($has_company_services && !$this->booking_company_services->count() || $this->booking_company_services_checked->count()){
if($this->booking_service_items->count()){
$company_services = false;
}
}
if(!$has_country_services && !$has_provider_services && !$has_company_services){
return false;
}
if($country_services && $provider_services && $company_services){
return true;
}
return false;
}
public function hasBookingParticipantsPass(){
if($this->participant_firstname){
if(!$this->participant_pass){
return false;
}
}
if($this->participants->count()){
foreach($this->participants as $participant){
if(!$participant->participant_pass){
return false;
}
}
}
return true;
}
public function getPassolutionPDF($create = false, $resync = false){
$nats = [];

View file

@ -59,7 +59,11 @@ class LeadMail extends Model
'draft' => 'bool',
'important' => 'bool',
'send' => 'bool',
'fail' => 'bool'
'fail' => 'bool',
'recipient' => 'array',
'forward' => 'array',
'cc' => 'array',
'bcc' => 'array'
];
protected $dates = [

View file

@ -47,7 +47,8 @@ class Participant extends Model
protected $casts = [
'booking_id' => 'int',
'participant_salutation_id' => 'int',
'participant_child' => 'bool'
'participant_child' => 'bool',
'participant_pass' => 'bool'
];
protected $dates = [
@ -61,7 +62,8 @@ class Participant extends Model
'participant_birthdate',
'participant_salutation_id',
'participant_child',
'nationality_id'
'nationality_id',
'participant_pass'
];
public function booking()

View file

@ -74,7 +74,7 @@ class TravelCountry extends Model
'contact_text_4',
'contact_footer',
'contact_emails',
'visum_text',
];
protected $casts = ['contact_lands' => 'array', 'mail_dirs'=>'array', 'contact_emails' => 'array'];

View file

@ -95,6 +95,7 @@ class TravelCountry extends Model
'contact_text_3',
'contact_text_4',
'contact_footer',
'visum_text',
'entry_requirements',
'contact_emails',
'is_customer_country',

View file

@ -79,6 +79,7 @@ class BookingRepository extends BaseRepository {
'travel_country_id' => $data['travel_country_id'] ? $data['travel_country_id'] : null,
'travelagenda_id' => $data['travelagenda_id'] ? $data['travelagenda_id'] : null,
'travel_category_id' => $data['travel_category_id'] ? $data['travel_category_id'] : null,
'comfort' => isset($data['travel_comfort']) ? true : false,
'start_date' => $data['start_date'] ? _reformat_date($data['start_date']) : null,
'end_date' => $data['end_date'] ? _reformat_date($data['end_date']) : null,
'title' => $data['title'],
@ -88,7 +89,8 @@ class BookingRepository extends BaseRepository {
'paying_out_status' => $data['paying_out_status'],
'branch_id' => $data['branch_id'],
'travel_company_id' => $data['travel_company_id'],
'airline_id' => $data['airline_id'],
//'airline_id' => $data['airline_id'],
'airline_ids' => isset($data['airline_ids']) ? $data['airline_ids'] : null,
'refund' => $data['refund'],
'refund_date' => _reformat_date($data['refund_date']),
'lawyer_date' => _reformat_date($data['lawyer_date']),
@ -103,6 +105,13 @@ class BookingRepository extends BaseRepository {
];
$this->model->fill($fill);
$this->model->save();
if($this->model->booking_draft_items){
foreach($this->model->booking_draft_items as $booking_draft_item){
$booking_draft_item->comfort = isset($data['travel_comfort']) ? true : false;
$booking_draft_item->save();
}
}
return $this->model;
}
@ -199,6 +208,7 @@ class BookingRepository extends BaseRepository {
if($Participant->booking_id !== $this->model->id){
abort(500);
}
$fill['participant_pass'] = isset($fill['participant_pass']) ? true : false;
$fill['participant_child'] = isset($fill['participant_child']) ? true : false;
$fill['participant_birthdate'] = isset($fill['participant_birthdate']) ? _reformat_date($fill['participant_birthdate']) : null;
$Participant->fill($fill);
@ -211,6 +221,8 @@ class BookingRepository extends BaseRepository {
$this->model->participant_firstname = isset($data['participant_firstname']) ? $data['participant_firstname'] : null;
$this->model->nationality_id = isset($data['nationality_id']) ? $data['nationality_id'] : null;
$this->model->participant_birthdate = isset($data['participant_birthdate']) ? _reformat_date($data['participant_birthdate']) : null;
$this->model->participant_pass = isset($data['participant_pass']) ? true : false;
$this->model->save();
return $this->model;

View file

@ -257,6 +257,7 @@ class CustomerFewoMailRepository extends BaseRepository {
$value->subtitle = "";
$value->url = "";
$value->recipient = "";
$value->show_move_dirs = true;
$value->cc = "";
$value->bcc = "";
$value->lead_title_id = "";
@ -267,6 +268,9 @@ class CustomerFewoMailRepository extends BaseRepository {
if (isset($data['customer_mail_id']) && $customer_mail = CustomerFewoMail::find($data['customer_mail_id'])) {
$value->url = $data['url'];
$value->title = "E-Mail Ansicht";
if(isset($data['preview']) && $data['preview']){
$value->show_move_dirs = false;
}
return view("travel.user.booking.mail.modal-show-mail", compact('data', 'value', 'customer_mail'))->render();
}
}

View file

@ -250,8 +250,19 @@ class CustomerMailRepository extends BaseRepository {
$value->customers[$key] = $val;
}
}else{
if(isset($value->replay_email)){
if($value->customer_mail_dir < 10){ // && $value->lead_mail_subdir > 0
$customer_mail_dir = \App\Services\Booking::getCustomerMailDir($value->customer_mail_dir);
$contact_emails = \App\Services\Booking::getCustomerMailEmails($customer_mail_dir, $value->customer_mail_subdir);
if($contact_emails && count($contact_emails) > 0) {
$value->replay_email = array_shift($contact_emails);
}
}
}
}
return $value;
return $value;
}
public static function loadModal($data)
@ -261,6 +272,7 @@ class CustomerMailRepository extends BaseRepository {
$value->subtitle = "";
$value->url = "";
$value->recipient = "";
$value->show_move_dirs = true;
$value->cc = "";
$value->bcc = "";
$value->lead_title_id = "";
@ -272,6 +284,9 @@ class CustomerMailRepository extends BaseRepository {
if (isset($data['customer_mail_id']) && $customer_mail = CustomerMail::find($data['customer_mail_id'])) {
$value->url = $data['url'];
$value->title = "E-Mail Ansicht";
if(isset($data['preview']) && $data['preview']){
$value->show_move_dirs = false;
}
return view("customer.mail.modal-show-mail", compact('data', 'value', 'customer_mail'))->render();
}
}
@ -377,12 +392,12 @@ class CustomerMailRepository extends BaseRepository {
$value->subtitle = "Die E-Mail wird im System gespeichert.";
if($data['id'] === 'reply-save'){
$value->subtitle = "Die E-Mail wird im System als Antwort gespeichert.";
}
$value->url = $data['url'];
$value->show = 'reply';
$value->customer_mail_dir = isset($data['customer_mail_dir']) ? $data['customer_mail_dir'] : 0;
$value->customer_mail_subdir = isset($data['customer_mail_subdir']) ? $data['customer_mail_subdir'] : 0;
$value->replay_email = $value->booking->customer->email;
$value = self::prepareContactMails($value);

View file

@ -128,7 +128,7 @@ class LeadMailRepository extends BaseRepository {
}
public function store($lead, $data, $mail_from, $is_answer = false, $reply_id = NULL, $sent_at=false){
if(isset($data['save_lead_mail_id'])){
$lead_mail = LeadMail::find($data['save_lead_mail_id']);
$lead_mail->fill([
@ -246,6 +246,17 @@ class LeadMailRepository extends BaseRepository {
$value->customers[$key] = $val;
}
}else{
if(isset($value->replay_email)){
if($value->lead_mail_dir < 10){ // && $value->lead_mail_subdir > 0
$lead_mail_dir = \App\Services\Lead::getCustomerMailDir($value->lead_mail_dir);
$contact_emails = \App\Services\Lead::getCustomerMailEmails($lead_mail_dir, $value->lead_mail_subdir);
if($contact_emails && count($contact_emails) > 0) {
$value->replay_email = array_shift($contact_emails);
}
}
}
}
return $value;
}
@ -257,6 +268,7 @@ class LeadMailRepository extends BaseRepository {
$value->subtitle = "";
$value->url = "";
$value->recipient = "";
$value->show_move_dirs = true;
$value->cc = "";
$value->bcc = "";
$value->lead_title_id = "";
@ -268,6 +280,9 @@ class LeadMailRepository extends BaseRepository {
if (isset($data['lead_mail_id']) && $lead_mail = LeadMail::find($data['lead_mail_id'])) {
$value->url = $data['url'];
$value->title = "E-Mail Ansicht";
if(isset($data['preview']) && $data['preview']){
$value->show_move_dirs = false;
}
return view("lead.modal-show-mail", compact('data', 'value', 'lead_mail'))->render();
}
}
@ -376,8 +391,10 @@ class LeadMailRepository extends BaseRepository {
$value->show = 'reply';
$value->lead_mail_dir = isset($data['lead_mail_dir']) ? $data['lead_mail_dir'] : 0;
$value->lead_mail_subdir = isset($data['lead_mail_subdir']) ? $data['lead_mail_subdir'] : 0;
$value->replay_email = $value->lead->customer->email;
$value = self::prepareContactMails($value);
return view("lead.modal-new-mail", compact('data', 'value'))->render();
}

View file

@ -98,4 +98,30 @@ class Booking
}
return [];
}
public static function getBookingInstructionPDFName($fewo){
return "HINWEISE-FERIENWOHNUNG-".$fewo->pdf_name.".pdf";
}
public static function getBookingCMSContent($content, $identifier){
return CMSContent::where('identifier', '=', $identifier)->where('integer', $content->id)->get()->sortBy('pos');
}
public static function getBookingCMSContentForPDF($identifier_content, $identifier){
$pdf_content = [];
$contents = CMSContent::where('identifier', '=', $identifier_content)->get()->sortBy('pos');
foreach ($contents as $content){
if($content->decimal > 0){ //in_pdf
$pdf_content[] = $content;
}
if($fewo_contents = self::getBookingCMSContent($content, $identifier)){
foreach ($fewo_contents as $fewo_content){
if($fewo_content->decimal > 0){ //in_pdf
$pdf_content[] = $fewo_content;
}
}
}
}
return $pdf_content;
}
}

View file

@ -232,6 +232,19 @@ class HTMLHelper
return $ret;
}
public static function getCMSContentOptions($identifier, $setId = false, $empty=false){
$options = CMSContent::where('identifier', '=', $identifier)->get()->sortBy('pos');
$ret = "";
if($empty){
$ret = '<option value="0">Keine Vorlage</option>\n';
}
foreach ($options as $option){
$attr = ($option->id === $setId) ? 'selected="selected"' : '';
$ret .= '<option value="'.$option->id.'" '.$attr.'>'.$option->name.'</option>\n';
}
return $ret;
}
public static function getTravelClassOptions($programId = false, $setId = false){
$options = TravelClass::where('program_id', $programId)->get();
$ret = '<option value="">alle Kategorien</option>\n';

View file

@ -4,6 +4,7 @@ namespace App\Services;
use App\Models\Branch;
use App\Models\Status;
use App\Models\DraftType;
use App\Models\CMSContent;
use App\Models\Salutation;
use App\Models\SfGuardUser;
use App\Models\TravelAgenda;
@ -90,9 +91,12 @@ class Model
$DraftType = DraftType::where('active', true)->orderByDesc('pos')->get()->pluck('name', 'id');
return $emtpy ? $DraftType->prepend('-', 0) : $DraftType;
}
public static function getCMSContentGeneralNameById($id = false){
if($id > 0){
$content = CMSContent::findOrFail($id);
return $content->name;
}
return "";
}
}

View file

@ -21,7 +21,17 @@ class Placeholder
'end_date' => '#Abreisedatum#',
'participants' => '#Teilnehmer#',
'booking_date' => '#Buchungsdatum#',
'airline' => '#Airline#'
'airline' => '#Airline#',
'extra_services' => '#zugebuchte_Leistungen#',
'net_price_travel' => '#Nettopreise_Rundreise#',
'net_price_extra_services' => '#Nettopreise_zugebuchte_Leistungen#',
'booked_rooms' => '#Gebuchte_Zimmer#',
'filekey' => "#Filekey#",
'flight_info' => "#Airline_Fluginfo#",
'check_in' => "#Airline_Checkin#",
'baggage' => "#Airline_Gepaeck#",
'country_visum' => '#Reiseland_Visum#',
'country_contact' => '#Reiseland_Kontakt#',
];
public static $placeholder_lead = [
@ -112,10 +122,24 @@ class Placeholder
$country = $booking->travel_country_id ? $booking->travel_country->name : "-";
$program = $booking->travelagenda_id ? $booking->travel_agenda->name : "-";
$salutation = isset($booking->customer->salutation) ? $booking->customer->salutation->name : '-';
$filekey = $booking->filekey;
$flight_info = "";
$check_in = "";
$baggage = "";
$country_visum = "";
$country_contact = "";
$start_date = $booking->getStartDateFormat();
$end_date = $booking->getEndDateFormat();
$booking_date = $booking->getBookingDateFormat();
$airline = $booking->airline ? $booking->airline->name_full : '-';
$extra_services = self::getBookingPlaceholdersBy('extra_services', $booking);
$net_price_travel = self::getBookingPlaceholdersBy('net_price_travel', $booking);
$net_price_extra_services = self::getBookingPlaceholdersBy('net_price_extra_services', $booking);
$booked_rooms = self::getBookingPlaceholdersBy('booked_rooms', $booking);
$participants = "Teilnehmer:<br>";
//first
if($booking->participant_firstname){
@ -140,8 +164,10 @@ class Placeholder
$replace = [];
foreach (self::$placeholder_booking as $key => $value) {
$search[] = $value;
$replace[] = ${$key};
if(isset(${$key})){
$search[] = $value;
$replace[] = ${$key};
}
}
$content = str_replace($search, $replace, $content);
$content = preg_replace('/<placeholder.*?>(.*?)<\/placeholder>/', '$1', $content);
@ -209,4 +235,58 @@ class Placeholder
}
private static function getBookingPlaceholdersBy($key, $booking){
if($booking->new_drafts){
$booked_rooms = '';
$extra_services = '';
$net_price_travel = 0;
$net_price_extra_services = 0;
foreach($booking->booking_draft_items as $booking_draft_item){
//41 zugebuchte Leistungen
//32 Aufpreis Kategorie
if(in_array($booking_draft_item->draft_type_id, [32, 41])){
}
//24 Rundreise
if($booking_draft_item->draft_type_id == 24){
}
//30 Grundpreis Reise (Zimmer)
if($booking_draft_item->draft_type_id == 30){
$booked_rooms .= self::cleanText($booking_draft_item->service)." | ".$booking_draft_item->adult." Erw. ".($booking_draft_item->children ? " | ".$booking_draft_item->children." Kin." : '')."<br>";
$prices = $booking_draft_item->getItemPrice();
$net_price_travel += $prices['adult'];
$net_price_travel += $prices['children'];
}
}
switch ($key) {
case 'extra_services':
return "zugebuchte Leistungen:<br>".$extra_services;
break;
case 'net_price_travel':
return "Nettopreis Rundreise: ".Util::_number_format($net_price_travel)." Euro";
break;
case 'net_price_extra_services':
return "Nettopreise zugebuchte Leistungen:<br>".$net_price_extra_services;
break;
case 'booked_rooms':
return "Gebuchte Zimmer:<br>".$booked_rooms;
break;
}
}
}
private static function cleanText($text){
$text = str_replace('pro Person im', '', $text);
return $text;
}
}