diff --git a/app/Http/Controllers/Admin/ReportController.php b/app/Http/Controllers/Admin/ReportController.php
index 6754f02..7b8d11a 100755
--- a/app/Http/Controllers/Admin/ReportController.php
+++ b/app/Http/Controllers/Admin/ReportController.php
@@ -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 ? ' ' : '';
})
+ ->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 = ' ';
+ }
+ if($serviceProviderEntry->booking->lead->status_id == 14 && !$serviceProviderEntry->booking->lead->is_rebook){
+ $icon = ' ';
+ }
+ return ''.$icon.$serviceProviderEntry->booking->lead->status->name.'';
+ }
+ return '-';
+ })
->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",
diff --git a/app/Http/Controllers/CMS/CMSBookingController.php b/app/Http/Controllers/CMS/CMSBookingController.php
new file mode 100644
index 0000000..c2aced9
--- /dev/null
+++ b/app/Http/Controllers/CMS/CMSBookingController.php
@@ -0,0 +1,288 @@
+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();
+ }
+}
diff --git a/app/Http/Controllers/LeadController.php b/app/Http/Controllers/LeadController.php
index 7dbe8d8..5c8c87f 100755
--- a/app/Http/Controllers/LeadController.php
+++ b/app/Http/Controllers/LeadController.php
@@ -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 "
".$lead_mail->subject."
".$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
'';
})
->addColumn('last_lead_email', function (Lead $lead) {
- //umbuchen
+
if($lead->lead_mails->count()){
$lead_mail = $lead->lead_mails_sent_at->last();
- return ''.$lead_mail->sent_at.'';
+ return '
+ '.$lead_mail->sent_at.'
+ ';
}
return '-';
})
@@ -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.'%');
diff --git a/app/Http/Controllers/LeadMailController.php b/app/Http/Controllers/LeadMailController.php
index e87efa4..13d4214 100644
--- a/app/Http/Controllers/LeadMailController.php
+++ b/app/Http/Controllers/LeadMailController.php
@@ -298,7 +298,7 @@ class LeadMailController extends Controller
$ret = '
+ 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.'">
diff --git a/app/Http/Controllers/MailController.php b/app/Http/Controllers/MailController.php
index d42c3e2..2c50382 100644
--- a/app/Http/Controllers/MailController.php
+++ b/app/Http/Controllers/MailController.php
@@ -48,6 +48,20 @@ class MailController extends Controller
->addColumn('action_edit', function (LeadMail $lead_mail) {
return '';
})
+ ->addColumn('action_see', function (LeadMail $lead_mail) {
+ return '
+
+ ';
+ })
->addColumn('lead_id', function (LeadMail $lead_mail) {
return ''.$lead_mail->lead_id.'';
})
@@ -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 '';
})
+ ->addColumn('action_see', function (CustomerMail $customer_mail) {
+ return '
+
+ ';
+ })
->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 '';
})
+ ->addColumn('action_see', function (CustomerFewoMail $customer_fewo_mail) {
+ return '
+
+ ';
+ })
+
->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);
}
diff --git a/app/Http/Controllers/RequestController.php b/app/Http/Controllers/RequestController.php
index 4506a67..665c0e2 100755
--- a/app/Http/Controllers/RequestController.php
+++ b/app/Http/Controllers/RequestController.php
@@ -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 "".$customer_mail->subject."
".$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 ?
+ ' '.$booking->participant_firstname." ".$booking->participant_lastname.'' :
+ ' '.$booking->participant_firstname." ".$booking->participant_lastname.'';
+ $ret .= "
";
+ }
+ if($booking->participants->count()){
+ foreach($booking->participants as $participant){
+ $ret .= $participant->participant_pass ?
+ ' '.$participant->participant_firstname." ".$participant->participant_lastname.'' :
+ ' '.$participant->participant_firstname." ".$participant->participant_lastname.'';
+ $ret .= "
";
+ }
+ }
+ 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 '';
- })
- ->addColumn('lead_id', function (Booking $booking) {
- return ''.$booking->lead_id.'';
- })
- /*->addColumn('participant_firstname', function (Booking $booking) {
- return ''.$booking->participant_firstname.'';
- })
- ->addColumn('participant_name', function (Booking $booking) {
- return ''.$booking->participant_name.'';
- })*/
+ ->addColumn('action_booking_edit', function (Booking $booking) {
+ return '';
+ })
->addColumn('id', function (Booking $booking) {
return ''.$booking->id.'';
})
- ->addColumn('action_booking_edit', function (Booking $booking) {
- return '';
+ ->addColumn('action_lead_edit', function (Booking $booking) {
+ return '';
+ })
+ ->addColumn('lead_id', function (Booking $booking) {
+ return ''.$booking->lead_id.'';
})
->addColumn('travel_country_id', function (Booking $booking) {
return ''.($booking->travel_country_id ? $booking->travel_country->name : "-").'';
@@ -373,35 +404,49 @@ class RequestController extends Controller
return $booking->getEndDateFormat();
})
->addColumn('travel_documents', function (Booking $booking) {
- return $booking->travel_documents ? '' : '';
+ return $booking->travel_documents ? '' : '';
})
->addColumn('booking_services', function (Booking $booking) {
return $booking->hasBookingServicesUnchecked() ? '' :
- '';
+ '';
})
->addColumn('booking_notice', function (Booking $booking) {
return $booking->booking_notices->count() ? '' :
- '';
+ '';
})
-
->addColumn('sf_guard_user_id', function (Booking $booking) {
return ''.($booking->sf_guard_user_id? $booking->sf_guard_user->first_name." ".$booking->sf_guard_user->last_name : "-").'';
})
->addColumn('lead.status_id', function (Booking $booking) {
- //umbuchen
if($booking->lead){
return $booking->lead->getStatusBadge($booking);
}
return '-';
})
->addColumn('last_customer_email', function (Booking $booking) {
- //umbuchen
if($booking->customer_mails->count()){
$customer_mail = $booking->customer_mails_sent_at->last();
- return ''.$customer_mail->sent_at.'';
+ return '
+ '.$customer_mail->sent_at.'
+ ';
}
return '-';
+
})
+ ->addColumn('booking_participants_pass', function (Booking $booking) {
+ return $booking->hasBookingParticipantsPass() ? '' :
+ '';
+ })
+
->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 ''.$booking->getPayingOutStatusType().'';
})
- ->addColumn('airline_id', function (Booking $booking) {
- return $booking->airline ? ''.$booking->airline->name.'' : '-';
+ ->addColumn('airline_ids', function (Booking $booking) {
+ return $booking->airline_ids ? ''. $booking->getAirlinesAsNames().'' : '-';
})
->addColumn('refund', function (Booking $booking) {
return ''.$booking->getRefundTypeList().'';
@@ -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);
}
}
diff --git a/app/Http/Controllers/Settings/AirlineController.php b/app/Http/Controllers/Settings/AirlineController.php
index de94c03..a53fe1f 100755
--- a/app/Http/Controllers/Settings/AirlineController.php
+++ b/app/Http/Controllers/Settings/AirlineController.php
@@ -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);
diff --git a/app/Http/Controllers/TravelUserBookingFewoController.php b/app/Http/Controllers/TravelUserBookingFewoController.php
index bd4c6f6..9ec7fa8 100755
--- a/app/Http/Controllers/TravelUserBookingFewoController.php
+++ b/app/Http/Controllers/TravelUserBookingFewoController.php
@@ -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 ''.$fewo_mail->sent_at.'';
+ return '
+ '.$fewo_mail->sent_at.'
+ ';
}
return '-';
})
diff --git a/app/Models/Airline.php b/app/Models/Airline.php
index af5a71a..48ce631 100644
--- a/app/Models/Airline.php
+++ b/app/Models/Airline.php
@@ -43,6 +43,9 @@ class Airline extends Model
'name_full',
'emails',
'contact_emails',
+ 'flight_info',
+ 'check_in',
+ 'baggage',
];
protected $casts = ['contact_emails' => 'array'];
diff --git a/app/Models/Booking.php b/app/Models/Booking.php
index 8c33dd0..0096239 100644
--- a/app/Models/Booking.php
+++ b/app/Models/Booking.php
@@ -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 = [];
diff --git a/app/Models/LeadMail.php b/app/Models/LeadMail.php
index 9a7a87d..55b59bb 100644
--- a/app/Models/LeadMail.php
+++ b/app/Models/LeadMail.php
@@ -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 = [
diff --git a/app/Models/Participant.php b/app/Models/Participant.php
index 4bf2419..a62c861 100644
--- a/app/Models/Participant.php
+++ b/app/Models/Participant.php
@@ -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()
diff --git a/app/Models/Sym/TravelCountry.php b/app/Models/Sym/TravelCountry.php
index ed2a8cf..2fab8a2 100644
--- a/app/Models/Sym/TravelCountry.php
+++ b/app/Models/Sym/TravelCountry.php
@@ -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'];
diff --git a/app/Models/TravelCountry.php b/app/Models/TravelCountry.php
index fcb1537..f32948f 100644
--- a/app/Models/TravelCountry.php
+++ b/app/Models/TravelCountry.php
@@ -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',
diff --git a/app/Repositories/BookingRepository.php b/app/Repositories/BookingRepository.php
index d9fcb6a..f3d5f7e 100644
--- a/app/Repositories/BookingRepository.php
+++ b/app/Repositories/BookingRepository.php
@@ -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;
diff --git a/app/Repositories/CustomerFewoMailRepository.php b/app/Repositories/CustomerFewoMailRepository.php
index b5e6bf4..59fc465 100644
--- a/app/Repositories/CustomerFewoMailRepository.php
+++ b/app/Repositories/CustomerFewoMailRepository.php
@@ -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();
}
}
diff --git a/app/Repositories/CustomerMailRepository.php b/app/Repositories/CustomerMailRepository.php
index eec5a83..31d9524 100644
--- a/app/Repositories/CustomerMailRepository.php
+++ b/app/Repositories/CustomerMailRepository.php
@@ -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);
diff --git a/app/Repositories/LeadMailRepository.php b/app/Repositories/LeadMailRepository.php
index 9bd4184..07859c4 100644
--- a/app/Repositories/LeadMailRepository.php
+++ b/app/Repositories/LeadMailRepository.php
@@ -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();
}
diff --git a/app/Services/Booking.php b/app/Services/Booking.php
index 43e0433..64ed181 100644
--- a/app/Services/Booking.php
+++ b/app/Services/Booking.php
@@ -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;
+ }
}
\ No newline at end of file
diff --git a/app/Services/HTMLHelper.php b/app/Services/HTMLHelper.php
index d619a36..807ab50 100644
--- a/app/Services/HTMLHelper.php
+++ b/app/Services/HTMLHelper.php
@@ -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 = '\n';
+ }
+ foreach ($options as $option){
+ $attr = ($option->id === $setId) ? 'selected="selected"' : '';
+ $ret .= '\n';
+ }
+ return $ret;
+ }
+
public static function getTravelClassOptions($programId = false, $setId = false){
$options = TravelClass::where('program_id', $programId)->get();
$ret = '\n';
diff --git a/app/Services/Model.php b/app/Services/Model.php
index 6c988ef..9fc8165 100644
--- a/app/Services/Model.php
+++ b/app/Services/Model.php
@@ -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 "";
+ }
}
\ No newline at end of file
diff --git a/app/Services/Placeholder.php b/app/Services/Placeholder.php
index 2a79c7e..76f5aef 100644
--- a/app/Services/Placeholder.php
+++ b/app/Services/Placeholder.php
@@ -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:
";
//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>/', '$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." : '')."
";
+ $prices = $booking_draft_item->getItemPrice();
+ $net_price_travel += $prices['adult'];
+ $net_price_travel += $prices['children'];
+
+ }
+ }
+ switch ($key) {
+ case 'extra_services':
+ return "zugebuchte Leistungen:
".$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:
".$net_price_extra_services;
+ break;
+ case 'booked_rooms':
+ return "Gebuchte Zimmer:
".$booked_rooms;
+ break;
+
+ }
+ }
+
+ }
+
+ private static function cleanText($text){
+ $text = str_replace('pro Person im', '', $text);
+ return $text;
+ }
+
}
\ No newline at end of file
diff --git a/config/booking.php b/config/booking.php
index ca5d8ed..810a3e2 100755
--- a/config/booking.php
+++ b/config/booking.php
@@ -1,5 +1,8 @@
'booking-pdf-g-',
+ 'identifier_general_name' => 'booking-pdf-general-name',
+ 'identifier_content' => 'booking-pdf-c-',
+ 'identifier_content_name' => 'booking-pdf-content-name'
];
diff --git a/config/permissions.php b/config/permissions.php
index 642a676..31f153d 100755
--- a/config/permissions.php
+++ b/config/permissions.php
@@ -31,6 +31,7 @@ return [
'cms-iq-assets' => ['name' => 'ADMIN CMS > Medien' , 'color' => 'secondary'],
'cms-tg' => ['name' => 'ADMIN CMS > Reiseführer' , 'color' => 'secondary'],
'cms-fewo' => ['name' => 'ADMIN CMS > FeWo' , 'color' => 'secondary'],
+ 'cms-book' => ['name' => 'ADMIN CMS > Buchungen' , 'color' => 'secondary'],
'cms-fb' => ['name' => 'ADMIN CMS > Feedback' , 'color' => 'secondary'],
'cms-aq' => ['name' => 'ADMIN CMS > Fragen & Antworten' , 'color' => 'secondary'],
'cms-sb' => ['name' => 'ADMIN CMS > Sidebar' , 'color' => 'secondary'],
diff --git a/database/migrations/2018_10_29_193339_create_travel_country_table.php b/database/migrations/2018_10_29_193339_create_travel_country_table.php
index da30ced..b17d351 100644
--- a/database/migrations/2018_10_29_193339_create_travel_country_table.php
+++ b/database/migrations/2018_10_29_193339_create_travel_country_table.php
@@ -38,6 +38,7 @@ class CreateTravelCountryTable extends Migration
$table->text('contact_text_3')->nullable();
$table->text('contact_text_4')->nullable();
$table->text('contact_footer')->nullable();
+ $table->text('visum_text')->nullable();
$table->text('entry_requirements')->nullable(); //need?
diff --git a/database/migrations/2018_10_29_202123_create_booking_table.php b/database/migrations/2018_10_29_202123_create_booking_table.php
index 9c7bb8a..b37d893 100644
--- a/database/migrations/2018_10_29_202123_create_booking_table.php
+++ b/database/migrations/2018_10_29_202123_create_booking_table.php
@@ -40,6 +40,7 @@ class CreateBookingTable extends Migration
$table->string('participant_firstname', 255)->nullable();
$table->date('participant_birthdate')->nullable();
$table->bigInteger('participant_salutation_id')->nullable();
+ $table->tinyInteger('participant_pass')->nullable()->default(0);
$table->unsignedInteger('nationality_id')->nullable();
$table->string('ev_number', 255)->nullable();
$table->string('merlin_knr', 255)->nullable();
@@ -58,6 +59,7 @@ class CreateBookingTable extends Migration
$table->tinyInteger('paying_out')->nullable()->default(0);
$table->tinyInteger('paying_out_status')->nullable()->default(0);
$table->unsignedBigInteger('airline_id')->nullable();
+ $table->string('airline_ids', 255)->nullable();
$table->tinyInteger('refund')->nullable()->default(0);
$table->date('refund_date')->nullable();
$table->date('lawyer_date')->nullable();
diff --git a/database/migrations/2020_01_29_152709_create_participant_table.php b/database/migrations/2020_01_29_152709_create_participant_table.php
index 62177a3..c1220d1 100644
--- a/database/migrations/2020_01_29_152709_create_participant_table.php
+++ b/database/migrations/2020_01_29_152709_create_participant_table.php
@@ -25,6 +25,7 @@ class CreateParticipantTable extends Migration
$table->date('participant_birthdate')->nullable();
$table->bigInteger('participant_salutation_id')->nullable();
$table->tinyInteger('participant_child')->nullable()->default(0);
+ $table->tinyInteger('participant_pass')->nullable()->default(0);
$table->unsignedInteger('nationality_id')->nullable();
diff --git a/database/migrations/2020_03_27_095607_create_airlines_table.php b/database/migrations/2020_03_27_095607_create_airlines_table.php
index e6b325d..bae44df 100644
--- a/database/migrations/2020_03_27_095607_create_airlines_table.php
+++ b/database/migrations/2020_03_27_095607_create_airlines_table.php
@@ -18,7 +18,9 @@ class CreateAirlinesTable extends Migration
$table->string('name', 255);
$table->string('name_full', 255);
$table->text('contact_emails')->nullable();
-
+ $table->text('flight_info')->nullable();
+ $table->text('check_in')->nullable();
+ $table->text('baggage')->nullable();
$table->timestamps();
});
}
diff --git a/database/migrations/sym/0001_sym_travel_country_table.php b/database/migrations/sym/0001_sym_travel_country_table.php
index 5bb734a..2a70fe0 100755
--- a/database/migrations/sym/0001_sym_travel_country_table.php
+++ b/database/migrations/sym/0001_sym_travel_country_table.php
@@ -33,7 +33,7 @@ class CreateTravelCountryTable extends Migration
$table->text('contact_text_4')->nullable();
$table->text('contact_footer')->nullable();
$table->text('contact_emails')->nullable();
-
+ $table->text('visum_text')->nullable();
});
diff --git a/public/js/custom.js b/public/js/custom.js
index 7186c6f..c019cb5 100644
--- a/public/js/custom.js
+++ b/public/js/custom.js
@@ -188,7 +188,7 @@ $(function () {
$.each(button.data(), function(index, value){
data[index] = value;
});
- // console.log(data);
+ //console.log(data);
loadModalInner(this, data);
});
@@ -221,7 +221,7 @@ $(function () {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
success: function(data) {
- // console.log(data);
+ //console.log(data);
$(data.response.target).find('.modal-dialog').html(data.html);
$(data.response.target).find('.selectpicker').selectpicker('refresh');
initModalInner();
diff --git a/resources/views/admin/report/bookings.blade.php b/resources/views/admin/report/bookings.blade.php
index fceefab..e2299fe 100755
--- a/resources/views/admin/report/bookings.blade.php
+++ b/resources/views/admin/report/bookings.blade.php
@@ -2,7 +2,7 @@
@section('content')
- Leistungsträger-Zahlungen
+ Buchungen & Leistungen
zurück ins v1 CRM