File Controller, Booking Organisation, import Draft, old arrangements
35
.env
|
|
@ -15,31 +15,44 @@ APP_DOMAIN_TLD=test
|
||||||
|
|
||||||
LOG_CHANNEL=stack
|
LOG_CHANNEL=stack
|
||||||
|
|
||||||
|
# Standard Database Connection
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=192.168.1.8
|
DB_HOST=mysql
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
DB_DATABASE=cmssso_db1
|
DB_DATABASE=stern_crm
|
||||||
DB_USERNAME=kadmin
|
DB_USERNAME=sail
|
||||||
DB_PASSWORD=KT32vQ7ix
|
DB_PASSWORD=password
|
||||||
|
|
||||||
DB_CONNECTION_STERN=mysql
|
# STERN Database Connection
|
||||||
DB_HOST_STERN=192.168.1.8
|
DB_HOST_STERN=mysql-stern
|
||||||
DB_PORT_STERN=3306
|
DB_PORT_STERN=3306
|
||||||
DB_DATABASE_STERN=relaunch1
|
DB_DATABASE_STERN=stern_db
|
||||||
DB_USERNAME_STERN=kadmin
|
DB_USERNAME_STERN=sail
|
||||||
DB_PASSWORD_STERN=KT32vQ7ix
|
DB_PASSWORD_STERN=password
|
||||||
|
|
||||||
|
# Docker Port Forwards
|
||||||
|
FORWARD_DB_PORT=33064
|
||||||
|
FORWARD_DB_PORT_STERN=33065
|
||||||
|
FORWARD_REDIS_PORT=6379
|
||||||
|
MYSQL_EXTRA_OPTIONS=
|
||||||
|
|
||||||
|
|
||||||
BROADCAST_DRIVER=log
|
BROADCAST_DRIVER=log
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
SESSION_DRIVER=file
|
SESSION_DRIVER=file
|
||||||
SESSION_LIFETIME=120
|
SESSION_LIFETIME=120
|
||||||
QUEUE_DRIVER=sync
|
|
||||||
|
|
||||||
REDIS_HOST=127.0.0.1
|
REDIS_HOST=redis
|
||||||
REDIS_PASSWORD=null
|
REDIS_PASSWORD=null
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
# Vite Port for Development
|
||||||
|
VITE_PORT=5173
|
||||||
|
# Sail Configuration
|
||||||
|
WWWGROUP=1000
|
||||||
|
WWWUSER=1000
|
||||||
|
SAIL_XDEBUG_MODE=off
|
||||||
|
|
||||||
MAIL_BBC=kevin@adametz.media
|
MAIL_BBC=kevin@adametz.media
|
||||||
MAIL_FEWO_EMPLOYEE=kevin@adametz.media
|
MAIL_FEWO_EMPLOYEE=kevin@adametz.media
|
||||||
|
|
|
||||||
15
.gitignore
vendored
|
|
@ -25,11 +25,24 @@ Icon
|
||||||
Network Trash Folder
|
Network Trash Folder
|
||||||
Temporary Items
|
Temporary Items
|
||||||
.apdisk
|
.apdisk
|
||||||
|
.idea/
|
||||||
|
.claude/
|
||||||
|
.cursor/
|
||||||
|
.cursorrules/
|
||||||
|
.cursorrules.md/
|
||||||
|
.cursorrules.md.txt/
|
||||||
|
.cursorrules.md.txt.txt/
|
||||||
|
.cursorrules.md.txt.txt.txt/
|
||||||
|
|
||||||
/vendor
|
/vendor
|
||||||
/node_modules
|
/node_modules
|
||||||
|
/storage/app
|
||||||
/storage/language
|
/storage/language
|
||||||
/storage/framework
|
/storage/framework
|
||||||
/storage/logs
|
/storage/logs
|
||||||
/public/vendor
|
/public/vendor
|
||||||
.idea
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
_static/
|
||||||
|
_work/
|
||||||
|
_storage/
|
||||||
|
|
|
||||||
7804
_ide_helper.php
|
|
@ -27,11 +27,10 @@ class BookingController extends Controller
|
||||||
protected $custRepo;
|
protected $custRepo;
|
||||||
|
|
||||||
public function __construct(BookingRepository $bookingRepo, CustomerRepository $custRepo)
|
public function __construct(BookingRepository $bookingRepo, CustomerRepository $custRepo)
|
||||||
{
|
{
|
||||||
$this->middleware(['admin', '2fa']);
|
$this->middleware(['admin', '2fa']);
|
||||||
$this->bookingRepo = $bookingRepo;
|
$this->bookingRepo = $bookingRepo;
|
||||||
$this->custRepo = $custRepo;
|
$this->custRepo = $custRepo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index($step = false)
|
public function index($step = false)
|
||||||
|
|
@ -45,11 +44,10 @@ class BookingController extends Controller
|
||||||
|
|
||||||
public function detail($id)
|
public function detail($id)
|
||||||
{
|
{
|
||||||
if($id == "new") {
|
if ($id == "new") {
|
||||||
$booking = new Booking();
|
$booking = new Booking();
|
||||||
$id = 'new';
|
$id = 'new';
|
||||||
|
} else {
|
||||||
}else{
|
|
||||||
$booking = Booking::findOrFail($id);
|
$booking = Booking::findOrFail($id);
|
||||||
$booking->getPassolutionPDF(true);
|
$booking->getPassolutionPDF(true);
|
||||||
$id = $booking->id;
|
$id = $booking->id;
|
||||||
|
|
@ -60,70 +58,91 @@ class BookingController extends Controller
|
||||||
'show_modal_quill_preview' => true,
|
'show_modal_quill_preview' => true,
|
||||||
];
|
];
|
||||||
return view('booking.detail', $data);
|
return view('booking.detail', $data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store($id)
|
public function store($id)
|
||||||
{
|
{
|
||||||
// \Session()->flash('alert-save', '1');
|
// \Session()->flash('alert-save', '1');
|
||||||
|
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
|
|
||||||
if($id === "new") {
|
if ($id === "new") {
|
||||||
$booking = new Booking();
|
$booking = new Booking();
|
||||||
}else{
|
} else {
|
||||||
$booking = Booking::findOrFail($id);
|
$booking = Booking::findOrFail($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($data['action'] === 'deleteAllChecked'){
|
if ($data['action'] === 'convertArrangementsToDrafts') {
|
||||||
if(!isset($data['draft_item_delete']) || !$data['draft_item_delete']){
|
if (!$booking->arrangements || $booking->arrangements->count() == 0) {
|
||||||
|
\Session()->flash('alert-warning', __('Keine Arrangements zum Konvertieren vorhanden'));
|
||||||
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->bookingRepo->convertArrangementsToDrafts($booking);
|
||||||
|
\Session()->flash('alert-success', __('Arrangements wurden erfolgreich in die neue Draft-Struktur übernommen'));
|
||||||
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data['action'] === 'loadDraftToBooking') {
|
||||||
|
if (!isset($data['draft_id']) || !$data['draft_id']) {
|
||||||
|
\Session()->flash('alert-error', __('Keine Vorlage ausgewählt'));
|
||||||
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->bookingRepo->loadDraftToBooking($booking->id, $data['draft_id']);
|
||||||
|
\Session()->flash('alert-success', __('Vorlage wurde erfolgreich geladen'));
|
||||||
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data['action'] === 'deleteAllChecked') {
|
||||||
|
if (!isset($data['draft_item_delete']) || !$data['draft_item_delete']) {
|
||||||
\Session()->flash('alert-error', 'Es wurden keine Leistungen ausgewählt');
|
\Session()->flash('alert-error', 'Es wurden keine Leistungen ausgewählt');
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingOrganisation");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($data['draft_item_delete'] as $draft_item_delete_id => $v) {
|
foreach ($data['draft_item_delete'] as $draft_item_delete_id => $v) {
|
||||||
$booking_draft_item = BookingDraftItem::findOrFail($draft_item_delete_id);
|
$booking_draft_item = BookingDraftItem::findOrFail($draft_item_delete_id);
|
||||||
if($booking_draft_item->booking_id === $booking->id){
|
if ($booking_draft_item->booking_id === $booking->id) {
|
||||||
$booking_draft_item->delete();
|
$booking_draft_item->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$booking->calculate_price_total();
|
$booking->calculate_price_total();
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingOrganisation");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['action'] === 'save_notice'){
|
if ($data['action'] === 'save_notice') {
|
||||||
$booking = $this->bookingRepo->updateNotice($id, $data);
|
$booking = $this->bookingRepo->updateNotice($id, $data);
|
||||||
\Session()->flash('alert-save', '1');
|
\Session()->flash('alert-save', '1');
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingNotice");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingNotice");
|
||||||
}
|
}
|
||||||
if($data['action'] === 'edit_notice'){
|
if ($data['action'] === 'edit_notice') {
|
||||||
$booking = $this->bookingRepo->updateNotice($id, $data);
|
$booking = $this->bookingRepo->updateNotice($id, $data);
|
||||||
\Session()->flash('alert-save', '1');
|
\Session()->flash('alert-save', '1');
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingNotice");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingNotice");
|
||||||
}
|
}
|
||||||
if(strpos($data['action'], 'createPDF') !== false) {
|
if (strpos($data['action'], 'createPDF') !== false) {
|
||||||
$bookingPDF = new BookingPDFRepository($booking);
|
$bookingPDF = new BookingPDFRepository($booking);
|
||||||
$bookingPDF->createPDF($id, $data);
|
$bookingPDF->createPDF($id, $data);
|
||||||
\Session()->flash('alert-success', 'PDF Datei erstellt');
|
\Session()->flash('alert-success', 'PDF Datei erstellt');
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingFiles");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingFiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
$redirect = route('booking_detail', [$booking->id]);
|
$redirect = route('booking_detail', [$booking->id]);
|
||||||
|
|
||||||
$i= 1;
|
$i = 1;
|
||||||
if($data['action'] === 'addItemUp'){
|
if ($data['action'] === 'addItemUp') {
|
||||||
$travel_program_id = null;
|
$travel_program_id = null;
|
||||||
$request_date = null;
|
$request_date = null;
|
||||||
$comfort = 0;
|
$comfort = 0;
|
||||||
if(count($booking->booking_draft_items)){
|
if (count($booking->booking_draft_items)) {
|
||||||
$first_booking_draft_item = $booking->booking_draft_items()->first();
|
$first_booking_draft_item = $booking->booking_draft_items()->first();
|
||||||
$travel_program_id = $first_booking_draft_item->travel_program_id;
|
$travel_program_id = $first_booking_draft_item->travel_program_id;
|
||||||
$request_date = $first_booking_draft_item->request_date;
|
$request_date = $first_booking_draft_item->request_date;
|
||||||
$comfort = $first_booking_draft_item->comfort;
|
$comfort = $first_booking_draft_item->comfort;
|
||||||
}
|
}
|
||||||
$add_draft_items_up_number = isset($data['add_draft_items_up_number']) ? intval($data['add_draft_items_up_number']) : 1;
|
$add_draft_items_up_number = isset($data['add_draft_items_up_number']) ? intval($data['add_draft_items_up_number']) : 1;
|
||||||
for ($j=0; $j < $add_draft_items_up_number; $j++) {
|
for ($j = 0; $j < $add_draft_items_up_number; $j++) {
|
||||||
$booking->booking_draft_items()->create([
|
$booking->booking_draft_items()->create([
|
||||||
'booking_id' => $booking->id,
|
'booking_id' => $booking->id,
|
||||||
'travel_program_id' => $travel_program_id,
|
'travel_program_id' => $travel_program_id,
|
||||||
|
|
@ -138,7 +157,7 @@ class BookingController extends Controller
|
||||||
'end_date' => null,
|
'end_date' => null,
|
||||||
'service' => '',
|
'service' => '',
|
||||||
'price_adult' => null,
|
'price_adult' => null,
|
||||||
'adult' => null ,
|
'adult' => null,
|
||||||
'price_children' => 0,
|
'price_children' => 0,
|
||||||
'children' => 0,
|
'children' => 0,
|
||||||
'price' => 0,
|
'price' => 0,
|
||||||
|
|
@ -148,11 +167,11 @@ class BookingController extends Controller
|
||||||
]);
|
]);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingOrganisation");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($data['draft_item'])){
|
if (isset($data['draft_item'])) {
|
||||||
foreach ($data['draft_item'] as $booking_draft_item_id => $draft_item){
|
foreach ($data['draft_item'] as $booking_draft_item_id => $draft_item) {
|
||||||
$BookingDraftItem = BookingDraftItem::findOrFail($booking_draft_item_id);
|
$BookingDraftItem = BookingDraftItem::findOrFail($booking_draft_item_id);
|
||||||
$draft_item['price_adult'] = isset($draft_item['price_adult']) ? $draft_item['price_adult'] : null;
|
$draft_item['price_adult'] = isset($draft_item['price_adult']) ? $draft_item['price_adult'] : null;
|
||||||
$draft_item['adult'] = isset($draft_item['adult']) ? $draft_item['adult'] : null;
|
$draft_item['adult'] = isset($draft_item['adult']) ? $draft_item['adult'] : null;
|
||||||
|
|
@ -166,18 +185,18 @@ class BookingController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['action'] === 'addItemDown'){
|
if ($data['action'] === 'addItemDown') {
|
||||||
$travel_program_id = null;
|
$travel_program_id = null;
|
||||||
$request_date = null;
|
$request_date = null;
|
||||||
$comfort = 0;
|
$comfort = 0;
|
||||||
if(count($booking->booking_draft_items)){
|
if (count($booking->booking_draft_items)) {
|
||||||
$first_booking_draft_item = $booking->booking_draft_items()->first();
|
$first_booking_draft_item = $booking->booking_draft_items()->first();
|
||||||
$travel_program_id = $first_booking_draft_item->travel_program_id;
|
$travel_program_id = $first_booking_draft_item->travel_program_id;
|
||||||
$request_date = $first_booking_draft_item->request_date;
|
$request_date = $first_booking_draft_item->request_date;
|
||||||
$comfort = $first_booking_draft_item->comfort;
|
$comfort = $first_booking_draft_item->comfort;
|
||||||
}
|
}
|
||||||
$add_draft_items_up_number = isset($data['add_draft_items_down_number']) ? intval($data['add_draft_items_down_number']) : 1;
|
$add_draft_items_up_number = isset($data['add_draft_items_down_number']) ? intval($data['add_draft_items_down_number']) : 1;
|
||||||
for ($j=0; $j < $add_draft_items_up_number; $j++) {
|
for ($j = 0; $j < $add_draft_items_up_number; $j++) {
|
||||||
$booking->booking_draft_items()->create([
|
$booking->booking_draft_items()->create([
|
||||||
'booking_id' => $booking->id,
|
'booking_id' => $booking->id,
|
||||||
'travel_program_id' => $travel_program_id,
|
'travel_program_id' => $travel_program_id,
|
||||||
|
|
@ -192,7 +211,7 @@ class BookingController extends Controller
|
||||||
'end_date' => null,
|
'end_date' => null,
|
||||||
'service' => '',
|
'service' => '',
|
||||||
'price_adult' => null,
|
'price_adult' => null,
|
||||||
'adult' => null ,
|
'adult' => null,
|
||||||
'price_children' => 0,
|
'price_children' => 0,
|
||||||
'children' => 0,
|
'children' => 0,
|
||||||
'price' => 0,
|
'price' => 0,
|
||||||
|
|
@ -202,14 +221,15 @@ class BookingController extends Controller
|
||||||
]);
|
]);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingOrganisation");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($data['action'] === 'saveCustomer' || $data['action'] === 'saveAll' || $data['action'] === 'save_lead_status' || $data['action'] === 'update_booking' ||
|
if (
|
||||||
$data['action'] === 'update_booking_services' || $data['action'] === 'update_booking_number' || $data['action'] === 'update_booking_price' ||
|
$data['action'] === 'saveCustomer' || $data['action'] === 'saveAll' || $data['action'] === 'save_lead_status' || $data['action'] === 'update_booking' ||
|
||||||
$data['action'] === 'update_service_provider_entry' || $data['action'] === 'update_booking_service_item' || $data['action'] === 'update_booking_participant'){
|
$data['action'] === 'update_booking_services' || $data['action'] === 'update_booking_number' || $data['action'] === 'update_booking_price' ||
|
||||||
|
$data['action'] === 'update_service_provider_entry' || $data['action'] === 'update_booking_service_item' || $data['action'] === 'update_booking_participant'
|
||||||
|
) {
|
||||||
$customer = $this->custRepo->updateCustomerFromBooking($id, $data);
|
$customer = $this->custRepo->updateCustomerFromBooking($id, $data);
|
||||||
$booking = $this->bookingRepo->updateLeadStatus($id, $data);
|
$booking = $this->bookingRepo->updateLeadStatus($id, $data);
|
||||||
$booking = $this->bookingRepo->updateBooking($id, $data);
|
$booking = $this->bookingRepo->updateBooking($id, $data);
|
||||||
|
|
@ -222,49 +242,49 @@ class BookingController extends Controller
|
||||||
|
|
||||||
|
|
||||||
\Session()->flash('alert-save', '1');
|
\Session()->flash('alert-save', '1');
|
||||||
|
|
||||||
|
|
||||||
switch($data['action']){
|
|
||||||
|
switch ($data['action']) {
|
||||||
case 'saveCustomer':
|
case 'saveCustomer':
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingCustomer");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingCustomer");
|
||||||
break;
|
break;
|
||||||
case 'saveAll':
|
case 'saveAll':
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingOrganisation");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
break;
|
break;
|
||||||
case 'update_booking':
|
case 'update_booking':
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingBooking");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingBooking");
|
||||||
break;
|
break;
|
||||||
case 'save_lead_status':
|
case 'save_lead_status':
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingLead");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingLead");
|
||||||
break;
|
break;
|
||||||
case 'update_booking_services':
|
case 'update_booking_services':
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingServices");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingServices");
|
||||||
break;
|
break;
|
||||||
case 'update_booking_number':
|
case 'update_booking_number':
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingMyJack");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingMyJack");
|
||||||
break;
|
break;
|
||||||
case 'update_booking_price':
|
case 'update_booking_price':
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingPrice");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingPrice");
|
||||||
break;
|
break;
|
||||||
case 'update_service_provider_entry':
|
case 'update_service_provider_entry':
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingProvider");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingProvider");
|
||||||
break;
|
break;
|
||||||
case 'update_booking_service_item':
|
case 'update_booking_service_item':
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingCompany");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingCompany");
|
||||||
break;
|
break;
|
||||||
case 'update_booking_participant':
|
case 'update_booking_participant':
|
||||||
$redirect = redirect(route('booking_detail', [$booking->id])."#collapseBookingParticipant");
|
$redirect = redirect(route('booking_detail', [$booking->id]) . "#collapseBookingParticipant");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$booking->calculate_price_total();
|
$booking->calculate_price_total();
|
||||||
|
|
||||||
if(strpos($data['action'], 'up_') !== false) {
|
if (strpos($data['action'], 'up_') !== false) {
|
||||||
$reId = intval(str_replace('up_', '', $data['action']));
|
$reId = intval(str_replace('up_', '', $data['action']));
|
||||||
$d_from = BookingDraftItem::findOrFail($reId);
|
$d_from = BookingDraftItem::findOrFail($reId);
|
||||||
$d_to = $booking->findBeforeDraftItemRelation($reId);
|
$d_to = $booking->findBeforeDraftItemRelation($reId);
|
||||||
if($d_to) {
|
if ($d_to) {
|
||||||
$t_pos = $d_from->pos;
|
$t_pos = $d_from->pos;
|
||||||
$d_from->pos = $d_to->pos;
|
$d_from->pos = $d_to->pos;
|
||||||
$d_to->pos = $t_pos;
|
$d_to->pos = $t_pos;
|
||||||
|
|
@ -272,11 +292,11 @@ class BookingController extends Controller
|
||||||
$d_to->save();
|
$d_to->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(strpos($data['action'], 'down_') !== false) {
|
if (strpos($data['action'], 'down_') !== false) {
|
||||||
$reId = intval(str_replace('down_', '', $data['action']));
|
$reId = intval(str_replace('down_', '', $data['action']));
|
||||||
$d_from = BookingDraftItem::findOrFail($reId);
|
$d_from = BookingDraftItem::findOrFail($reId);
|
||||||
$d_to = $booking->findAfterDraftItemRelation($reId);
|
$d_to = $booking->findAfterDraftItemRelation($reId);
|
||||||
if($d_to) {
|
if ($d_to) {
|
||||||
$t_pos = $d_from->pos;
|
$t_pos = $d_from->pos;
|
||||||
$d_from->pos = $d_to->pos;
|
$d_from->pos = $d_to->pos;
|
||||||
$d_to->pos = $t_pos;
|
$d_to->pos = $t_pos;
|
||||||
|
|
@ -288,11 +308,12 @@ class BookingController extends Controller
|
||||||
return $redirect;
|
return $redirect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadModal(){
|
public function loadModal()
|
||||||
|
{
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
$ret = "";
|
$ret = "";
|
||||||
if(Request::ajax()) {
|
if (Request::ajax()) {
|
||||||
if ($data['action'] === "new-customer-mail" || $data['action'] === "reply-customer-mail" || $data['action'] === "show-customer-mail" || $data['action'] === "edit-customer-mail"){
|
if ($data['action'] === "new-customer-mail" || $data['action'] === "reply-customer-mail" || $data['action'] === "show-customer-mail" || $data['action'] === "edit-customer-mail") {
|
||||||
$data['customers'] = [];
|
$data['customers'] = [];
|
||||||
if ($data['action'] === "new-customer-mail" && isset($data['booking_id']) && $booking = Booking::find($data['booking_id'])) {
|
if ($data['action'] === "new-customer-mail" && isset($data['booking_id']) && $booking = Booking::find($data['booking_id'])) {
|
||||||
$tmp = [];
|
$tmp = [];
|
||||||
|
|
@ -305,120 +326,119 @@ class BookingController extends Controller
|
||||||
$ret = CustomerMailRepository::loadModal($data);
|
$ret = CustomerMailRepository::loadModal($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['action'] === "modal-upload-booking-file") {
|
if ($data['action'] === "modal-upload-booking-file") {
|
||||||
$ret = view("booking.upload_modal", compact('data'))->render();
|
$ret = view("booking.upload_modal", compact('data'))->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['action'] === "edit_notice") {
|
if ($data['action'] === "edit_notice") {
|
||||||
$value = BookingNotice::findOrFail($data['id']);
|
$value = BookingNotice::findOrFail($data['id']);
|
||||||
$ret = view("booking.edit_notice_modal", compact('data', 'value'))->render();
|
$ret = view("booking.edit_notice_modal", compact('data', 'value'))->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['action'] === "createPDF_Coupon") {
|
if ($data['action'] === "createPDF_Coupon") {
|
||||||
$booking = Booking::findOrFail($data['booking_id']);
|
$booking = Booking::findOrFail($data['booking_id']);
|
||||||
$data['has_coupon'] = $booking->hasDocument('coupon');
|
$data['has_coupon'] = $booking->hasDocument('coupon');
|
||||||
$data['default_value'] = config('booking.coupon_default_value');
|
$data['default_value'] = config('booking.coupon_default_value');
|
||||||
$data['issue_date'] = date('d.m.Y');
|
$data['issue_date'] = date('d.m.Y');
|
||||||
$data['valid_date'] = \Carbon::now()->addMonths(config('booking.coupon_valid_date_month'))->format('d.m.Y');
|
$data['valid_date'] = \Carbon::now()->addMonths(config('booking.coupon_valid_date_month'))->format('d.m.Y');
|
||||||
$ret = view("booking.modal_create_coupon", compact('data'))->render();
|
$ret = view("booking.modal_create_coupon", compact('data'))->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['action'] === "createPDF_Storno") {
|
if ($data['action'] === "createPDF_Storno") {
|
||||||
$booking = Booking::findOrFail($data['booking_id']);
|
$booking = Booking::findOrFail($data['booking_id']);
|
||||||
$data['price'] = $booking->price;
|
$data['price'] = $booking->price;
|
||||||
if($data['has_storno'] = $booking->hasDocument('storno')){
|
if ($data['has_storno'] = $booking->hasDocument('storno')) {
|
||||||
$document_storno = $booking->getDocument('storno');
|
$document_storno = $booking->getDocument('storno');
|
||||||
$data['storno_date'] = \Carbon::parse($document_storno->data->storno_date)->format('d.m.Y');
|
$data['storno_date'] = \Carbon::parse($document_storno->data->storno_date)->format('d.m.Y');
|
||||||
$data['storno_print'] = \Carbon::parse($document_storno->data->storno_print)->format('d.m.Y') ;
|
$data['storno_print'] = \Carbon::parse($document_storno->data->storno_print)->format('d.m.Y');
|
||||||
$data['storno_status_id'] = $document_storno->data->storno_status_id;
|
$data['storno_status_id'] = $document_storno->data->storno_status_id;
|
||||||
$data['storno_level'] = $document_storno->data->storno_level;
|
$data['storno_level'] = $document_storno->data->storno_level;
|
||||||
$data['storno_level_number'] = _number_format($document_storno->data->storno_level);
|
$data['storno_level_number'] = _number_format($document_storno->data->storno_level);
|
||||||
$data['storno_total_price'] = '';
|
$data['storno_total_price'] = '';
|
||||||
|
} else {
|
||||||
|
|
||||||
}else{
|
|
||||||
$data['storno_date'] = date('d.m.Y');
|
$data['storno_date'] = date('d.m.Y');
|
||||||
$data['storno_print'] = date('d.m.Y');
|
$data['storno_print'] = date('d.m.Y');
|
||||||
$data['storno_status_id'] = null;
|
$data['storno_status_id'] = null;
|
||||||
$data['storno_level'] = 100;
|
$data['storno_level'] = 100;
|
||||||
$data['storno_level_number'] = '';
|
$data['storno_level_number'] = '';
|
||||||
$data['storno_total_price'] = '';
|
$data['storno_total_price'] = '';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = view("booking.modal_create_storno", compact('data'))->render();
|
$ret = view("booking.modal_create_storno", compact('data'))->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['action'] === "upload-booking-file"){
|
if ($data['action'] === "upload-booking-file") {
|
||||||
if($data['booking_id']){
|
if ($data['booking_id']) {
|
||||||
$bookingFileRepo = new BookingFileRepository(new BookingFile());
|
$bookingFileRepo = new BookingFileRepository(new BookingFile());
|
||||||
$bookingFileRepo->_set('disk', 'booking');
|
$bookingFileRepo->_set('disk', 'booking');
|
||||||
$bookingFileRepo->_set('booking_id', $data['booking_id']);
|
$bookingFileRepo->_set('booking_id', $data['booking_id']);
|
||||||
$bookingFileRepo->_set('dir', '/files/'.date('Y/m').'/');
|
$bookingFileRepo->_set('dir', '/files/' . date('Y/m') . '/');
|
||||||
$bookingFileRepo->_set('identifier', 'booking');
|
$bookingFileRepo->_set('identifier', 'booking');
|
||||||
return $bookingFileRepo->uploadFile(Request::all());
|
return $bookingFileRepo->uploadFile(Request::all());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return response()->json(['response' => $data, 'html'=>$ret]);
|
return response()->json(['response' => $data, 'html' => $ret]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function draftItemDelete($id){
|
public function draftItemDelete($id)
|
||||||
|
{
|
||||||
$booking_draft_item = BookingDraftItem::findOrFail($id);
|
$booking_draft_item = BookingDraftItem::findOrFail($id);
|
||||||
$booking = $booking_draft_item->booking;
|
$booking = $booking_draft_item->booking;
|
||||||
$booking_draft_item->delete();
|
$booking_draft_item->delete();
|
||||||
$booking->calculate_price_total();
|
$booking->calculate_price_total();
|
||||||
\Session()->flash('alert-success', __('Eintrag gelöscht'));
|
\Session()->flash('alert-success', __('Eintrag gelöscht'));
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingOrganisation");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function action($action, $id=false){
|
public function action($action, $id = false)
|
||||||
|
{
|
||||||
|
|
||||||
if(!$booking = Booking::find($id)){
|
if (!$booking = Booking::find($id)) {
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action === 'change_travel_dates'){
|
if ($action === 'change_travel_dates') {
|
||||||
$draftRepo = new DraftRepository($booking);
|
$draftRepo = new DraftRepository($booking);
|
||||||
$draftRepo->change_dates_drafts_from_booking(Request::get('change_travel_start_date'));
|
$draftRepo->change_dates_drafts_from_booking(Request::get('change_travel_start_date'));
|
||||||
\Session()->flash('alert-success', __('Datum der Reise wurde geändert'));
|
\Session()->flash('alert-success', __('Datum der Reise wurde geändert'));
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingOrganisation");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingOrganisation");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action === 'service_provider_entry_add_discount'){
|
if ($action === 'service_provider_entry_add_discount') {
|
||||||
$ServiceProvider = ServiceProvider::where('type', 'discount')->where('active',true)->first();
|
$ServiceProvider = ServiceProvider::where('type', 'discount')->where('active', true)->first();
|
||||||
ServiceProviderEntry::create([
|
ServiceProviderEntry::create([
|
||||||
'booking_id' => $booking->id,
|
'booking_id' => $booking->id,
|
||||||
'service_provider_id' => $ServiceProvider->id,
|
'service_provider_id' => $ServiceProvider->id,
|
||||||
'type' => 'discount',
|
'type' => 'discount',
|
||||||
]);
|
]);
|
||||||
\Session()->flash('alert-success', __('Leistungsträger neuer Rabatt hinzugefügt'));
|
\Session()->flash('alert-success', __('Leistungsträger neuer Rabatt hinzugefügt'));
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingProvider");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingProvider");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action === 'service_provider_entry_add_payment'){
|
if ($action === 'service_provider_entry_add_payment') {
|
||||||
$ServiceProvider = ServiceProvider::where('type', 'payment')->where('active',true)->first();
|
$ServiceProvider = ServiceProvider::where('type', 'payment')->where('active', true)->first();
|
||||||
ServiceProviderEntry::create([
|
ServiceProviderEntry::create([
|
||||||
'booking_id' => $booking->id,
|
'booking_id' => $booking->id,
|
||||||
'service_provider_id' => $ServiceProvider->id,
|
'service_provider_id' => $ServiceProvider->id,
|
||||||
'type' => 'payment',
|
'type' => 'payment',
|
||||||
]);
|
]);
|
||||||
\Session()->flash('alert-success', __('Leistungsträger neue Zahlung hinzugefügt'));
|
\Session()->flash('alert-success', __('Leistungsträger neue Zahlung hinzugefügt'));
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingProvider");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingProvider");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action === 'booking_service_item_add'){
|
if ($action === 'booking_service_item_add') {
|
||||||
$TravelCompany = TravelCompany::where('active',true)->first();
|
$TravelCompany = TravelCompany::where('active', true)->first();
|
||||||
BookingServiceItem::create([
|
BookingServiceItem::create([
|
||||||
'booking_id' => $booking->id,
|
'booking_id' => $booking->id,
|
||||||
'travel_company_id' => $TravelCompany->id,
|
'travel_company_id' => $TravelCompany->id,
|
||||||
'travel_date' => now(),
|
'travel_date' => now(),
|
||||||
]);
|
]);
|
||||||
\Session()->flash('alert-success', __('Reiseveranstalter neue Leistung hinzugefügt'));
|
\Session()->flash('alert-success', __('Reiseveranstalter neue Leistung hinzugefügt'));
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingCompany");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingCompany");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($action === 'booking_participant_add'){
|
if ($action === 'booking_participant_add') {
|
||||||
Participant::create([
|
Participant::create([
|
||||||
'booking_id' => $booking->id,
|
'booking_id' => $booking->id,
|
||||||
'nationality_id' => 1,
|
'nationality_id' => 1,
|
||||||
|
|
@ -426,129 +446,129 @@ class BookingController extends Controller
|
||||||
|
|
||||||
]);
|
]);
|
||||||
\Session()->flash('alert-success', __('Neuen Teilnehmer hinzugefügt'));
|
\Session()->flash('alert-success', __('Neuen Teilnehmer hinzugefügt'));
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingParticipant");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingParticipant");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id, $del="booking"){
|
public function delete($id, $del = "booking")
|
||||||
|
{
|
||||||
|
|
||||||
if($del === 'booking_file'){
|
if ($del === 'booking_file') {
|
||||||
$booking_file = BookingFile::findOrFail($id);
|
$booking_file = BookingFile::findOrFail($id);
|
||||||
$booking = $booking_file->booking;
|
$booking = $booking_file->booking;
|
||||||
$this->deleteBookingFile($booking_file);
|
$this->deleteBookingFile($booking_file);
|
||||||
\Session()->flash('alert-success', 'Datei gelöscht');
|
\Session()->flash('alert-success', 'Datei gelöscht');
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingFiles");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingFiles");
|
||||||
}
|
}
|
||||||
if($del === 'booking_notice'){
|
if ($del === 'booking_notice') {
|
||||||
$booking_notice = BookingNotice::findOrFail($id);
|
$booking_notice = BookingNotice::findOrFail($id);
|
||||||
$booking = $booking_notice->booking;
|
$booking = $booking_notice->booking;
|
||||||
$booking_notice->delete();
|
$booking_notice->delete();
|
||||||
\Session()->flash('alert-success', 'Notiz gelöscht');
|
\Session()->flash('alert-success', 'Notiz gelöscht');
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingNotice");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingNotice");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($del === 'passolution_file'){
|
if ($del === 'passolution_file') {
|
||||||
$booking = Booking::findOrFail($id);
|
$booking = Booking::findOrFail($id);
|
||||||
$booking->resyncPassolutionPDF();
|
$booking->resyncPassolutionPDF();
|
||||||
\Session()->flash('alert-success', 'Passolution erneuert');
|
\Session()->flash('alert-success', 'Passolution erneuert');
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingFiles");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingFiles");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($del === 'service_provider_entry'){
|
if ($del === 'service_provider_entry') {
|
||||||
$ServiceProviderEntry = ServiceProviderEntry::findOrFail($id);
|
$ServiceProviderEntry = ServiceProviderEntry::findOrFail($id);
|
||||||
$booking = $ServiceProviderEntry->booking;
|
$booking = $ServiceProviderEntry->booking;
|
||||||
$ServiceProviderEntry->delete();
|
$ServiceProviderEntry->delete();
|
||||||
\Session()->flash('alert-success', 'Leistungsträger gelöscht');
|
\Session()->flash('alert-success', 'Leistungsträger gelöscht');
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingProvider");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingProvider");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($del === 'booking_service_item'){
|
if ($del === 'booking_service_item') {
|
||||||
$BookingServiceItem = BookingServiceItem::findOrFail($id);
|
$BookingServiceItem = BookingServiceItem::findOrFail($id);
|
||||||
$booking = $BookingServiceItem->booking;
|
$booking = $BookingServiceItem->booking;
|
||||||
$BookingServiceItem->delete();
|
$BookingServiceItem->delete();
|
||||||
\Session()->flash('alert-success', 'Reiseveranstalter gelöscht');
|
\Session()->flash('alert-success', 'Reiseveranstalter gelöscht');
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingCompany");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingCompany");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($del === 'participant'){
|
if ($del === 'participant') {
|
||||||
$Participant = Participant::findOrFail($id);
|
$Participant = Participant::findOrFail($id);
|
||||||
$booking = $Participant->booking;
|
$booking = $Participant->booking;
|
||||||
$Participant->delete();
|
$Participant->delete();
|
||||||
\Session()->flash('alert-success', 'Teilnehmer gelöscht');
|
\Session()->flash('alert-success', 'Teilnehmer gelöscht');
|
||||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingParticipant");
|
return redirect(route('booking_detail', [$booking->id]) . "#collapseBookingParticipant");
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(route('requests'));
|
return redirect(route('requests'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function deleteBookingFile($booking_file){
|
private function deleteBookingFile($booking_file)
|
||||||
|
{
|
||||||
$fileRepo = new BookingFileRepository($booking_file);
|
$fileRepo = new BookingFileRepository($booking_file);
|
||||||
$fileRepo->_set('disk', 'booking');
|
$fileRepo->_set('disk', 'booking');
|
||||||
$fileRepo->delete();
|
$fileRepo->delete();
|
||||||
$booking_file->delete();
|
$booking_file->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function deleteCustomerFile($customer_file){
|
private function deleteCustomerFile($customer_file)
|
||||||
|
{
|
||||||
$fileRepo = new CustomerFileRepository($customer_file);
|
$fileRepo = new CustomerFileRepository($customer_file);
|
||||||
$fileRepo->_set('disk', 'customer');
|
$fileRepo->_set('disk', 'customer');
|
||||||
$fileRepo->delete();
|
$fileRepo->delete();
|
||||||
$customer_file->delete();
|
$customer_file->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function deleteBookingDocument($booking_document){
|
private function deleteBookingDocument($booking_document)
|
||||||
|
{
|
||||||
$booking_document->deleteFile();
|
$booking_document->deleteFile();
|
||||||
$booking_document->delete();
|
$booking_document->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteComplete($id){
|
public function deleteComplete($id)
|
||||||
|
{
|
||||||
$booking = Booking::findOrFail($id);
|
$booking = Booking::findOrFail($id);
|
||||||
|
|
||||||
if($booking->booking_files){
|
if ($booking->booking_files) {
|
||||||
foreach ($booking->booking_files as $booking_file) {
|
foreach ($booking->booking_files as $booking_file) {
|
||||||
$this->deleteBookingFile($booking_file);
|
$this->deleteBookingFile($booking_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($booking->booking_notices){
|
if ($booking->booking_notices) {
|
||||||
foreach ($booking->booking_notices as $booking_notice) {
|
foreach ($booking->booking_notices as $booking_notice) {
|
||||||
$booking_notice->delete();
|
$booking_notice->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($booking->service_provider_entries){
|
if ($booking->service_provider_entries) {
|
||||||
foreach ($booking->service_provider_entries as $service_provider_entry) {
|
foreach ($booking->service_provider_entries as $service_provider_entry) {
|
||||||
$service_provider_entry->delete();
|
$service_provider_entry->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($booking->booking_service_items){
|
if ($booking->booking_service_items) {
|
||||||
foreach ($booking->booking_service_items as $booking_service_item) {
|
foreach ($booking->booking_service_items as $booking_service_item) {
|
||||||
$booking_service_item->delete();
|
$booking_service_item->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($booking->booking_provider_services){
|
if ($booking->booking_provider_services) {
|
||||||
foreach ($booking->booking_provider_services as $booking_provider_service) {
|
foreach ($booking->booking_provider_services as $booking_provider_service) {
|
||||||
$booking_provider_service->delete();
|
$booking_provider_service->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($booking->booking_country_services){
|
if ($booking->booking_country_services) {
|
||||||
foreach ($booking->booking_country_services as $booking_country_service) {
|
foreach ($booking->booking_country_services as $booking_country_service) {
|
||||||
$booking_country_service->delete();
|
$booking_country_service->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($booking->participants){
|
if ($booking->participants) {
|
||||||
foreach ($booking->participants as $participant) {
|
foreach ($booking->participants as $participant) {
|
||||||
$participant->delete();
|
$participant->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($booking->customer_mails){
|
if ($booking->customer_mails) {
|
||||||
foreach ($booking->customer_mails_reverse as $customer_mail) {
|
foreach ($booking->customer_mails_reverse as $customer_mail) {
|
||||||
if($customer_mail->customer_files){
|
if ($customer_mail->customer_files) {
|
||||||
foreach ($customer_mail->customer_files as $customer_file) {
|
foreach ($customer_mail->customer_files as $customer_file) {
|
||||||
$this->deleteCustomerFile($customer_file);
|
$this->deleteCustomerFile($customer_file);
|
||||||
}
|
}
|
||||||
|
|
@ -556,18 +576,18 @@ class BookingController extends Controller
|
||||||
$customer_mail->delete();
|
$customer_mail->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($booking->booking_documents){
|
if ($booking->booking_documents) {
|
||||||
foreach ($booking->booking_documents as $booking_document) {
|
foreach ($booking->booking_documents as $booking_document) {
|
||||||
if($booking_document->identifier === 'coupon'){
|
if ($booking_document->identifier === 'coupon') {
|
||||||
//coupon set booking ID to null <- is need by the customer
|
//coupon set booking ID to null <- is need by the customer
|
||||||
$booking_document->booking_id = null;
|
$booking_document->booking_id = null;
|
||||||
$booking_document->save();
|
$booking_document->save();
|
||||||
}else{
|
} else {
|
||||||
$this->deleteBookingDocument($booking_document);
|
$this->deleteBookingDocument($booking_document);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($booking->coupons){
|
if ($booking->coupons) {
|
||||||
foreach ($booking->coupons as $coupon) {
|
foreach ($booking->coupons as $coupon) {
|
||||||
//coupon set booking ID to null <- is need by the customer
|
//coupon set booking ID to null <- is need by the customer
|
||||||
$coupon->booking_id = null;
|
$coupon->booking_id = null;
|
||||||
|
|
@ -578,7 +598,4 @@ class BookingController extends Controller
|
||||||
\Session()->flash('alert-success', 'Buchung gelöscht');
|
\Session()->flash('alert-success', 'Buchung gelöscht');
|
||||||
return redirect(route('requests'));
|
return redirect(route('requests'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,17 +13,15 @@ class FileController extends Controller
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function show($id = null, $disk = null, $do='file')
|
public function show($id = null, $disk = null, $do = 'file')
|
||||||
{
|
{
|
||||||
$path = "";
|
$path = "";
|
||||||
$filename = "";
|
$filename = "";
|
||||||
|
|
||||||
switch ($disk){
|
switch ($disk) {
|
||||||
case 'customer':
|
case 'customer':
|
||||||
$file = \App\Models\CustomerFile::findOrFail($id);
|
$file = \App\Models\CustomerFile::findOrFail($id);
|
||||||
$filename = $file->original_name;
|
$filename = $file->original_name;
|
||||||
|
|
@ -66,25 +64,33 @@ class FileController extends Controller
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
|
|
||||||
|
// Cache-Control Header für PDFs und andere Dateien, die sich häufig ändern
|
||||||
|
$headers = [
|
||||||
|
'Cache-Control' => 'no-cache, no-store, must-revalidate',
|
||||||
|
'Pragma' => 'no-cache',
|
||||||
|
'Expires' => '0'
|
||||||
|
];
|
||||||
|
|
||||||
switch ($do) {
|
switch ($do) {
|
||||||
case 'file':
|
case 'file':
|
||||||
return Response::file($path);
|
return Response::file($path, $headers);
|
||||||
break;
|
break;
|
||||||
case 'download':
|
case 'download':
|
||||||
return Response::download($path, $filename);
|
return Response::download($path, $filename, $headers);
|
||||||
break;
|
break;
|
||||||
case 'url':
|
case 'url':
|
||||||
return $path.$filename;
|
return $path . $filename;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function showExpert($type = null, $class = null, $year = null, $file = null, $do = null) {
|
public function showExpert($type = null, $class = null, $year = null, $file = null, $do = null)
|
||||||
|
{
|
||||||
|
|
||||||
/*if ($type == 'xls') {
|
/*if ($type == 'xls') {
|
||||||
$path = storage_path("app/export/");
|
$path = storage_path("app/export/");
|
||||||
|
|
@ -92,35 +98,39 @@ class FileController extends Controller
|
||||||
}*/
|
}*/
|
||||||
$path = "";
|
$path = "";
|
||||||
$filename = "";
|
$filename = "";
|
||||||
$headers = [];
|
$headers = [
|
||||||
|
'Cache-Control' => 'no-cache, no-store, must-revalidate',
|
||||||
|
'Pragma' => 'no-cache',
|
||||||
|
'Expires' => '0'
|
||||||
|
];
|
||||||
|
|
||||||
if ($class === 'invoices' || $class === 'infos'){
|
if ($class === 'invoices' || $class === 'infos') {
|
||||||
$headers = [
|
$headers = [
|
||||||
'Content-Type: application/pdf',
|
'Content-Type: application/pdf',
|
||||||
'Pragma: no-cache',
|
'Pragma: no-cache',
|
||||||
'Cache-Control: no-store,no-cache, must-revalidate, post-check=0, pre-check=0'
|
'Cache-Control: no-store,no-cache, must-revalidate, post-check=0, pre-check=0'
|
||||||
];
|
];
|
||||||
$dir = $year."/";
|
$dir = $year . "/";
|
||||||
$filename = $file;
|
$filename = $file;
|
||||||
if ($type === 'fewo') {
|
if ($type === 'fewo') {
|
||||||
if(Storage::disk('fewo_invoices')->exists( $dir.$filename )){
|
if (Storage::disk('fewo_invoices')->exists($dir . $filename)) {
|
||||||
$path = Storage::disk('fewo_invoices')->path($dir.$filename);
|
$path = Storage::disk('fewo_invoices')->path($dir . $filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($type === 'fewo') {
|
if ($type === 'fewo') {
|
||||||
if(Storage::disk('fewo_infos')->exists( $dir.$filename )){
|
if (Storage::disk('fewo_infos')->exists($dir . $filename)) {
|
||||||
$path = Storage::disk('fewo_infos')->path($dir.$filename);
|
$path = Storage::disk('fewo_infos')->path($dir . $filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
if($do === "download"){
|
if ($do === "download") {
|
||||||
return Response::download($path, $filename, $headers);
|
return Response::download($path, $filename, $headers);
|
||||||
}
|
}
|
||||||
if($do === "file"){
|
if ($do === "file") {
|
||||||
return Response::file($path, $headers);
|
return Response::file($path, $headers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,11 @@ class TravelCompanyController extends Controller
|
||||||
|
|
||||||
public function detail($id, $step = false)
|
public function detail($id, $step = false)
|
||||||
{
|
{
|
||||||
if($id === "new") {
|
if ($id == "new") {
|
||||||
$model = new TravelCompany();
|
$model = new TravelCompany();
|
||||||
$id = 'new';
|
$id = 'new';
|
||||||
$model->active = 1;
|
$model->active = 1;
|
||||||
}else{
|
} else {
|
||||||
$model = TravelCompany::findOrFail($id);
|
$model = TravelCompany::findOrFail($id);
|
||||||
$id = $model->id;
|
$id = $model->id;
|
||||||
}
|
}
|
||||||
|
|
@ -45,20 +45,21 @@ class TravelCompanyController extends Controller
|
||||||
return view('settings.travel_company.detail', $data);
|
return view('settings.travel_company.detail', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id){
|
public function update($id)
|
||||||
|
{
|
||||||
|
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
|
|
||||||
|
|
||||||
if(isset($data['update-action'])){
|
if (isset($data['update-action'])) {
|
||||||
if($data['update-action'] === 'save-travel-company-service'){
|
if ($data['update-action'] === 'save-travel-company-service') {
|
||||||
$data['active'] = true;//isset($data['active']) ? true : false;
|
$data['active'] = true; //isset($data['active']) ? true : false;
|
||||||
$travel_company = TravelCompany::findOrFail($id);
|
$travel_company = TravelCompany::findOrFail($id);
|
||||||
$data['travel_company_id'] = $travel_company->id;
|
$data['travel_company_id'] = $travel_company->id;
|
||||||
|
|
||||||
if($data['travel_company_service_id'] === 'new'){
|
if ($data['travel_company_service_id'] === 'new') {
|
||||||
$model = TravelCompanyService::create($data);
|
$model = TravelCompanyService::create($data);
|
||||||
}else{
|
} else {
|
||||||
$model = TravelCompanyService::find($data['travel_company_service_id']);
|
$model = TravelCompanyService::find($data['travel_company_service_id']);
|
||||||
$model->fill($data);
|
$model->fill($data);
|
||||||
$model->save();
|
$model->save();
|
||||||
|
|
@ -69,9 +70,9 @@ class TravelCompanyController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
|
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
|
||||||
if($id === "new"){
|
if ($id === "new") {
|
||||||
$model = TravelCompany::create($data);
|
$model = TravelCompany::create($data);
|
||||||
}else{
|
} else {
|
||||||
$model = TravelCompany::find($id);
|
$model = TravelCompany::find($id);
|
||||||
$model->fill($data);
|
$model->fill($data);
|
||||||
$model->save();
|
$model->save();
|
||||||
|
|
@ -79,12 +80,12 @@ class TravelCompanyController extends Controller
|
||||||
|
|
||||||
\Session()->flash('alert-save', '1');
|
\Session()->flash('alert-save', '1');
|
||||||
return redirect(route('admin_settings_travel_company_detail', [$model->id, $data['action']]));
|
return redirect(route('admin_settings_travel_company_detail', [$model->id, $data['action']]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id, $del="travel_company"){
|
public function delete($id, $del = "travel_company")
|
||||||
|
{
|
||||||
|
|
||||||
if($del === 'travel_country') {
|
if ($del === 'travel_country') {
|
||||||
abort(404, 'Noch keine Funktion');
|
abort(404, 'Noch keine Funktion');
|
||||||
$model = TravelCompany::findOrFail($id);
|
$model = TravelCompany::findOrFail($id);
|
||||||
$model->delete();
|
$model->delete();
|
||||||
|
|
@ -92,11 +93,11 @@ class TravelCompanyController extends Controller
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($del === 'company_service'){
|
if ($del === 'company_service') {
|
||||||
$service = TravelCompanyService::findOrFail($id);
|
$service = TravelCompanyService::findOrFail($id);
|
||||||
$travel_company = $service->travel_company;
|
$travel_company = $service->travel_company;
|
||||||
//check as entry
|
//check as entry
|
||||||
if($service->booking_company_services->count() > 0){
|
if ($service->booking_company_services->count() > 0) {
|
||||||
\Session()->flash('alert-error', 'Die Leistung kann nicht gelöscht werden, diese hat Einträge bei den Buchungen');
|
\Session()->flash('alert-error', 'Die Leistung kann nicht gelöscht werden, diese hat Einträge bei den Buchungen');
|
||||||
return redirect(route('admin_settings_travel_company_detail', [$travel_company->id, 'services']));
|
return redirect(route('admin_settings_travel_company_detail', [$travel_company->id, 'services']));
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +106,4 @@ class TravelCompanyController extends Controller
|
||||||
return redirect(route('admin_settings_travel_company_detail', [$travel_company->id, 'services']));
|
return redirect(route('admin_settings_travel_company_detail', [$travel_company->id, 'services']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,11 @@ class TravelCountryController extends Controller
|
||||||
|
|
||||||
public function detail($id, $step = false)
|
public function detail($id, $step = false)
|
||||||
{
|
{
|
||||||
if($id === "new") {
|
if ($id == "new") {
|
||||||
$model = new TravelCountry();
|
$model = new TravelCountry();
|
||||||
$id = 'new';
|
$id = 'new';
|
||||||
$model->active_backend = 1;
|
$model->active_backend = 1;
|
||||||
}else{
|
} else {
|
||||||
$model = TravelCountry::findOrFail($id);
|
$model = TravelCountry::findOrFail($id);
|
||||||
$id = $model->id;
|
$id = $model->id;
|
||||||
}
|
}
|
||||||
|
|
@ -62,15 +62,15 @@ class TravelCountryController extends Controller
|
||||||
{
|
{
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
|
|
||||||
if(isset($data['update-action'])){
|
if (isset($data['update-action'])) {
|
||||||
if($data['update-action'] === 'save-travel-county-service'){
|
if ($data['update-action'] === 'save-travel-county-service') {
|
||||||
$data['active'] = true;//isset($data['active']) ? true : false;
|
$data['active'] = true; //isset($data['active']) ? true : false;
|
||||||
$travel_country = TravelCountry::findOrFail($id);
|
$travel_country = TravelCountry::findOrFail($id);
|
||||||
$data['travel_country_id'] = $travel_country->id;
|
$data['travel_country_id'] = $travel_country->id;
|
||||||
$data['crm_travel_country_id'] = $travel_country->crm_id;
|
$data['crm_travel_country_id'] = $travel_country->crm_id;
|
||||||
if($data['travel_county_service_id'] === 'new'){
|
if ($data['travel_county_service_id'] === 'new') {
|
||||||
$model = TravelCountryService::create($data);
|
$model = TravelCountryService::create($data);
|
||||||
}else{
|
} else {
|
||||||
$model = TravelCountryService::find($data['travel_county_service_id']);
|
$model = TravelCountryService::find($data['travel_county_service_id']);
|
||||||
$model->fill($data);
|
$model->fill($data);
|
||||||
$model->save();
|
$model->save();
|
||||||
|
|
@ -81,7 +81,7 @@ class TravelCountryController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
|
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
|
||||||
if(!isset($data['contact_lands'])){
|
if (!isset($data['contact_lands'])) {
|
||||||
$data['contact_lands'] = null;
|
$data['contact_lands'] = null;
|
||||||
}
|
}
|
||||||
$data['action'] = isset($data['action']) ? $data['action'] : false;
|
$data['action'] = isset($data['action']) ? $data['action'] : false;
|
||||||
|
|
@ -90,9 +90,9 @@ class TravelCountryController extends Controller
|
||||||
$data['active_frontend'] = isset($data['active_frontend']) ? true : false;
|
$data['active_frontend'] = isset($data['active_frontend']) ? true : false;
|
||||||
$data['active_backend'] = isset($data['active_backend']) ? true : false;
|
$data['active_backend'] = isset($data['active_backend']) ? true : false;
|
||||||
*/
|
*/
|
||||||
if($id === "new"){
|
if ($id === "new") {
|
||||||
$model = TravelCountry::create($data);
|
$model = TravelCountry::create($data);
|
||||||
}else{
|
} else {
|
||||||
$model = TravelCountry::find($id);
|
$model = TravelCountry::find($id);
|
||||||
$model->fill($data);
|
$model->fill($data);
|
||||||
$model->save();
|
$model->save();
|
||||||
|
|
@ -106,11 +106,11 @@ class TravelCountryController extends Controller
|
||||||
}
|
}
|
||||||
//TODO for this time
|
//TODO for this time
|
||||||
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
|
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
|
||||||
if(!$tc){
|
if (!$tc) {
|
||||||
$tc = \App\Models\Sym\TravelCountry::create($data);
|
$tc = \App\Models\Sym\TravelCountry::create($data);
|
||||||
$model->crm_id = $tc->id;
|
$model->crm_id = $tc->id;
|
||||||
$model->save();
|
$model->save();
|
||||||
}else {
|
} else {
|
||||||
$tc->fill($data);
|
$tc->fill($data);
|
||||||
$tc->save();
|
$tc->save();
|
||||||
}
|
}
|
||||||
|
|
@ -119,17 +119,18 @@ class TravelCountryController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function delete($id, $del="travel_country"){
|
public function delete($id, $del = "travel_country")
|
||||||
|
{
|
||||||
|
|
||||||
if($del === 'travel_country'){
|
if ($del === 'travel_country') {
|
||||||
$model = TravelCountry::findOrFail($id);
|
$model = TravelCountry::findOrFail($id);
|
||||||
if($model->travel_nationality_requirements){
|
if ($model->travel_nationality_requirements) {
|
||||||
foreach($model->travel_nationality_requirements as $travel_nationality_requirement){
|
foreach ($model->travel_nationality_requirements as $travel_nationality_requirement) {
|
||||||
$travel_nationality_requirement->delete();
|
$travel_nationality_requirement->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
|
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
|
||||||
if($tc){
|
if ($tc) {
|
||||||
$tc->delete();
|
$tc->delete();
|
||||||
}
|
}
|
||||||
$model->delete();
|
$model->delete();
|
||||||
|
|
@ -137,7 +138,7 @@ class TravelCountryController extends Controller
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($del === 'general_file'){
|
if ($del === 'general_file') {
|
||||||
$general_file = GeneralFile::findOrFail($id);
|
$general_file = GeneralFile::findOrFail($id);
|
||||||
$travel_country = $general_file->travel_country;
|
$travel_country = $general_file->travel_country;
|
||||||
$fileRepo = new GeneralFileRepository($general_file);
|
$fileRepo = new GeneralFileRepository($general_file);
|
||||||
|
|
@ -146,23 +147,18 @@ class TravelCountryController extends Controller
|
||||||
$general_file->delete();
|
$general_file->delete();
|
||||||
\Session()->flash('alert-success', 'Datei gelöscht');
|
\Session()->flash('alert-success', 'Datei gelöscht');
|
||||||
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'data']));
|
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'data']));
|
||||||
|
|
||||||
}
|
}
|
||||||
if($del === 'country_service'){
|
if ($del === 'country_service') {
|
||||||
$travel_country_service = TravelCountryService::findOrFail($id);
|
$travel_country_service = TravelCountryService::findOrFail($id);
|
||||||
$travel_country = $travel_country_service->travel_country;
|
$travel_country = $travel_country_service->travel_country;
|
||||||
//check as entry
|
//check as entry
|
||||||
if($travel_country_service->booking_country_services->count() > 0){
|
if ($travel_country_service->booking_country_services->count() > 0) {
|
||||||
\Session()->flash('alert-error', 'Die Leistung kann nicht gelöscht werden, diese hat Einträge bei den Buchungen');
|
\Session()->flash('alert-error', 'Die Leistung kann nicht gelöscht werden, diese hat Einträge bei den Buchungen');
|
||||||
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'services']));
|
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'services']));
|
||||||
}
|
}
|
||||||
$travel_country_service->delete();
|
$travel_country_service->delete();
|
||||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||||
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'services']));
|
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'services']));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Libraries;
|
namespace App\Libraries;
|
||||||
|
|
||||||
//use FPDI in myMerge v2
|
//use FPDI in myMerge v2
|
||||||
|
|
@ -10,10 +11,10 @@ class MyPDFMerger
|
||||||
private $_files; //['form.pdf'] ["1,2,4, 5-19"]
|
private $_files; //['form.pdf'] ["1,2,4, 5-19"]
|
||||||
private $_fpdi;
|
private $_fpdi;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
/* if(!class_exists("FPDF")) {
|
/* if(!class_exists("FPDF")) {
|
||||||
require_once(__DIR__.'/fpdf/fpdf.php');
|
require_once(__DIR__.'/fpdf/fpdf.php');
|
||||||
}
|
}
|
||||||
if(!class_exists("FPDI")) {
|
if(!class_exists("FPDI")) {
|
||||||
|
|
@ -39,12 +40,14 @@ class MyPDFMerger
|
||||||
|
|
||||||
public function myMerge($outputmode = 'browser', $outputpath = 'newfile.pdf', $theme = false)
|
public function myMerge($outputmode = 'browser', $outputpath = 'newfile.pdf', $theme = false)
|
||||||
{
|
{
|
||||||
if (!isset($this->_files) || !is_array($this->_files)): throw new \exception("No PDFs to merge."); endif;
|
//$theme = false;
|
||||||
|
if (!isset($this->_files) || !is_array($this->_files)): throw new \exception("No PDFs to merge.");
|
||||||
|
endif;
|
||||||
|
|
||||||
$fpdi = new \setasign\Fpdi\Fpdi();
|
$fpdi = new \setasign\Fpdi\Fpdi();
|
||||||
$first = 1;
|
$first = 1;
|
||||||
|
|
||||||
//
|
|
||||||
//merger operations
|
//merger operations
|
||||||
foreach ($this->_files as $file) {
|
foreach ($this->_files as $file) {
|
||||||
$filename = $file[0];
|
$filename = $file[0];
|
||||||
|
|
@ -60,30 +63,29 @@ class MyPDFMerger
|
||||||
$template = $fpdi->importPage($i);
|
$template = $fpdi->importPage($i);
|
||||||
$size = $fpdi->getTemplateSize($template);
|
$size = $fpdi->getTemplateSize($template);
|
||||||
$orientation = ($size['height'] > $size['width']) ? 'P' : 'L';
|
$orientation = ($size['height'] > $size['width']) ? 'P' : 'L';
|
||||||
|
|
||||||
$fpdi->AddPage($orientation, array($size['width'], $size['height']));
|
$fpdi->AddPage($orientation, array($size['width'], $size['height']));
|
||||||
if($theme){
|
if ($theme) {
|
||||||
$fpdi->setSourceFile(__DIR__ . '/../../public/pdf/'.$theme.'-'.$first.'.pdf');
|
$fpdi->setSourceFile(__DIR__ . '/../../public/pdf/' . $theme . '-' . $first . '.pdf');
|
||||||
if($first == 1){
|
if ($first == 1) {
|
||||||
$first = 2;
|
$first = 2;
|
||||||
}
|
}
|
||||||
$backId = $fpdi->importPage(1);
|
$backId = $fpdi->importPage(1);
|
||||||
$fpdi->useTemplate($backId);
|
$fpdi->useTemplate($backId);
|
||||||
|
|
||||||
}
|
}
|
||||||
$fpdi->useTemplate($template);
|
$fpdi->useTemplate($template);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($filepages as $page) {
|
foreach ($filepages as $page) {
|
||||||
$count = $fpdi->setSourceFile($filename);
|
$count = $fpdi->setSourceFile($filename);
|
||||||
if (!$template = $fpdi->importPage($page)): throw new \exception("Could not load page '$page' in PDF '$filename'. Check that the page exists."); endif;
|
if (!$template = $fpdi->importPage($page)): throw new \exception("Could not load page '$page' in PDF '$filename'. Check that the page exists.");
|
||||||
|
endif;
|
||||||
$size = $fpdi->getTemplateSize($template);
|
$size = $fpdi->getTemplateSize($template);
|
||||||
$orientation = ($size['h'] > $size['w']) ? 'P' : 'L';
|
$orientation = ($size['h'] > $size['w']) ? 'P' : 'L';
|
||||||
|
|
||||||
$fpdi->AddPage($orientation, array($size['w'], $size['h']));
|
$fpdi->AddPage($orientation, array($size['w'], $size['h']));
|
||||||
if($theme){
|
if ($theme) {
|
||||||
$fpdi->setSourceFile(__DIR__ . '/../../public/pdf/'.$theme.'-'.$first.'.pdf');
|
$fpdi->setSourceFile(__DIR__ . '/../../public/pdf/' . $theme . '-' . $first . '.pdf');
|
||||||
if($first == 1){
|
if ($first == 1) {
|
||||||
$first = 2;
|
$first = 2;
|
||||||
}
|
}
|
||||||
$backId = $fpdi->importPage(1);
|
$backId = $fpdi->importPage(1);
|
||||||
|
|
@ -110,11 +112,9 @@ class MyPDFMerger
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FPDI uses single characters for specifying the output location. Change our more descriptive string into proper format.
|
* FPDI uses single characters for specifying the output location. Change our more descriptive string into proper format.
|
||||||
* @param $mode
|
* @param $mode
|
||||||
* @return Character
|
* @return Character
|
||||||
|
|
@ -140,7 +140,7 @@ class MyPDFMerger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes our provided pages in the form of 1,3,4,16-50 and creates an array of all pages
|
* Takes our provided pages in the form of 1,3,4,16-50 and creates an array of all pages
|
||||||
* @param $pages
|
* @param $pages
|
||||||
* @return array
|
* @return array
|
||||||
|
|
@ -160,11 +160,13 @@ class MyPDFMerger
|
||||||
$y = $ind[1]; //end page
|
$y = $ind[1]; //end page
|
||||||
|
|
||||||
if ($x > $y): throw new \exception("Starting page, '$x' is greater than ending page '$y'.");
|
if ($x > $y): throw new \exception("Starting page, '$x' is greater than ending page '$y'.");
|
||||||
return false; endif;
|
return false;
|
||||||
|
endif;
|
||||||
|
|
||||||
//add middle pages
|
//add middle pages
|
||||||
while ($x <= $y): $newpages[] = (int)$x;
|
while ($x <= $y): $newpages[] = (int)$x;
|
||||||
$x++; endwhile;
|
$x++;
|
||||||
|
endwhile;
|
||||||
} else {
|
} else {
|
||||||
$newpages[] = (int)$ind[0];
|
$newpages[] = (int)$ind[0];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -207,27 +207,27 @@ class Booking extends Model
|
||||||
|
|
||||||
protected $table = 'booking';
|
protected $table = 'booking';
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'customer_id' => 'int',
|
'customer_id' => 'int',
|
||||||
'lead_id' => 'int',
|
'lead_id' => 'int',
|
||||||
'new_drafts' => 'bool',
|
'new_drafts' => 'bool',
|
||||||
'sf_guard_user_id' => 'int',
|
'sf_guard_user_id' => 'int',
|
||||||
'branch_id' => 'int',
|
'branch_id' => 'int',
|
||||||
'airport_id' => 'int',
|
'airport_id' => 'int',
|
||||||
'service_fee' => 'float',
|
'service_fee' => 'float',
|
||||||
'travel_country_id' => 'int',
|
'travel_country_id' => 'int',
|
||||||
'travel_category_id' => 'int',
|
'travel_category_id' => 'int',
|
||||||
'pax' => 'int',
|
'pax' => 'int',
|
||||||
'coupon_id' => 'int',
|
'coupon_id' => 'int',
|
||||||
'website_id' => 'int',
|
'website_id' => 'int',
|
||||||
'participant_salutation_id' => 'int',
|
'participant_salutation_id' => 'int',
|
||||||
'travel_company_id' => 'int',
|
'travel_company_id' => 'int',
|
||||||
'travel_documents' => 'bool',
|
'travel_documents' => 'bool',
|
||||||
'price' => 'float',
|
'price' => 'float',
|
||||||
'price_total' => 'float',
|
'price_total' => 'float',
|
||||||
'deposit_total' => 'float',
|
'deposit_total' => 'float',
|
||||||
'final_payment' => 'float',
|
'final_payment' => 'float',
|
||||||
'travelagenda_id' => 'int',
|
'travelagenda_id' => 'int',
|
||||||
'paying_out' => 'int',
|
'paying_out' => 'int',
|
||||||
'hold' => 'int',
|
'hold' => 'int',
|
||||||
//'airline_id' => 'int',
|
//'airline_id' => 'int',
|
||||||
|
|
@ -240,55 +240,55 @@ class Booking extends Model
|
||||||
'participant_pass' => 'bool'
|
'participant_pass' => 'bool'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $dates = [
|
protected $dates = [
|
||||||
'booking_date',
|
'booking_date',
|
||||||
'start_date',
|
'start_date',
|
||||||
'end_date',
|
'end_date',
|
||||||
'participant_birthdate',
|
'participant_birthdate',
|
||||||
'final_payment_date',
|
'final_payment_date',
|
||||||
'refund_date',
|
'refund_date',
|
||||||
'lawyer_date',
|
'lawyer_date',
|
||||||
'xx_tkt_date'
|
'xx_tkt_date'
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'booking_date',
|
'booking_date',
|
||||||
'customer_id',
|
'customer_id',
|
||||||
'lead_id',
|
'lead_id',
|
||||||
'new_drafts',
|
'new_drafts',
|
||||||
'sf_guard_user_id',
|
'sf_guard_user_id',
|
||||||
'branch_id',
|
'branch_id',
|
||||||
'service_fee',
|
'service_fee',
|
||||||
'travel_country_id',
|
'travel_country_id',
|
||||||
'travel_category_id',
|
'travel_category_id',
|
||||||
'pax',
|
'pax',
|
||||||
'coupon_id',
|
'coupon_id',
|
||||||
'title',
|
'title',
|
||||||
'comfort',
|
'comfort',
|
||||||
'start_date',
|
'start_date',
|
||||||
'end_date',
|
'end_date',
|
||||||
'website_id',
|
'website_id',
|
||||||
'travel_number',
|
'travel_number',
|
||||||
'participant_name',
|
'participant_name',
|
||||||
'participant_firstname',
|
'participant_firstname',
|
||||||
'participant_birthdate',
|
'participant_birthdate',
|
||||||
'participant_salutation_id',
|
'participant_salutation_id',
|
||||||
'participant_pass',
|
'participant_pass',
|
||||||
'nationality_id',
|
'nationality_id',
|
||||||
'ev_number',
|
'ev_number',
|
||||||
'merlin_knr',
|
'merlin_knr',
|
||||||
'merlin_order_number',
|
'merlin_order_number',
|
||||||
'travel_company_id',
|
'travel_company_id',
|
||||||
'travel_documents',
|
'travel_documents',
|
||||||
'price',
|
'price',
|
||||||
'price_canceled',
|
'price_canceled',
|
||||||
'price_total',
|
'price_total',
|
||||||
'price_balance',
|
'price_balance',
|
||||||
'deposit_total',
|
'deposit_total',
|
||||||
'final_payment',
|
'final_payment',
|
||||||
'final_payment_date',
|
'final_payment_date',
|
||||||
'travelagenda_id',
|
'travelagenda_id',
|
||||||
'insurance_offer',
|
'insurance_offer',
|
||||||
'paying_out',
|
'paying_out',
|
||||||
'paying_out_status',
|
'paying_out_status',
|
||||||
|
|
@ -304,10 +304,10 @@ class Booking extends Model
|
||||||
'filekey',
|
'filekey',
|
||||||
'is_rail_fly',
|
'is_rail_fly',
|
||||||
'notice',
|
'notice',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $paying_out_types = [
|
public static $paying_out_types = [
|
||||||
0 => '-',
|
0 => '-',
|
||||||
1 => 'Gutschein',
|
1 => 'Gutschein',
|
||||||
2 => 'Auszahlung',
|
2 => 'Auszahlung',
|
||||||
3 => 'Umbuchung',
|
3 => 'Umbuchung',
|
||||||
|
|
@ -345,8 +345,8 @@ class Booking extends Model
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $customer_mail_dirs = [
|
public static $customer_mail_dirs = [
|
||||||
11 => ['name' => 'Entwürfe', 'icon'=>'ion-md-create'],
|
11 => ['name' => 'Entwürfe', 'icon' => 'ion-md-create'],
|
||||||
12 => ['name' => 'Papierkorb', 'icon'=>'ion-md-trash'],
|
12 => ['name' => 'Papierkorb', 'icon' => 'ion-md-trash'],
|
||||||
];
|
];
|
||||||
protected $paying_out_colors = [
|
protected $paying_out_colors = [
|
||||||
0 => '',
|
0 => '',
|
||||||
|
|
@ -377,47 +377,47 @@ class Booking extends Model
|
||||||
|
|
||||||
protected $passolutionPDFs = [];
|
protected $passolutionPDFs = [];
|
||||||
|
|
||||||
/*public function branch()
|
/*public function branch()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Branch::class);
|
return $this->belongsTo(Branch::class);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public function coupon()
|
public function coupon()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Coupon::class);
|
return $this->belongsTo(Coupon::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function customer()
|
public function customer()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Customer::class);
|
return $this->belongsTo(Customer::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function lead()
|
public function lead()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Lead::class);
|
return $this->belongsTo(Lead::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sf_guard_user()
|
public function sf_guard_user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(SfGuardUser::class);
|
return $this->belongsTo(SfGuardUser::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function travel_category()
|
public function travel_category()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(TravelCategory::class);
|
return $this->belongsTo(TravelCategory::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function travel_company()
|
public function travel_company()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(TravelCompany::class);
|
return $this->belongsTo(TravelCompany::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function airport()
|
public function airport()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Airport::class, 'airport_id');
|
return $this->belongsTo(Airport::class, 'airport_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public function travel_country()
|
/* public function travel_country()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(TravelCountry::class, 'travel_country_id', 'crm_id');
|
return $this->belongsTo(TravelCountry::class, 'travel_country_id', 'crm_id');
|
||||||
}*/
|
}*/
|
||||||
|
|
@ -428,64 +428,64 @@ class Booking extends Model
|
||||||
return $this->belongsTo(\App\Models\Sym\TravelCountry::class, 'travel_country_id', 'id');
|
return $this->belongsTo(\App\Models\Sym\TravelCountry::class, 'travel_country_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function travel_agenda()
|
public function travel_agenda()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(TravelAgenda::class, 'travelagenda_id');
|
return $this->belongsTo(TravelAgenda::class, 'travelagenda_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public function airline()
|
/*public function airline()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Airline::class, 'airline_id');
|
return $this->belongsTo(Airline::class, 'airline_id');
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function arrangements()
|
public function arrangements()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Arrangement::class);
|
return $this->hasMany(Arrangement::class)->orderBy('view_position', 'DESC');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function arrangement_types()
|
public function arrangement_types()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ArrangementType::class);
|
return $this->hasMany(ArrangementType::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function booking_draft_items()
|
public function booking_draft_items()
|
||||||
{
|
{
|
||||||
return $this->hasMany(BookingDraftItem::class)->orderBy('pos', 'ASC');
|
return $this->hasMany(BookingDraftItem::class)->orderBy('pos', 'ASC');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function booking_service_items()
|
public function booking_service_items()
|
||||||
{
|
{
|
||||||
return $this->hasMany(BookingServiceItem::class);
|
return $this->hasMany(BookingServiceItem::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function coupons()
|
public function coupons()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Coupon::class);
|
return $this->hasMany(Coupon::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function insurance_certificates()
|
public function insurance_certificates()
|
||||||
{
|
{
|
||||||
return $this->hasMany(InsuranceCertificate::class);
|
return $this->hasMany(InsuranceCertificate::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function participants()
|
public function participants()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Participant::class);
|
return $this->hasMany(Participant::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function participant_salutation()
|
public function participant_salutation()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Salutation::class, 'participant_salutation_id');
|
return $this->belongsTo(Salutation::class, 'participant_salutation_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function service_provider_entries()
|
public function service_provider_entries()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ServiceProviderEntry::class);
|
return $this->hasMany(ServiceProviderEntry::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function customer_mails()
|
public function customer_mails()
|
||||||
|
|
@ -519,9 +519,9 @@ class Booking extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
public function booking_stornos()
|
public function booking_stornos()
|
||||||
{
|
{
|
||||||
return $this->hasMany(BookingStorno::class);
|
return $this->hasMany(BookingStorno::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public function booking_invoices()
|
/*public function booking_invoices()
|
||||||
{
|
{
|
||||||
|
|
@ -529,19 +529,19 @@ class Booking extends Model
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
public function booking_vouchers()
|
public function booking_vouchers()
|
||||||
{
|
{
|
||||||
return $this->hasMany(BookingVoucher::class);
|
return $this->hasMany(BookingVoucher::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function booking_voucher_agencys()
|
public function booking_voucher_agencys()
|
||||||
{
|
{
|
||||||
return $this->hasMany(BookingVoucherAgency::class);
|
return $this->hasMany(BookingVoucherAgency::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function travel_insurances()
|
public function travel_insurances()
|
||||||
{
|
{
|
||||||
return $this->hasMany(TravelInsurance::class);
|
return $this->hasMany(TravelInsurance::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function booking_files()
|
public function booking_files()
|
||||||
{
|
{
|
||||||
|
|
@ -592,17 +592,17 @@ class Booking extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
public function booking_strono()
|
public function booking_strono()
|
||||||
{
|
{
|
||||||
return $this->hasOne(BookingStorno::class);
|
return $this->hasOne(BookingStorno::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAirlinesAsNames()
|
public function getAirlinesAsNames()
|
||||||
{
|
{
|
||||||
$ret = "";
|
$ret = "";
|
||||||
if($this->airline_ids){
|
if ($this->airline_ids) {
|
||||||
foreach($this->airline_ids as $airline_id){
|
foreach ($this->airline_ids as $airline_id) {
|
||||||
if($Airline = Airline::find($airline_id)){
|
if ($Airline = Airline::find($airline_id)) {
|
||||||
$ret .= $Airline->name." ";
|
$ret .= $Airline->name . " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -610,13 +610,13 @@ class Booking extends Model
|
||||||
}
|
}
|
||||||
public function getAirlinesIds()
|
public function getAirlinesIds()
|
||||||
{
|
{
|
||||||
if($this->airline_ids){
|
if ($this->airline_ids) {
|
||||||
return implode('', $this->airline_ids);
|
return implode('', $this->airline_ids);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
}
|
}
|
||||||
public function hasBookingServicesUnchecked(){
|
public function hasBookingServicesUnchecked()
|
||||||
|
{
|
||||||
$country_services = true;
|
$country_services = true;
|
||||||
$provider_services = true;
|
$provider_services = true;
|
||||||
$company_services = true;
|
$company_services = true;
|
||||||
|
|
@ -625,101 +625,102 @@ class Booking extends Model
|
||||||
$has_provider_services = false;
|
$has_provider_services = false;
|
||||||
$has_company_services = false;
|
$has_company_services = false;
|
||||||
|
|
||||||
if($this->travel_country){
|
if ($this->travel_country) {
|
||||||
foreach($this->travel_country->getContactLandsModels() as $TravelCountry){
|
foreach ($this->travel_country->getContactLandsModels() as $TravelCountry) {
|
||||||
if($TravelCountry->stern_travel_country){
|
if ($TravelCountry->stern_travel_country) {
|
||||||
if($TravelCountry->stern_travel_country->travel_country_services->count()){
|
if ($TravelCountry->stern_travel_country->travel_country_services->count()) {
|
||||||
$has_country_services = true;
|
$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;
|
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->service_provider_entries as $service_provider_entry){
|
foreach ($this->service_provider_entries as $service_provider_entry) {
|
||||||
if($service_provider_entry->service_provider && $service_provider_entry->service_provider->service_provider_services->count()){
|
if ($service_provider_entry->service_provider && $service_provider_entry->service_provider->service_provider_services->count()) {
|
||||||
$has_provider_services = true;
|
$has_provider_services = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($has_provider_services && !$this->booking_provider_services->count() || $this->booking_provider_services_checked->count()){
|
if ($has_provider_services && !$this->booking_provider_services->count() || $this->booking_provider_services_checked->count()) {
|
||||||
if($this->service_provider_entries->count()){
|
if ($this->service_provider_entries->count()) {
|
||||||
$provider_services = false;
|
$provider_services = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->booking_service_items as $booking_service_item){
|
foreach ($this->booking_service_items as $booking_service_item) {
|
||||||
if($booking_service_item->travel_company && $booking_service_item->travel_company->travel_company_services->count()){
|
if ($booking_service_item->travel_company && $booking_service_item->travel_company->travel_company_services->count()) {
|
||||||
$has_company_services = true;
|
$has_company_services = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($has_company_services && !$this->booking_company_services->count() || $this->booking_company_services_checked->count()){
|
if ($has_company_services && !$this->booking_company_services->count() || $this->booking_company_services_checked->count()) {
|
||||||
if($this->booking_service_items->count()){
|
if ($this->booking_service_items->count()) {
|
||||||
$company_services = false;
|
$company_services = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$has_country_services && !$has_provider_services && !$has_company_services){
|
if (!$has_country_services && !$has_provider_services && !$has_company_services) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($country_services && $provider_services && $company_services){
|
if ($country_services && $provider_services && $company_services) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasBookingParticipantsPass(){
|
public function hasBookingParticipantsPass()
|
||||||
if($this->participant_firstname){
|
{
|
||||||
if(!$this->participant_pass){
|
if ($this->participant_firstname) {
|
||||||
|
if (!$this->participant_pass) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($this->participants->count()){
|
if ($this->participants->count()) {
|
||||||
foreach($this->participants as $participant){
|
foreach ($this->participants as $participant) {
|
||||||
if(!$participant->participant_pass){
|
if (!$participant->participant_pass) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getPassolutionPDF($create = false, $resync = false){
|
|
||||||
|
public function getPassolutionPDF($create = false, $resync = false)
|
||||||
|
{
|
||||||
|
|
||||||
$nats = [];
|
$nats = [];
|
||||||
|
|
||||||
if(count($this->passolutionPDFs)){
|
if (count($this->passolutionPDFs)) {
|
||||||
return $this->passolutionPDFs;
|
return $this->passolutionPDFs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->travel_country){
|
if (!$this->travel_country) {
|
||||||
return $this->passolutionPDFs;
|
return $this->passolutionPDFs;
|
||||||
}
|
}
|
||||||
|
|
||||||
$destco = $this->travel_country->destco;
|
$destco = $this->travel_country->destco;
|
||||||
if($this->travel_nationality){
|
if ($this->travel_nationality) {
|
||||||
$nats[$this->travel_nationality->nat] = $this->travel_nationality->nat;
|
$nats[$this->travel_nationality->nat] = $this->travel_nationality->nat;
|
||||||
}
|
}
|
||||||
if($this->participants->count()){
|
if ($this->participants->count()) {
|
||||||
foreach ($this->participants as $participant){
|
foreach ($this->participants as $participant) {
|
||||||
if($participant->travel_nationality){
|
if ($participant->travel_nationality) {
|
||||||
$nats[$participant->travel_nationality->nat] = $participant->travel_nationality->nat;
|
$nats[$participant->travel_nationality->nat] = $participant->travel_nationality->nat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($nats)){
|
if (empty($nats)) {
|
||||||
$nats['de'] = 'de';
|
$nats['de'] = 'de';
|
||||||
}
|
}
|
||||||
foreach ($nats as $nat){
|
foreach ($nats as $nat) {
|
||||||
$data = [
|
$data = [
|
||||||
'nat' => $nat,
|
'nat' => $nat,
|
||||||
'destco' => $destco,
|
'destco' => $destco,
|
||||||
|
|
@ -728,11 +729,12 @@ class Booking extends Model
|
||||||
$passolution = new Passolution($data);
|
$passolution = new Passolution($data);
|
||||||
$this->passolutionPDFs[] = $passolution->findOrCreatePDF($create, $resync);
|
$this->passolutionPDFs[] = $passolution->findOrCreatePDF($create, $resync);
|
||||||
}
|
}
|
||||||
return $this->passolutionPDFs;
|
return $this->passolutionPDFs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resyncPassolutionPDF(){
|
public function resyncPassolutionPDF()
|
||||||
return $this->getPassolutionPDF(true, true);
|
{
|
||||||
|
return $this->getPassolutionPDF(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calculate_price_total()
|
public function calculate_price_total()
|
||||||
|
|
@ -746,13 +748,13 @@ class Booking extends Model
|
||||||
$travel_children = 0;
|
$travel_children = 0;
|
||||||
foreach ($this->booking_draft_items as $booking_draft_item) {
|
foreach ($this->booking_draft_items as $booking_draft_item) {
|
||||||
//24 Rundreise ist der Grundeintrag für die Reise
|
//24 Rundreise ist der Grundeintrag für die Reise
|
||||||
if($booking_draft_item->draft_type_id == 24){
|
if ($booking_draft_item->draft_type_id == 24) {
|
||||||
$travel_draft_item = $booking_draft_item;
|
$travel_draft_item = $booking_draft_item;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$prices = $booking_draft_item->getItemPrice();
|
$prices = $booking_draft_item->getItemPrice();
|
||||||
//Grundpreis Reise //pro Persopn im Zimmer
|
//Grundpreis Reise //pro Persopn im Zimmer
|
||||||
if($booking_draft_item->draft_type_id == 30){
|
if ($booking_draft_item->draft_type_id == 30) {
|
||||||
$travel_price_adult += $prices['adult'];
|
$travel_price_adult += $prices['adult'];
|
||||||
$travel_price_children += $prices['children'];
|
$travel_price_children += $prices['children'];
|
||||||
$travel_adult += $booking_draft_item->adult;
|
$travel_adult += $booking_draft_item->adult;
|
||||||
|
|
@ -762,9 +764,9 @@ class Booking extends Model
|
||||||
$total_children += $prices['children'];
|
$total_children += $prices['children'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($travel_draft_item){
|
|
||||||
|
if ($travel_draft_item) {
|
||||||
$travel_draft_item->setPriceAdultRaw($travel_price_adult);
|
$travel_draft_item->setPriceAdultRaw($travel_price_adult);
|
||||||
$travel_draft_item->setPriceChildrenRaw($travel_price_children);
|
$travel_draft_item->setPriceChildrenRaw($travel_price_children);
|
||||||
$travel_draft_item->adult = $travel_adult;
|
$travel_draft_item->adult = $travel_adult;
|
||||||
|
|
@ -774,7 +776,6 @@ class Booking extends Model
|
||||||
$this->price = $total_adult + $total_children;
|
$this->price = $total_adult + $total_children;
|
||||||
$this->price_total = $this->getPriceRaw() + $this->getServiceTotal(true);
|
$this->price_total = $this->getPriceRaw() + $this->getServiceTotal(true);
|
||||||
$this->save();
|
$this->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPriceAttribute()
|
public function getPriceAttribute()
|
||||||
|
|
@ -845,7 +846,7 @@ class Booking extends Model
|
||||||
public function findBeforeDraftItemRelation($reid)
|
public function findBeforeDraftItemRelation($reid)
|
||||||
{
|
{
|
||||||
$before = false;
|
$before = false;
|
||||||
foreach($this->booking_draft_items as $booking_draft_items) {
|
foreach ($this->booking_draft_items as $booking_draft_items) {
|
||||||
if ($booking_draft_items->id == $reid) {
|
if ($booking_draft_items->id == $reid) {
|
||||||
return $before;
|
return $before;
|
||||||
}
|
}
|
||||||
|
|
@ -857,8 +858,8 @@ class Booking extends Model
|
||||||
public function findAfterDraftItemRelation($reid)
|
public function findAfterDraftItemRelation($reid)
|
||||||
{
|
{
|
||||||
$next = false;
|
$next = false;
|
||||||
foreach($this->booking_draft_items as $booking_draft_items) {
|
foreach ($this->booking_draft_items as $booking_draft_items) {
|
||||||
if($next){
|
if ($next) {
|
||||||
return $booking_draft_items;
|
return $booking_draft_items;
|
||||||
}
|
}
|
||||||
if ($booking_draft_items->id == $reid) {
|
if ($booking_draft_items->id == $reid) {
|
||||||
|
|
@ -868,41 +869,54 @@ class Booking extends Model
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStartDateFormat(){
|
public function getStartDateFormat()
|
||||||
if(!$this->attributes['start_date']){ return ""; }
|
{
|
||||||
|
if (!$this->attributes['start_date']) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return Carbon::parse($this->attributes['start_date'])->format(\Util::formatDateDB());
|
return Carbon::parse($this->attributes['start_date'])->format(\Util::formatDateDB());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEndDateFormat(){
|
public function getEndDateFormat()
|
||||||
if(!$this->attributes['end_date']){ return ""; }
|
{
|
||||||
|
if (!$this->attributes['end_date']) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return Carbon::parse($this->attributes['end_date'])->format(\Util::formatDateDB());
|
return Carbon::parse($this->attributes['end_date'])->format(\Util::formatDateDB());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBookingDateFormat(){
|
public function getBookingDateFormat()
|
||||||
if(!$this->attributes['booking_date']){ return ""; }
|
{
|
||||||
|
if (!$this->attributes['booking_date']) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return Carbon::parse($this->attributes['booking_date'])->format(\Util::formatDateDB());
|
return Carbon::parse($this->attributes['booking_date'])->format(\Util::formatDateDB());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFinalPaymentDateFormat(){
|
public function getFinalPaymentDateFormat()
|
||||||
if(!$this->attributes['final_payment_date']){ return ""; }
|
{
|
||||||
|
if (!$this->attributes['final_payment_date']) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return Carbon::parse($this->attributes['final_payment_date'])->format(\Util::formatDateDB());
|
return Carbon::parse($this->attributes['final_payment_date'])->format(\Util::formatDateDB());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isCanceled(){
|
public function isCanceled()
|
||||||
|
{
|
||||||
return ($this->attributes['canceled'] !== null);
|
return ($this->attributes['canceled'] !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
//erlös #getRevenueFactor
|
//erlös #getRevenueFactor
|
||||||
public function proceeds($raw = false){
|
public function proceeds($raw = false)
|
||||||
|
{
|
||||||
$proceeds = $this->attributes['price'] - $this->attributes['price_balance'] - $this->getServiceProviderPaymentsFactorTotal(true);
|
$proceeds = $this->attributes['price'] - $this->attributes['price_balance'] - $this->getServiceProviderPaymentsFactorTotal(true);
|
||||||
return $raw ? $proceeds : Util::_number_format($proceeds);
|
return $raw ? $proceeds : Util::_number_format($proceeds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getServiceTotal($raw = false)
|
public function getServiceTotal($raw = false)
|
||||||
{
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
foreach ($this->booking_service_items as $booking_service_item){
|
foreach ($this->booking_service_items as $booking_service_item) {
|
||||||
$total += $booking_service_item->getServicePriceRaw();
|
$total += $booking_service_item->getServicePriceRaw();
|
||||||
}
|
}
|
||||||
return $raw ? $total : Util::_number_format($total);
|
return $raw ? $total : Util::_number_format($total);
|
||||||
|
|
@ -912,7 +926,7 @@ class Booking extends Model
|
||||||
public function getServiceProviderPaymentsFactorTotal($raw = false)
|
public function getServiceProviderPaymentsFactorTotal($raw = false)
|
||||||
{
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
foreach ($this->service_provider_entries as $entry){
|
foreach ($this->service_provider_entries as $entry) {
|
||||||
$total += $entry->getAmountRaw() / $entry->getFactortRaw();
|
$total += $entry->getAmountRaw() / $entry->getFactortRaw();
|
||||||
}
|
}
|
||||||
return $raw ? $total : Util::_number_format($total);
|
return $raw ? $total : Util::_number_format($total);
|
||||||
|
|
@ -921,15 +935,16 @@ class Booking extends Model
|
||||||
public function getServiceProviderPaymentsTotal($raw = false)
|
public function getServiceProviderPaymentsTotal($raw = false)
|
||||||
{
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
foreach ($this->service_provider_entries as $entry){
|
foreach ($this->service_provider_entries as $entry) {
|
||||||
$total += $entry->getAmountRaw();
|
$total += $entry->getAmountRaw();
|
||||||
}
|
}
|
||||||
return $raw ? $total : Util::_number_format($total);
|
return $raw ? $total : Util::_number_format($total);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getKontoNumber(){
|
public function getKontoNumber()
|
||||||
|
{
|
||||||
|
|
||||||
switch ($this->ev_number){
|
switch ($this->ev_number) {
|
||||||
case 'E01':
|
case 'E01':
|
||||||
return '4011';
|
return '4011';
|
||||||
break;
|
break;
|
||||||
|
|
@ -942,44 +957,48 @@ class Booking extends Model
|
||||||
case 'E04':
|
case 'E04':
|
||||||
return '4014';
|
return '4014';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
return $this->ev_number;
|
return $this->ev_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBookingNumber()
|
public function getBookingNumber()
|
||||||
{
|
{
|
||||||
if ($this->lead)
|
if ($this->lead) {
|
||||||
{
|
|
||||||
return $this->lead->id;
|
return $this->lead->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPayingOutType(){
|
public function getPayingOutType()
|
||||||
|
{
|
||||||
return isset(self::$paying_out_types[$this->paying_out]) ? self::$paying_out_types[$this->paying_out] : '-';
|
return isset(self::$paying_out_types[$this->paying_out]) ? self::$paying_out_types[$this->paying_out] : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInsuranceOfferType(){
|
public function getInsuranceOfferType()
|
||||||
|
{
|
||||||
return isset(self::$insurance_offer_types[$this->insurance_offer]) ? self::$insurance_offer_types[$this->insurance_offer] : '-';
|
return isset(self::$insurance_offer_types[$this->insurance_offer]) ? self::$insurance_offer_types[$this->insurance_offer] : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPayingOutStatusType(){
|
public function getPayingOutStatusType()
|
||||||
|
{
|
||||||
return isset(self::$paying_out_status_types[$this->paying_out_status]) ? self::$paying_out_status_types[$this->paying_out_status] : '-';
|
return isset(self::$paying_out_status_types[$this->paying_out_status]) ? self::$paying_out_status_types[$this->paying_out_status] : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRefundType(){
|
public function getRefundType()
|
||||||
|
{
|
||||||
return isset(self::$refund_types[$this->refund]) ? self::$refund_types[$this->refund] : '-';
|
return isset(self::$refund_types[$this->refund]) ? self::$refund_types[$this->refund] : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getXxTktType(){
|
public function getXxTktType()
|
||||||
|
{
|
||||||
return isset(self::$xx_tkt_types[$this->xx_tkt]) ? self::$xx_tkt_types[$this->xx_tkt] : '-';
|
return isset(self::$xx_tkt_types[$this->xx_tkt]) ? self::$xx_tkt_types[$this->xx_tkt] : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getXxTktTypeList(){
|
public function getXxTktTypeList()
|
||||||
if(isset(self::$xx_tkt_types[$this->xx_tkt])){
|
{
|
||||||
if($this->xx_tkt == 1 && $this->xx_tkt_date){
|
if (isset(self::$xx_tkt_types[$this->xx_tkt])) {
|
||||||
|
if ($this->xx_tkt == 1 && $this->xx_tkt_date) {
|
||||||
return Carbon::parse($this->xx_tkt_date)->format('d.m.Y');
|
return Carbon::parse($this->xx_tkt_date)->format('d.m.Y');
|
||||||
}
|
}
|
||||||
return self::$xx_tkt_types[$this->xx_tkt];
|
return self::$xx_tkt_types[$this->xx_tkt];
|
||||||
|
|
@ -987,9 +1006,10 @@ class Booking extends Model
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRefundTypeList(){
|
public function getRefundTypeList()
|
||||||
if(isset(self::$refund_types[$this->refund])){
|
{
|
||||||
if($this->refund == 1 && $this->refund_date){
|
if (isset(self::$refund_types[$this->refund])) {
|
||||||
|
if ($this->refund == 1 && $this->refund_date) {
|
||||||
return Carbon::parse($this->refund_date)->format('d.m.Y');
|
return Carbon::parse($this->refund_date)->format('d.m.Y');
|
||||||
}
|
}
|
||||||
return self::$refund_types[$this->refund];
|
return self::$refund_types[$this->refund];
|
||||||
|
|
@ -997,57 +1017,65 @@ class Booking extends Model
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPayingOutColor(){
|
public function getPayingOutColor()
|
||||||
|
{
|
||||||
return isset($this->paying_out_colors[$this->paying_out]) ? $this->paying_out_colors[$this->paying_out] : '';
|
return isset($this->paying_out_colors[$this->paying_out]) ? $this->paying_out_colors[$this->paying_out] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPayingOutStatusColor(){
|
public function getPayingOutStatusColor()
|
||||||
|
{
|
||||||
return isset($this->paying_out_status_colors[$this->paying_out_status]) ? $this->paying_out_status_colors[$this->paying_out_status] : '';
|
return isset($this->paying_out_status_colors[$this->paying_out_status]) ? $this->paying_out_status_colors[$this->paying_out_status] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRefundColor(){
|
public function getRefundColor()
|
||||||
|
{
|
||||||
return isset($this->refund_colors[$this->refund]) ? $this->refund_colors[$this->refund] : '-';
|
return isset($this->refund_colors[$this->refund]) ? $this->refund_colors[$this->refund] : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getXxTktColor(){
|
public function getXxTktColor()
|
||||||
|
{
|
||||||
return isset($this->xx_tkt_colors[$this->xx_tkt]) ? $this->xx_tkt_colors[$this->xx_tkt] : '-';
|
return isset($this->xx_tkt_colors[$this->xx_tkt]) ? $this->xx_tkt_colors[$this->xx_tkt] : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countCustomerMailsBy($dir, $subdir=false){
|
public function countCustomerMailsBy($dir, $subdir = false)
|
||||||
|
{
|
||||||
|
|
||||||
if($dir === 11){
|
if ($dir === 11) {
|
||||||
return $this->customer_mails->where('draft', true)->where('dir', '!=', 12)->count();
|
return $this->customer_mails->where('draft', true)->where('dir', '!=', 12)->count();
|
||||||
}
|
}
|
||||||
if($subdir){
|
if ($subdir) {
|
||||||
return $this->customer_mails->where('dir', $dir)->where('subdir', $subdir)->count();
|
return $this->customer_mails->where('dir', $dir)->where('subdir', $subdir)->count();
|
||||||
}
|
}
|
||||||
return $this->customer_mails->where('dir', $dir)->count();
|
return $this->customer_mails->where('dir', $dir)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*DOCUMENTS*/
|
/*DOCUMENTS*/
|
||||||
|
|
||||||
public function hasDocument($identifier){
|
public function hasDocument($identifier)
|
||||||
|
{
|
||||||
return $this->booking_documents->where('identifier', $identifier)->count() ? true : false;
|
return $this->booking_documents->where('identifier', $identifier)->count() ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDocument($identifier){
|
public function getDocument($identifier)
|
||||||
|
{
|
||||||
return $this->booking_documents->where('identifier', $identifier)->first();
|
return $this->booking_documents->where('identifier', $identifier)->first();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDepositPossible($maxIntervalDays = false)
|
public function isDepositPossible($maxIntervalDays = false)
|
||||||
{
|
{
|
||||||
$maxIntervalDays = $maxIntervalDays ? $maxIntervalDays : config('booking.max_interval_days');
|
$maxIntervalDays = $maxIntervalDays ? $maxIntervalDays : config('booking.max_interval_days');
|
||||||
$diffInDays = $this->booking_date->diffInDays($this->start_date, false);
|
$diffInDays = $this->booking_date->diffInDays($this->start_date, false);
|
||||||
return $diffInDays > $maxIntervalDays;
|
return $diffInDays > $maxIntervalDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfirmationDeposit($percentageRate = false){
|
public function getConfirmationDeposit($percentageRate = false)
|
||||||
|
{
|
||||||
$percentageRate = $percentageRate ? $percentageRate : config('booking.deposit_percentage_rate');
|
$percentageRate = $percentageRate ? $percentageRate : config('booking.deposit_percentage_rate');
|
||||||
return ($this->isDepositPossible() ? round($this->getPriceRaw() * $percentageRate / 100) : 0);
|
return ($this->isDepositPossible() ? round($this->getPriceRaw() * $percentageRate / 100) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfirmationFinalPayment(){
|
public function getConfirmationFinalPayment()
|
||||||
|
{
|
||||||
return $this->getPriceRaw() - $this->getConfirmationDeposit();
|
return $this->getPriceRaw() - $this->getConfirmationDeposit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,34 +44,34 @@ class TravelCompany extends Model
|
||||||
protected $connection = 'mysql';
|
protected $connection = 'mysql';
|
||||||
|
|
||||||
protected $table = 'travel_company';
|
protected $table = 'travel_company';
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'percentage' => 'float',
|
'percentage' => 'float',
|
||||||
'is_allowed_edit_commission' => 'bool',
|
'is_allowed_edit_commission' => 'bool',
|
||||||
'is_inhouse' => 'bool',
|
'is_inhouse' => 'bool',
|
||||||
'active' => 'bool',
|
'active' => 'bool',
|
||||||
'contact_emails' => 'array'
|
'contact_emails' => 'array'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'percentage',
|
'percentage',
|
||||||
'is_allowed_edit_commission',
|
'is_allowed_edit_commission',
|
||||||
'is_inhouse',
|
'is_inhouse',
|
||||||
'contact_emails',
|
'contact_emails',
|
||||||
'active'
|
'active'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function bookings()
|
public function bookings()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Booking::class);
|
return $this->hasMany(Booking::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function booking_service_items()
|
public function booking_service_items()
|
||||||
{
|
{
|
||||||
return $this->hasMany(BookingServiceItem::class);
|
return $this->hasMany(BookingServiceItem::class);
|
||||||
}
|
}
|
||||||
public function travel_company_services()
|
public function travel_company_services()
|
||||||
{
|
{
|
||||||
return $this->hasMany(TravelCompanyService::class, 'travel_company_id', 'id')->orderBy('pos', 'DESC');
|
return $this->hasMany(TravelCompanyService::class, 'travel_company_id', 'id')->orderBy('pos', 'DESC');
|
||||||
|
|
@ -84,7 +84,7 @@ class TravelCompany extends Model
|
||||||
|
|
||||||
public function getPercentageAttribute()
|
public function getPercentageAttribute()
|
||||||
{
|
{
|
||||||
return Util::_number_format($this->attributes['percentage']);
|
return isset($this->attributes['percentage']) ? Util::_number_format($this->attributes['percentage']) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPercentageRaw()
|
public function getPercentageRaw()
|
||||||
|
|
|
||||||
72
app/Policies/ModelPolicy.php
Executable file
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\User;
|
||||||
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
abstract class ModelPolicy
|
||||||
|
{
|
||||||
|
use HandlesAuthorization;
|
||||||
|
|
||||||
|
abstract protected function getModelClass(): string;
|
||||||
|
|
||||||
|
public function viewAny(User $user)
|
||||||
|
{
|
||||||
|
return $user->can('view-any-' . $this->getModelClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view(User $user, Model $model)
|
||||||
|
{
|
||||||
|
if ($user->can('view-' . $this->getModelClass())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->can('view-self-' . $this->getModelClass())) {
|
||||||
|
return $this->isOwner($user, $model);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(User $user)
|
||||||
|
{
|
||||||
|
return $user->can('create-' . $this->getModelClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(User $user, Model $model)
|
||||||
|
{
|
||||||
|
if ($user->can('update-' . $this->getModelClass())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->can('update-self-' . $this->getModelClass())) {
|
||||||
|
return $this->isOwner($user, $model);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(User $user, Model $model)
|
||||||
|
{
|
||||||
|
if ($user->can('delete-' . $this->getModelClass())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->can('delete-self-' . $this->getModelClass())) {
|
||||||
|
return $this->isOwner($user, $model);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isOwner(User $user, Model $model): bool
|
||||||
|
{
|
||||||
|
if (!empty($user) && method_exists($model, 'user')) {
|
||||||
|
return $user->getKey() === $model->getRelation('user')->getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Facades\URL;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
|
@ -14,6 +15,7 @@ class AppServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
|
URL::forceScheme('https');
|
||||||
Schema::defaultStringLength(191);
|
Schema::defaultStringLength(191);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ use App\Libraries\CreatePDFCoupon;
|
||||||
use Carbon;
|
use Carbon;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class BookingPDFRepository extends BaseRepository {
|
class BookingPDFRepository extends BaseRepository
|
||||||
|
{
|
||||||
|
|
||||||
protected $prepath;
|
protected $prepath;
|
||||||
|
|
||||||
|
|
@ -29,7 +30,8 @@ class BookingPDFRepository extends BaseRepository {
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPDF($id, $data){
|
public function createPDF($id, $data)
|
||||||
|
{
|
||||||
|
|
||||||
$this->model = Booking::findOrFail($id);
|
$this->model = Booking::findOrFail($id);
|
||||||
|
|
||||||
|
|
@ -57,7 +59,8 @@ class BookingPDFRepository extends BaseRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPDF_Registration(){
|
public function createPDF_Registration()
|
||||||
|
{
|
||||||
$document = new stdClass();
|
$document = new stdClass();
|
||||||
$document->name = 'registration';
|
$document->name = 'registration';
|
||||||
$document->number = $this->model->lead_id;
|
$document->number = $this->model->lead_id;
|
||||||
|
|
@ -65,22 +68,21 @@ class BookingPDFRepository extends BaseRepository {
|
||||||
$document->voucher = null;
|
$document->voucher = null;
|
||||||
$document->date = now();
|
$document->date = now();
|
||||||
$document->total = $this->model->getPriceRaw();
|
$document->total = $this->model->getPriceRaw();
|
||||||
|
|
||||||
$dir = $this->getDirPath('pdf', 'booking', $document->date->format('Y'));
|
$dir = $this->getDirPath('pdf', 'booking', $document->date->format('Y'));
|
||||||
$filename = "Buchnungsauftrag-".$this->model->lead_id.".pdf";
|
$filename = "Buchnungsauftrag-" . $this->model->lead_id . ".pdf";
|
||||||
|
|
||||||
$pdf_file = new CreatePDF('pdf.booking_registration');
|
$pdf_file = new CreatePDF('pdf.booking_registration');
|
||||||
$data = [
|
$data = [
|
||||||
'booking' => $this->model,
|
'booking' => $this->model,
|
||||||
'document' => $document,
|
'document' => $document,
|
||||||
];
|
];
|
||||||
$pdf_file->create($data, $filename, 'save', $this->prepath.$dir);
|
$pdf_file->create($data, $filename, 'save', $this->prepath . $dir);
|
||||||
$booking_document = $this->savePDF($dir, $filename, 'sterntours-template', 'registration', $document);
|
$booking_document = $this->savePDF($dir, $filename, 'sterntours-template', 'registration', $document);
|
||||||
|
|
||||||
return $booking_document;
|
return $booking_document;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPDF_Confirmation(){
|
public function createPDF_Confirmation()
|
||||||
|
{
|
||||||
$document = new stdClass();
|
$document = new stdClass();
|
||||||
$document->name = 'confirmation';
|
$document->name = 'confirmation';
|
||||||
$document->number = $this->model->lead_id;
|
$document->number = $this->model->lead_id;
|
||||||
|
|
@ -92,32 +94,31 @@ class BookingPDFRepository extends BaseRepository {
|
||||||
$document->deposit = $this->model->getConfirmationDeposit();
|
$document->deposit = $this->model->getConfirmationDeposit();
|
||||||
$document->final_payment = $this->model->getConfirmationFinalPayment();
|
$document->final_payment = $this->model->getConfirmationFinalPayment();
|
||||||
|
|
||||||
if ($this->model->isDepositPossible())
|
if ($this->model->isDepositPossible()) {
|
||||||
{
|
|
||||||
$document->deposit_payment_date = date('Y-m-d');
|
$document->deposit_payment_date = date('Y-m-d');
|
||||||
$maxDepositIntervalDays = config('booking.max_deposit_interval_days');
|
$maxDepositIntervalDays = config('booking.max_deposit_interval_days');
|
||||||
$_start_date = clone $this->model->start_date;
|
$_start_date = clone $this->model->start_date;
|
||||||
$_start_date->modify('-'.$maxDepositIntervalDays.' days');
|
$_start_date->modify('-' . $maxDepositIntervalDays . ' days');
|
||||||
$document->final_payment_date = $_start_date->format('Y-m-d');
|
$document->final_payment_date = $_start_date->format('Y-m-d');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$document->final_payment_date = date('Y-m-d');
|
$document->final_payment_date = date('Y-m-d');
|
||||||
}
|
}
|
||||||
$dir = $this->getDirPath('pdf', 'booking', $document->date->format('Y'));
|
$dir = $this->getDirPath('pdf', 'booking', $document->date->format('Y'));
|
||||||
$filename = "Reisebestätigung-".$this->model->lead_id.".pdf";
|
$filename = "Reisebestätigung-" . $this->model->lead_id . ".pdf";
|
||||||
|
|
||||||
$pdf_file = new CreatePDF('pdf.booking_confirmation');
|
$pdf_file = new CreatePDF('pdf.booking_confirmation');
|
||||||
$data = [
|
$data = [
|
||||||
'booking' => $this->model,
|
'booking' => $this->model,
|
||||||
'document' => $document,
|
'document' => $document,
|
||||||
];
|
];
|
||||||
$pdf_file->create($data, $filename, 'save', $this->prepath.$dir);
|
$pdf_file->create($data, $filename, 'save', $this->prepath . $dir);
|
||||||
$booking_document = $this->savePDF($dir, $filename, 'sterntours-template', 'confirmation', $document);
|
$booking_document = $this->savePDF($dir, $filename, 'sterntours-template', 'confirmation', $document);
|
||||||
|
|
||||||
return $booking_document;
|
return $booking_document;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPDF_Coupon($data){
|
public function createPDF_Coupon($data)
|
||||||
|
{
|
||||||
|
|
||||||
$document = new stdClass();
|
$document = new stdClass();
|
||||||
$document->name = 'coupon';
|
$document->name = 'coupon';
|
||||||
|
|
@ -133,7 +134,7 @@ class BookingPDFRepository extends BaseRepository {
|
||||||
$coupon->valid_date = $data['valid_date'];
|
$coupon->valid_date = $data['valid_date'];
|
||||||
$coupon->is_redeemed = false;
|
$coupon->is_redeemed = false;
|
||||||
$coupon->save();
|
$coupon->save();
|
||||||
|
|
||||||
$document->number = $coupon->number;
|
$document->number = $coupon->number;
|
||||||
$document->value = $coupon->value;
|
$document->value = $coupon->value;
|
||||||
$document->issue_date = $coupon->issue_date;
|
$document->issue_date = $coupon->issue_date;
|
||||||
|
|
@ -142,61 +143,63 @@ class BookingPDFRepository extends BaseRepository {
|
||||||
|
|
||||||
|
|
||||||
$dir = $this->getDirPath('pdf', 'coupon', $document->date->format('Y'));
|
$dir = $this->getDirPath('pdf', 'coupon', $document->date->format('Y'));
|
||||||
$filename = "Gutschein-".$coupon->number.".pdf";
|
$filename = "Gutschein-" . $coupon->number . ".pdf";
|
||||||
|
|
||||||
$pdf_file = new CreatePDFCoupon('pdf.booking_coupon');
|
$pdf_file = new CreatePDFCoupon('pdf.booking_coupon');
|
||||||
$data = [
|
$data = [
|
||||||
'booking' => $this->model,
|
'booking' => $this->model,
|
||||||
'document' => $document,
|
'document' => $document,
|
||||||
'coupon' => $coupon,
|
'coupon' => $coupon,
|
||||||
];
|
];
|
||||||
$pdf_file->create($data, $filename, 'save', $this->prepath.$dir);
|
$pdf_file->create($data, $filename, 'save', $this->prepath . $dir);
|
||||||
$booking_document = $this->savePDF($dir, $filename, 'sterntours-coupon', 'coupon', $document);
|
$booking_document = $this->savePDF($dir, $filename, 'sterntours-coupon', 'coupon', $document);
|
||||||
return $booking_document;
|
return $booking_document;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPDF_Voucher($agency = false){
|
public function createPDF_Voucher($agency = false)
|
||||||
|
{
|
||||||
$document = new stdClass();
|
$document = new stdClass();
|
||||||
$document->name = 'voucher';
|
$document->name = 'voucher';
|
||||||
$document->number = $this->model->lead_id;
|
$document->number = $this->model->lead_id;
|
||||||
$document->name = 'voucher';
|
$document->name = 'voucher';
|
||||||
$document->title = $agency ? 'VOUCHER Agentur': 'VOUCHER';
|
$document->title = $agency ? 'VOUCHER Agentur' : 'VOUCHER';
|
||||||
$document->voucher = $agency ? 'agency': 'client';
|
$document->voucher = $agency ? 'agency' : 'client';
|
||||||
$document->date = now();
|
$document->date = now();
|
||||||
|
|
||||||
$dir = $this->getDirPath('pdf', 'voucher', $document->date->format('Y'));
|
$dir = $this->getDirPath('pdf', 'voucher', $document->date->format('Y'));
|
||||||
$filename = ($agency ? 'VoucherAgentur': 'Voucher')."-".$this->model->lead_id.".pdf";
|
$filename = ($agency ? 'VoucherAgentur' : 'Voucher') . "-" . $this->model->lead_id . ".pdf";
|
||||||
|
|
||||||
$pdf_file = new CreatePDF('pdf.booking_voucher');
|
$pdf_file = new CreatePDF('pdf.booking_voucher');
|
||||||
$data = [
|
$data = [
|
||||||
'booking' => $this->model,
|
'booking' => $this->model,
|
||||||
'document' => $document,
|
'document' => $document,
|
||||||
];
|
];
|
||||||
$pdf_file->create($data, $filename, 'save', $this->prepath.$dir);
|
$pdf_file->create($data, $filename, 'save', $this->prepath . $dir);
|
||||||
$identifier = $agency ? 'voucher_agency': 'voucher';
|
$identifier = $agency ? 'voucher_agency' : 'voucher';
|
||||||
$booking_document = $this->savePDF($dir, $filename, 'sterntours-template', $identifier, $document);
|
$booking_document = $this->savePDF($dir, $filename, 'sterntours-template', $identifier, $document);
|
||||||
|
|
||||||
return $booking_document;
|
return $booking_document;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createPDF_Storno($data){
|
public function createPDF_Storno($data)
|
||||||
|
{
|
||||||
//Storno Values
|
//Storno Values
|
||||||
$storno_status_id = (int) $data['storno_status_id'];
|
$storno_status_id = (int) $data['storno_status_id'];
|
||||||
$storno_level = (float) $data['storno_level'];
|
$storno_level = (float) $data['storno_level'];
|
||||||
$storno_level_number = \Util::_clean_float($data['storno_level_number']);
|
$storno_level_number = \Util::_clean_float($data['storno_level_number']);
|
||||||
$storno_total_price = \Util::_clean_float($data['storno_total_price']);
|
$storno_total_price = \Util::_clean_float($data['storno_total_price']);
|
||||||
$price = $this->model->getPriceRaw();
|
$price = $this->model->getPriceRaw();
|
||||||
if($storno_level_number > 0 && $storno_level_number < 100 ){
|
if ($storno_level_number > 0 && $storno_level_number < 100) {
|
||||||
$storno_level = $storno_level_number;
|
$storno_level = $storno_level_number;
|
||||||
}
|
}
|
||||||
//calculate price canceled
|
//calculate price canceled
|
||||||
if($storno_total_price > 0){
|
if ($storno_total_price > 0) {
|
||||||
$price_canceled = $storno_total_price;
|
$price_canceled = $storno_total_price;
|
||||||
$storno_level = ((100 / $price) * $storno_total_price);
|
$storno_level = ((100 / $price) * $storno_total_price);
|
||||||
}else{
|
} else {
|
||||||
$price_canceled = round($price / 100 * $storno_level, 2);
|
$price_canceled = round($price / 100 * $storno_level, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//init identifier
|
//init identifier
|
||||||
$identifier = 'storno';
|
$identifier = 'storno';
|
||||||
|
|
@ -210,11 +213,11 @@ class BookingPDFRepository extends BaseRepository {
|
||||||
'storno_print' => $data['storno_print'],
|
'storno_print' => $data['storno_print'],
|
||||||
'binary_data' => NULL,
|
'binary_data' => NULL,
|
||||||
];
|
];
|
||||||
if($this->model->hasDocument($identifier)){
|
if ($this->model->hasDocument($identifier)) {
|
||||||
$booking_document = $this->model->getDocument($identifier);
|
$booking_document = $this->model->getDocument($identifier);
|
||||||
$booking_storno = $booking_document->booking_storno;
|
$booking_storno = $booking_document->booking_storno;
|
||||||
$booking_storno->update($fill);
|
$booking_storno->update($fill);
|
||||||
}else{
|
} else {
|
||||||
$booking_storno = BookingStorno::create($fill);
|
$booking_storno = BookingStorno::create($fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,53 +236,54 @@ class BookingPDFRepository extends BaseRepository {
|
||||||
$document->booking_storno_id = $booking_storno->id;
|
$document->booking_storno_id = $booking_storno->id;
|
||||||
$document->storno_level = $storno_level;
|
$document->storno_level = $storno_level;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//update Booking // Lead Status
|
//update Booking // Lead Status
|
||||||
if($storno_status_id){
|
if ($storno_status_id) {
|
||||||
$this->model->lead->status_id = $storno_status_id;
|
$this->model->lead->status_id = $storno_status_id;
|
||||||
$this->model->lead->save();
|
$this->model->lead->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->model->canceled = $storno_level;
|
$this->model->canceled = $storno_level;
|
||||||
$this->model->price_canceled = $price_canceled; //must pay
|
$this->model->price_canceled = $price_canceled; //must pay
|
||||||
$this->model->price_total = $price_canceled; //is the same as Canceled( ...
|
$this->model->price_total = $price_canceled; //is the same as Canceled( ...
|
||||||
$this->model->price_balance = round($price - $price_canceled, 2); //is the Rest - must not pay
|
$this->model->price_balance = round($price - $price_canceled, 2); //is the Rest - must not pay
|
||||||
$this->model->save();
|
$this->model->save();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$dir = $this->getDirPath('pdf', 'storno', $document->date->format('Y'));
|
$dir = $this->getDirPath('pdf', 'storno', $document->date->format('Y'));
|
||||||
$filename = "Reisestornierung -".$this->model->lead_id.".pdf";
|
$filename = "Reisestornierung -" . $this->model->lead_id . ".pdf";
|
||||||
|
|
||||||
$pdf_file = new CreatePDF('pdf.booking_storno');
|
$pdf_file = new CreatePDF('pdf.booking_storno');
|
||||||
$data = [
|
$data = [
|
||||||
'booking' => $this->model,
|
'booking' => $this->model,
|
||||||
'document' => $document,
|
'document' => $document,
|
||||||
];
|
];
|
||||||
$pdf_file->create($data, $filename, 'save', $this->prepath.$dir);
|
$pdf_file->create($data, $filename, 'save', $this->prepath . $dir);
|
||||||
$this->savePDF($dir, $filename, 'sterntours-template', $identifier, $document);
|
$this->savePDF($dir, $filename, 'sterntours-template', $identifier, $document);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//get Invoice Name / Paths / ...
|
|
||||||
private function getDirPath($file, $dir, $year){
|
|
||||||
|
|
||||||
$path = $file.'/'.$dir.'/'.$year.'/';
|
//get Invoice Name / Paths / ...
|
||||||
if(!Storage::disk('public')->exists( $path )){
|
private function getDirPath($file, $dir, $year)
|
||||||
|
{
|
||||||
|
|
||||||
|
$path = $file . '/' . $dir . '/' . $year . '/';
|
||||||
|
if (!Storage::disk('public')->exists($path)) {
|
||||||
Storage::disk('public')->makeDirectory($path); //creates directory
|
Storage::disk('public')->makeDirectory($path); //creates directory
|
||||||
}
|
}
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function savePDF($dir, $filename, $template, $identifier, $document = null, $status = 0){
|
private function savePDF($dir, $filename, $template, $identifier, $document = null, $status = 0)
|
||||||
|
{
|
||||||
|
|
||||||
$pdfMerger = new MyPDFMerger();
|
$pdfMerger = new MyPDFMerger();
|
||||||
$pdfMerger->addPDF($this->prepath.$dir.$filename);
|
$pdfMerger->addPDF($this->prepath . $dir . $filename);
|
||||||
$file = $pdfMerger->myMerge('string', $filename, $template);
|
$file = $pdfMerger->myMerge('string', $filename, $template);
|
||||||
Storage::disk('public')->put($dir.$filename, $file);
|
Storage::disk('public')->put($dir . $filename, $file);
|
||||||
|
|
||||||
$fill = [
|
$fill = [
|
||||||
'booking_id' => $this->model->id,
|
'booking_id' => $this->model->id,
|
||||||
|
|
@ -291,25 +295,23 @@ class BookingPDFRepository extends BaseRepository {
|
||||||
'original_name' => $filename,
|
'original_name' => $filename,
|
||||||
'ext' => 'pdf',
|
'ext' => 'pdf',
|
||||||
'mine' => 'application/pdf',
|
'mine' => 'application/pdf',
|
||||||
'size' => Storage::disk('public')->size($dir.$filename),
|
'size' => Storage::disk('public')->size($dir . $filename),
|
||||||
'date' => now(),
|
'date' => now(),
|
||||||
'data' => $document,
|
'data' => $document,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'booking_storno_id' => isset($document->booking_storno_id) ? $document->booking_storno_id : null,
|
'booking_storno_id' => isset($document->booking_storno_id) ? $document->booking_storno_id : null,
|
||||||
'coupon_id' => isset($document->coupon_id) ? $document->coupon_id : null,
|
'coupon_id' => isset($document->coupon_id) ? $document->coupon_id : null,
|
||||||
];
|
];
|
||||||
if($this->model->hasDocument($identifier)){
|
if ($this->model->hasDocument($identifier)) {
|
||||||
$booking_document = $this->model->getDocument($identifier);
|
$booking_document = $this->model->getDocument($identifier);
|
||||||
$booking_document->update($fill);
|
$booking_document->update($fill);
|
||||||
}else{
|
} else {
|
||||||
$booking_document = BookingDocument::create($fill);
|
$booking_document = BookingDocument::create($fill);
|
||||||
}
|
}
|
||||||
return $booking_document;
|
return $booking_document;
|
||||||
|
|
||||||
//return $pdfMerger->myMerge('browser', $filename, $template);
|
//return $pdfMerger->myMerge('browser', $filename, $template);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3,19 +3,21 @@
|
||||||
namespace App\Repositories;
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
|
||||||
use Auth;
|
|
||||||
use App\Models\Lead;
|
|
||||||
use App\Services\Util;
|
|
||||||
use App\Models\Booking;
|
use App\Models\Booking;
|
||||||
use App\Models\Participant;
|
|
||||||
use App\Models\BookingNotice;
|
|
||||||
use App\Models\BookingServiceItem;
|
|
||||||
use App\Models\ServiceProviderEntry;
|
|
||||||
use App\Models\BookingCompanyService;
|
use App\Models\BookingCompanyService;
|
||||||
use App\Models\BookingCountryService;
|
use App\Models\BookingCountryService;
|
||||||
|
use App\Models\BookingDraftItem;
|
||||||
|
use App\Models\BookingNotice;
|
||||||
use App\Models\BookingProviderService;
|
use App\Models\BookingProviderService;
|
||||||
|
use App\Models\BookingServiceItem;
|
||||||
|
use App\Models\Lead;
|
||||||
|
use App\Models\Participant;
|
||||||
|
use App\Models\ServiceProviderEntry;
|
||||||
|
use App\Services\Util;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
class BookingRepository extends BaseRepository {
|
class BookingRepository extends BaseRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Booking $model)
|
public function __construct(Booking $model)
|
||||||
|
|
@ -29,35 +31,38 @@ class BookingRepository extends BaseRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function updateNotice($id, $data){
|
public function updateNotice($id, $data)
|
||||||
|
{
|
||||||
|
|
||||||
$this->model = Booking::findOrFail($id);
|
$this->model = Booking::findOrFail($id);
|
||||||
if($data['action'] === 'edit_notice' && isset($data['notice_id'])){
|
if ($data['action'] === 'edit_notice' && isset($data['notice_id'])) {
|
||||||
$BookingNotice = BookingNotice::findOrFail($data['notice_id']);
|
$BookingNotice = BookingNotice::findOrFail($data['notice_id']);
|
||||||
$BookingNotice->message = isset($data['booking_notice']) ? $data['booking_notice'] : "";
|
$BookingNotice->message = isset($data['booking_notice']) ? $data['booking_notice'] : "";
|
||||||
$BookingNotice->edit_at = now();
|
$BookingNotice->edit_at = now();
|
||||||
$BookingNotice->save();
|
$BookingNotice->save();
|
||||||
}else{
|
} else {
|
||||||
//save_notice
|
//save_notice
|
||||||
BookingNotice::create([
|
BookingNotice::create(
|
||||||
'booking_id' => $this->model->id,
|
[
|
||||||
'from_user_id' => Auth::user()->id,
|
'booking_id' => $this->model->id,
|
||||||
'to_user_id' => isset($this->model->sf_guard_user->user_id) ? $this->model->sf_guard_user->user_id : null,
|
'from_user_id' => Auth::user()->id,
|
||||||
'message' => isset($data['booking_notice']) ? $data['booking_notice'] : "",
|
'to_user_id' => isset($this->model->sf_guard_user->user_id) ? $this->model->sf_guard_user->user_id : null,
|
||||||
|
'message' => isset($data['booking_notice']) ? $data['booking_notice'] : "",
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateLeadStatus($id, $data){
|
public function updateLeadStatus($id, $data)
|
||||||
|
{
|
||||||
|
|
||||||
$this->model = Booking::findOrFail($id);
|
$this->model = Booking::findOrFail($id);
|
||||||
|
|
||||||
if(isset($data['lead'])){
|
if (isset($data['lead'])) {
|
||||||
$lead = $this->model->lead;
|
$lead = $this->model->lead;
|
||||||
if($lead->id != $data['lead']['id']){
|
if ($lead->id != $data['lead']['id']) {
|
||||||
abort(500);
|
abort(500);
|
||||||
}
|
}
|
||||||
$lead->status_id = $data['lead']['status_id'];
|
$lead->status_id = $data['lead']['status_id'];
|
||||||
|
|
@ -68,7 +73,8 @@ class BookingRepository extends BaseRepository {
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateBooking($id, $data){
|
public function updateBooking($id, $data)
|
||||||
|
{
|
||||||
|
|
||||||
$this->model = Booking::findOrFail($id);
|
$this->model = Booking::findOrFail($id);
|
||||||
|
|
||||||
|
|
@ -88,7 +94,7 @@ class BookingRepository extends BaseRepository {
|
||||||
'paying_out' => $data['paying_out'],
|
'paying_out' => $data['paying_out'],
|
||||||
'paying_out_status' => $data['paying_out_status'],
|
'paying_out_status' => $data['paying_out_status'],
|
||||||
'branch_id' => isset($data['branch_id']) ? $data['branch_id'] : 4,
|
'branch_id' => isset($data['branch_id']) ? $data['branch_id'] : 4,
|
||||||
'airport_id' => (isset($data['airport_id']) && $data['airport_id']>0) ? $data['airport_id'] : null,
|
'airport_id' => (isset($data['airport_id']) && $data['airport_id'] > 0) ? $data['airport_id'] : null,
|
||||||
'travel_company_id' => $data['travel_company_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,
|
'airline_ids' => isset($data['airline_ids']) ? $data['airline_ids'] : null,
|
||||||
|
|
@ -107,8 +113,8 @@ class BookingRepository extends BaseRepository {
|
||||||
$this->model->fill($fill);
|
$this->model->fill($fill);
|
||||||
$this->model->save();
|
$this->model->save();
|
||||||
|
|
||||||
if($this->model->booking_draft_items){
|
if ($this->model->booking_draft_items) {
|
||||||
foreach($this->model->booking_draft_items as $booking_draft_item){
|
foreach ($this->model->booking_draft_items as $booking_draft_item) {
|
||||||
$booking_draft_item->comfort = isset($data['travel_comfort']) ? true : false;
|
$booking_draft_item->comfort = isset($data['travel_comfort']) ? true : false;
|
||||||
$booking_draft_item->save();
|
$booking_draft_item->save();
|
||||||
}
|
}
|
||||||
|
|
@ -116,24 +122,26 @@ class BookingRepository extends BaseRepository {
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateBookingServices($id, $data){
|
public function updateBookingServices($id, $data)
|
||||||
|
{
|
||||||
|
|
||||||
$this->model = Booking::findOrFail($id);
|
$this->model = Booking::findOrFail($id);
|
||||||
if(isset($data['country_service'])){
|
if (isset($data['country_service'])) {
|
||||||
$this->updateCountryService($data['country_service']);
|
$this->updateCountryService($data['country_service']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($data['provider_service'])){
|
if (isset($data['provider_service'])) {
|
||||||
$this->updateProviderService($data['provider_service']);
|
$this->updateProviderService($data['provider_service']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($data['company_service'])){
|
if (isset($data['company_service'])) {
|
||||||
$this->updateCompanyService($data['company_service']);
|
$this->updateCompanyService($data['company_service']);
|
||||||
}
|
}
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateBookingNumber($id, $data){
|
public function updateBookingNumber($id, $data)
|
||||||
|
{
|
||||||
|
|
||||||
$this->model = Booking::findOrFail($id);
|
$this->model = Booking::findOrFail($id);
|
||||||
$fill = [
|
$fill = [
|
||||||
|
|
@ -145,7 +153,8 @@ class BookingRepository extends BaseRepository {
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateBookingPrice($id, $data){
|
public function updateBookingPrice($id, $data)
|
||||||
|
{
|
||||||
|
|
||||||
$this->model = Booking::findOrFail($id);
|
$this->model = Booking::findOrFail($id);
|
||||||
$fill = [
|
$fill = [
|
||||||
|
|
@ -158,46 +167,48 @@ class BookingRepository extends BaseRepository {
|
||||||
$this->model->save();
|
$this->model->save();
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateServiceProviderEntry($id, $data){
|
public function updateServiceProviderEntry($id, $data)
|
||||||
|
{
|
||||||
$this->model = Booking::findOrFail($id);
|
$this->model = Booking::findOrFail($id);
|
||||||
if(isset($data['service_provider_entry'])){
|
if (isset($data['service_provider_entry'])) {
|
||||||
foreach($data['service_provider_entry'] as $spe_id => $fill){
|
foreach ($data['service_provider_entry'] as $spe_id => $fill) {
|
||||||
$ServiceProviderEntry = ServiceProviderEntry::findOrFail($spe_id);
|
$ServiceProviderEntry = ServiceProviderEntry::findOrFail($spe_id);
|
||||||
if($ServiceProviderEntry->booking_id !== $this->model->id){
|
if ($ServiceProviderEntry->booking_id !== $this->model->id) {
|
||||||
abort(500);
|
abort(500);
|
||||||
}
|
}
|
||||||
$fill['is_cleared'] = isset($fill['is_cleared']) ? true : false;
|
$fill['is_cleared'] = isset($fill['is_cleared']) ? true : false;
|
||||||
$fill['payment_date'] = isset($fill['payment_date']) ? _reformat_date($fill['payment_date']) : null;
|
$fill['payment_date'] = isset($fill['payment_date']) ? _reformat_date($fill['payment_date']) : null;
|
||||||
$ServiceProviderEntry->fill($fill);
|
$ServiceProviderEntry->fill($fill);
|
||||||
$ServiceProviderEntry->save();
|
$ServiceProviderEntry->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateBookingServiceItem($id, $data){
|
public function updateBookingServiceItem($id, $data)
|
||||||
|
{
|
||||||
$this->model = Booking::findOrFail($id);
|
$this->model = Booking::findOrFail($id);
|
||||||
if(isset($data['booking_service_item'])){
|
if (isset($data['booking_service_item'])) {
|
||||||
foreach($data['booking_service_item'] as $bsi_id => $fill){
|
foreach ($data['booking_service_item'] as $bsi_id => $fill) {
|
||||||
$BookingServiceItem = BookingServiceItem::findOrFail($bsi_id);
|
$BookingServiceItem = BookingServiceItem::findOrFail($bsi_id);
|
||||||
if($BookingServiceItem->booking_id !== $this->model->id){
|
if ($BookingServiceItem->booking_id !== $this->model->id) {
|
||||||
abort(500);
|
abort(500);
|
||||||
}
|
}
|
||||||
$fill['is_commission_locked'] = isset($fill['is_commission_locked']) ? true : false;
|
$fill['is_commission_locked'] = isset($fill['is_commission_locked']) ? true : false;
|
||||||
$fill['travel_date'] = isset($fill['travel_date']) ? _reformat_date($fill['travel_date']) : now();
|
$fill['travel_date'] = isset($fill['travel_date']) ? _reformat_date($fill['travel_date']) : now();
|
||||||
$BookingServiceItem->fill($fill);
|
$BookingServiceItem->fill($fill);
|
||||||
$BookingServiceItem->save();
|
$BookingServiceItem->save();
|
||||||
|
|
||||||
if($fill['is_commission_locked'] === true){
|
if ($fill['is_commission_locked'] === true) {
|
||||||
$service_price_refund = 0;
|
$service_price_refund = 0;
|
||||||
if($BookingServiceItem->getServicePriceRaw() > 0){
|
if ($BookingServiceItem->getServicePriceRaw() > 0) {
|
||||||
$service_price_refund = $BookingServiceItem->getServicePriceRaw() / 100 * $BookingServiceItem->travel_company->getPercentageRaw();
|
$service_price_refund = $BookingServiceItem->getServicePriceRaw() / 100 * $BookingServiceItem->travel_company->getPercentageRaw();
|
||||||
}
|
}
|
||||||
$BookingServiceItem->setServicePriceRefundRaw($service_price_refund);
|
$BookingServiceItem->setServicePriceRefundRaw($service_price_refund);
|
||||||
$BookingServiceItem->save();
|
$BookingServiceItem->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->model->price_total = ($this->model->getPriceRaw() + $this->model->getServiceTotal(true));
|
$this->model->price_total = ($this->model->getPriceRaw() + $this->model->getServiceTotal(true));
|
||||||
$this->model->save();
|
$this->model->save();
|
||||||
|
|
@ -205,21 +216,22 @@ class BookingRepository extends BaseRepository {
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateBookingParticipant($id, $data){
|
public function updateBookingParticipant($id, $data)
|
||||||
|
{
|
||||||
$this->model = Booking::findOrFail($id);
|
$this->model = Booking::findOrFail($id);
|
||||||
if(isset($data['participant'])){
|
if (isset($data['participant'])) {
|
||||||
foreach($data['participant'] as $p_id => $fill){
|
foreach ($data['participant'] as $p_id => $fill) {
|
||||||
$Participant = Participant::findOrFail($p_id);
|
$Participant = Participant::findOrFail($p_id);
|
||||||
if($Participant->booking_id !== $this->model->id){
|
if ($Participant->booking_id !== $this->model->id) {
|
||||||
abort(500);
|
abort(500);
|
||||||
}
|
}
|
||||||
$fill['participant_pass'] = isset($fill['participant_pass']) ? true : false;
|
$fill['participant_pass'] = isset($fill['participant_pass']) ? true : false;
|
||||||
$fill['participant_storno'] = isset($fill['participant_storno']) ? true : false;
|
$fill['participant_storno'] = isset($fill['participant_storno']) ? true : false;
|
||||||
$fill['participant_child'] = isset($fill['participant_child']) ? true : false;
|
$fill['participant_child'] = isset($fill['participant_child']) ? true : false;
|
||||||
$fill['participant_birthdate'] = isset($fill['participant_birthdate']) ? _reformat_date($fill['participant_birthdate']) : null;
|
$fill['participant_birthdate'] = isset($fill['participant_birthdate']) ? _reformat_date($fill['participant_birthdate']) : null;
|
||||||
$Participant->fill($fill);
|
$Participant->fill($fill);
|
||||||
$Participant->save();
|
$Participant->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//main
|
//main
|
||||||
$this->model->participant_salutation_id = isset($data['participant_salutation_id']) ? $data['participant_salutation_id'] : null;
|
$this->model->participant_salutation_id = isset($data['participant_salutation_id']) ? $data['participant_salutation_id'] : null;
|
||||||
|
|
@ -229,29 +241,30 @@ class BookingRepository extends BaseRepository {
|
||||||
$this->model->participant_birthdate = isset($data['participant_birthdate']) ? _reformat_date($data['participant_birthdate']) : 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->participant_pass = isset($data['participant_pass']) ? true : false;
|
||||||
//update pax
|
//update pax
|
||||||
if($this->model->participants->count() > 0){
|
if ($this->model->participants->count() > 0) {
|
||||||
$this->model->pax = $this->model->participants->where('participant_storno', false)->count();
|
$this->model->pax = $this->model->participants->where('participant_storno', false)->count();
|
||||||
}
|
}
|
||||||
$this->model->save();
|
$this->model->save();
|
||||||
return $this->model;
|
return $this->model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function updateCountryService($country_services){
|
|
||||||
foreach ($country_services as $country_service_id=>$val){
|
|
||||||
|
private function updateCountryService($country_services)
|
||||||
|
{
|
||||||
|
foreach ($country_services as $country_service_id => $val) {
|
||||||
$booking_country_service = BookingCountryService::where('travel_country_service_id', '=', $country_service_id)
|
$booking_country_service = BookingCountryService::where('travel_country_service_id', '=', $country_service_id)
|
||||||
->where('booking_id', '=', $this->model->id)->first();
|
->where('booking_id', '=', $this->model->id)->first();
|
||||||
|
|
||||||
if(!$booking_country_service){
|
if (!$booking_country_service) {
|
||||||
BookingCountryService::create([
|
BookingCountryService::create([
|
||||||
'travel_country_service_id' => $country_service_id,
|
'travel_country_service_id' => $country_service_id,
|
||||||
'booking_id' => $this->model->id,
|
'booking_id' => $this->model->id,
|
||||||
'status' => $val
|
'status' => $val
|
||||||
]);
|
]);
|
||||||
}else{
|
} else {
|
||||||
$booking_country_service->fill([
|
$booking_country_service->fill([
|
||||||
'status' => $val
|
'status' => $val
|
||||||
]);
|
]);
|
||||||
|
|
@ -260,18 +273,19 @@ class BookingRepository extends BaseRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateProviderService($provider_service){
|
private function updateProviderService($provider_service)
|
||||||
foreach ($provider_service as $provider_service_id=>$val){
|
{
|
||||||
|
foreach ($provider_service as $provider_service_id => $val) {
|
||||||
$booking_provider_service = BookingProviderService::where('service_provider_service_id', '=', $provider_service_id)
|
$booking_provider_service = BookingProviderService::where('service_provider_service_id', '=', $provider_service_id)
|
||||||
->where('booking_id', '=', $this->model->id)->first();
|
->where('booking_id', '=', $this->model->id)->first();
|
||||||
|
|
||||||
if(!$booking_provider_service){
|
if (!$booking_provider_service) {
|
||||||
BookingProviderService::create([
|
BookingProviderService::create([
|
||||||
'service_provider_service_id' => $provider_service_id,
|
'service_provider_service_id' => $provider_service_id,
|
||||||
'booking_id' => $this->model->id,
|
'booking_id' => $this->model->id,
|
||||||
'status' => $val
|
'status' => $val
|
||||||
]);
|
]);
|
||||||
}else{
|
} else {
|
||||||
$booking_provider_service->fill([
|
$booking_provider_service->fill([
|
||||||
'status' => $val
|
'status' => $val
|
||||||
]);
|
]);
|
||||||
|
|
@ -280,18 +294,19 @@ class BookingRepository extends BaseRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateCompanyService($company_service){
|
private function updateCompanyService($company_service)
|
||||||
foreach ($company_service as $company_service_id=>$val){
|
{
|
||||||
|
foreach ($company_service as $company_service_id => $val) {
|
||||||
$booking_company_service = BookingCompanyService::where('travel_company_service_id', '=', $company_service_id)
|
$booking_company_service = BookingCompanyService::where('travel_company_service_id', '=', $company_service_id)
|
||||||
->where('booking_id', '=', $this->model->id)->first();
|
->where('booking_id', '=', $this->model->id)->first();
|
||||||
|
|
||||||
if(!$booking_company_service){
|
if (!$booking_company_service) {
|
||||||
BookingCompanyService::create([
|
BookingCompanyService::create([
|
||||||
'travel_company_service_id' => $company_service_id,
|
'travel_company_service_id' => $company_service_id,
|
||||||
'booking_id' => $this->model->id,
|
'booking_id' => $this->model->id,
|
||||||
'status' => $val
|
'status' => $val
|
||||||
]);
|
]);
|
||||||
}else{
|
} else {
|
||||||
$booking_company_service->fill([
|
$booking_company_service->fill([
|
||||||
'status' => $val
|
'status' => $val
|
||||||
]);
|
]);
|
||||||
|
|
@ -300,4 +315,135 @@ class BookingRepository extends BaseRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public function convertArrangementsToDrafts(Booking $booking)
|
||||||
|
{
|
||||||
|
if (!$booking->arrangements || $booking->arrangements->count() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nextPos = 1;
|
||||||
|
if ($booking->booking_draft_items && $booking->booking_draft_items->count() > 0) {
|
||||||
|
$nextPos = $booking->booking_draft_items->max('pos') + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($booking->arrangements->sortByDesc('view_position') as $arrangement) {
|
||||||
|
|
||||||
|
$data = $arrangement->getDataAsMap();
|
||||||
|
|
||||||
|
|
||||||
|
// Erstelle neues BookingDraftItem aus Arrangement
|
||||||
|
$draftItem = new BookingDraftItem();
|
||||||
|
|
||||||
|
// Mappe die grundlegenden Daten
|
||||||
|
$draftItem->booking_id = $booking->id;
|
||||||
|
$draftItem->pos = $nextPos++;
|
||||||
|
|
||||||
|
// Daten von Arrangement übertragen
|
||||||
|
if ($arrangement->begin) {
|
||||||
|
$draftItem->start_date = $arrangement->begin->format('Y-m-d');
|
||||||
|
}
|
||||||
|
if ($arrangement->end) {
|
||||||
|
$draftItem->end_date = $arrangement->end->format('Y-m-d');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Service/Beschreibung aus data_s generieren
|
||||||
|
$serviceText = $arrangement->getDataS();
|
||||||
|
$draftItem->service = $serviceText;
|
||||||
|
|
||||||
|
$draftItem->adult = $data['Teilnehmer'] ?? $booking->pax;
|
||||||
|
$draftItem->price_adult = $data['Preis'] ?? 0;
|
||||||
|
|
||||||
|
// PDF-Einstellung übernehmen
|
||||||
|
$draftItem->in_pdf = $arrangement->in_pdf ? 1 : 0;
|
||||||
|
|
||||||
|
// Versuche DraftType zu finden basierend auf ArrangementType
|
||||||
|
if ($arrangement->arrangement_type && isset($arrangement->arrangement_type->name)) {
|
||||||
|
$draftType = \App\Models\DraftType::where('name', 'like', '%' . $arrangement->arrangement_type->name . '%')->first();
|
||||||
|
if ($draftType) {
|
||||||
|
$draftItem->draft_type_id = $draftType->id;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Fallback: Suche nach einem passenden DraftType basierend auf dem Namen
|
||||||
|
$draftType = \App\Models\DraftType::where('name', 'like', '%' . $arrangement->type_s . '%')->first();
|
||||||
|
if ($draftType) {
|
||||||
|
$draftItem->draft_type_id = $draftType->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standardwerte für neue Felder setzen
|
||||||
|
$draftItem->comfort = 0;
|
||||||
|
$draftItem->price = 0;
|
||||||
|
$draftItem->adult = 0;
|
||||||
|
$draftItem->price_children = 0;
|
||||||
|
$draftItem->children = 0;
|
||||||
|
|
||||||
|
$draftItem->save();
|
||||||
|
|
||||||
|
// Arrangement als konvertiert markieren oder löschen
|
||||||
|
// Hier löschen wir das Arrangement nach erfolgreicher Konvertierung
|
||||||
|
$arrangement->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stelle sicher, dass new_drafts aktiviert ist
|
||||||
|
if (!$booking->new_drafts) {
|
||||||
|
$booking->new_drafts = true;
|
||||||
|
$booking->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preise neu berechnen
|
||||||
|
$booking->calculate_price_total();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadDraftToBooking($bookingId, $draftId)
|
||||||
|
{
|
||||||
|
$booking = Booking::findOrFail($bookingId);
|
||||||
|
$draft = \App\Models\Draft::findOrFail($draftId);
|
||||||
|
|
||||||
|
if (!$booking->new_drafts) {
|
||||||
|
$booking->new_drafts = true;
|
||||||
|
$booking->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lösche bestehende Draft Items falls gewünscht
|
||||||
|
if ($booking->booking_draft_items && $booking->booking_draft_items->count() > 0) {
|
||||||
|
foreach ($booking->booking_draft_items as $existingItem) {
|
||||||
|
$existingItem->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pos = 1;
|
||||||
|
foreach ($draft->draft_items as $draftItem) {
|
||||||
|
$bookingDraftItem = new \App\Models\BookingDraftItem();
|
||||||
|
|
||||||
|
// Kopiere alle Daten aus der Draft Vorlage
|
||||||
|
$bookingDraftItem->booking_id = $booking->id;
|
||||||
|
$bookingDraftItem->draft_type_id = $draftItem->draft_type_id;
|
||||||
|
$bookingDraftItem->travel_program_id = null; // Wird später gesetzt wenn nötig
|
||||||
|
$bookingDraftItem->fewo_lodging_id = null;
|
||||||
|
$bookingDraftItem->travel_class_id = null;
|
||||||
|
$bookingDraftItem->draft_item_id = $draftItem->id;
|
||||||
|
$bookingDraftItem->request_date = null;
|
||||||
|
$bookingDraftItem->days_start = $draftItem->days_start;
|
||||||
|
$bookingDraftItem->days_duration = $draftItem->days_duration;
|
||||||
|
$bookingDraftItem->start_date = null; // Wird später basierend auf Reisebeginn gesetzt
|
||||||
|
$bookingDraftItem->end_date = null; // Wird später basierend auf Reiseende gesetzt
|
||||||
|
$bookingDraftItem->service = $draftItem->service;
|
||||||
|
$bookingDraftItem->price_adult = $draftItem->price_adult;
|
||||||
|
$bookingDraftItem->adult = $draftItem->adult;
|
||||||
|
$bookingDraftItem->price_children = $draftItem->price_children;
|
||||||
|
$bookingDraftItem->children = $draftItem->children;
|
||||||
|
$bookingDraftItem->price = 0; // Wird später berechnet
|
||||||
|
$bookingDraftItem->pos = $pos++;
|
||||||
|
$bookingDraftItem->in_pdf = $draftItem->in_pdf;
|
||||||
|
$bookingDraftItem->comfort = 0;
|
||||||
|
$bookingDraftItem->status = 1;
|
||||||
|
|
||||||
|
$bookingDraftItem->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preise neu berechnen
|
||||||
|
$booking->calculate_price_total();
|
||||||
|
|
||||||
|
return $booking;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3|^8.0",
|
"php": "^8.0|^8.2",
|
||||||
"bacon/bacon-qr-code": "^3.0",
|
"bacon/bacon-qr-code": "^3.0",
|
||||||
"barryvdh/laravel-dompdf": "*",
|
"barryvdh/laravel-dompdf": "*",
|
||||||
"cviebrock/eloquent-sluggable": "*",
|
"cviebrock/eloquent-sluggable": "*",
|
||||||
|
|
|
||||||
932
composer.lock
generated
113
docker-compose.yml
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
services:
|
||||||
|
laravel.test:
|
||||||
|
build:
|
||||||
|
context: ./vendor/laravel/sail/runtimes/8.2
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
WWWGROUP: '${WWWGROUP}'
|
||||||
|
image: sail-8.2/app
|
||||||
|
extra_hosts:
|
||||||
|
- 'host.docker.internal:host-gateway'
|
||||||
|
ports:
|
||||||
|
#- '${APP_PORT:-80}:80'
|
||||||
|
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
|
||||||
|
environment:
|
||||||
|
WWWUSER: '${WWWUSER}'
|
||||||
|
LARAVEL_SAIL: 1
|
||||||
|
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
|
||||||
|
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
|
||||||
|
IGNITION_LOCAL_SITES_PATH: '${PWD}'
|
||||||
|
volumes:
|
||||||
|
- '.:/var/www/html'
|
||||||
|
networks:
|
||||||
|
- sail
|
||||||
|
- proxy
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
- mysql-stern
|
||||||
|
- redis
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
# Hauptdomain
|
||||||
|
- "traefik.http.routers.meinsterntours.rule=Host(`mein.sterntours.test`)"
|
||||||
|
- "traefik.http.routers.meinsterntours.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.meinsterntours.tls=true"
|
||||||
|
- "traefik.http.routers.meinsterntours.service=meinsterntours-service"
|
||||||
|
# Service Definition - NUR EINMAL!
|
||||||
|
- "traefik.http.services.meinsterntours-service.loadbalancer.server.port=80"
|
||||||
|
- "traefik.docker.network=proxy"
|
||||||
|
mysql:
|
||||||
|
image: 'mysql/mysql-server:8.0'
|
||||||
|
ports:
|
||||||
|
- '${FORWARD_DB_PORT:-33064}:3306'
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
|
||||||
|
MYSQL_ROOT_HOST: '%'
|
||||||
|
MYSQL_DATABASE: '${DB_DATABASE}'
|
||||||
|
MYSQL_USER: '${DB_USERNAME}'
|
||||||
|
MYSQL_PASSWORD: '${DB_PASSWORD}'
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: 1
|
||||||
|
volumes:
|
||||||
|
- 'sail-mysql:/var/lib/mysql'
|
||||||
|
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
|
||||||
|
networks:
|
||||||
|
- sail
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
- CMD
|
||||||
|
- mysqladmin
|
||||||
|
- ping
|
||||||
|
- '-p${DB_PASSWORD}'
|
||||||
|
retries: 3
|
||||||
|
timeout: 5s
|
||||||
|
mysql-stern:
|
||||||
|
image: 'mysql/mysql-server:8.0'
|
||||||
|
ports:
|
||||||
|
- '${FORWARD_DB_PORT_STERN:-33065}:3306'
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD_STERN}'
|
||||||
|
MYSQL_ROOT_HOST: '%'
|
||||||
|
MYSQL_DATABASE: '${DB_DATABASE_STERN}'
|
||||||
|
MYSQL_USER: '${DB_USERNAME_STERN}'
|
||||||
|
MYSQL_PASSWORD: '${DB_PASSWORD_STERN}'
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: 1
|
||||||
|
volumes:
|
||||||
|
- 'sail-mysql-stern:/var/lib/mysql'
|
||||||
|
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
|
||||||
|
networks:
|
||||||
|
- sail
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
- CMD
|
||||||
|
- mysqladmin
|
||||||
|
- ping
|
||||||
|
- '-p${DB_PASSWORD_STERN}'
|
||||||
|
retries: 3
|
||||||
|
timeout: 5s
|
||||||
|
redis:
|
||||||
|
image: 'redis:alpine'
|
||||||
|
ports:
|
||||||
|
- '${FORWARD_REDIS_PORT:-6379}:6379'
|
||||||
|
volumes:
|
||||||
|
- 'sail-redis:/data'
|
||||||
|
networks:
|
||||||
|
- sail
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
- CMD
|
||||||
|
- redis-cli
|
||||||
|
- ping
|
||||||
|
retries: 3
|
||||||
|
timeout: 5s
|
||||||
|
networks:
|
||||||
|
sail:
|
||||||
|
driver: bridge
|
||||||
|
proxy:
|
||||||
|
external: true
|
||||||
|
volumes:
|
||||||
|
sail-mysql:
|
||||||
|
driver: local
|
||||||
|
sail-mysql-stern:
|
||||||
|
driver: local
|
||||||
|
sail-redis:
|
||||||
|
driver: local
|
||||||
|
|
@ -3,6 +3,5 @@
|
||||||
{
|
{
|
||||||
"path": "."
|
"path": "."
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"settings": {}
|
|
||||||
}
|
}
|
||||||
0
public/128.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
0
public/css/application-purple.css
Normal file → Executable file
0
public/css/application.css
Normal file → Executable file
0
public/css/stern_fewo_pdf.css
Normal file → Executable file
0
public/fonts/nunito.css
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-200.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-200.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
0
public/fonts/nunito/nunito-v25-latin-200.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-200.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-200.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-200italic.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-200italic.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
0
public/fonts/nunito/nunito-v25-latin-200italic.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-200italic.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-200italic.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-300.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-300.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
0
public/fonts/nunito/nunito-v25-latin-300.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-300.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-300.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-300italic.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-300italic.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
0
public/fonts/nunito/nunito-v25-latin-300italic.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-300italic.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-300italic.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-500.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-500.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
0
public/fonts/nunito/nunito-v25-latin-500.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-500.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-500.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-500italic.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-500italic.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
0
public/fonts/nunito/nunito-v25-latin-500italic.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-500italic.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-500italic.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-600.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-600.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
0
public/fonts/nunito/nunito-v25-latin-600.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-600.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-600.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-600italic.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-600italic.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
0
public/fonts/nunito/nunito-v25-latin-600italic.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-600italic.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-600italic.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-700.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-700.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
0
public/fonts/nunito/nunito-v25-latin-700.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-700.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-700.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-700italic.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-700italic.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
0
public/fonts/nunito/nunito-v25-latin-700italic.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-700italic.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-700italic.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-800.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-800.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
0
public/fonts/nunito/nunito-v25-latin-800.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-800.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-800.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-800italic.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-800italic.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
0
public/fonts/nunito/nunito-v25-latin-800italic.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-800italic.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-800italic.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-900.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-900.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
0
public/fonts/nunito/nunito-v25-latin-900.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-900.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-900.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-900italic.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-900italic.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
0
public/fonts/nunito/nunito-v25-latin-900italic.ttf
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-900italic.woff
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-900italic.woff2
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-italic.eot
Normal file → Executable file
0
public/fonts/nunito/nunito-v25-latin-italic.svg
Normal file → Executable file
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |