138 lines
4.9 KiB
PHP
Executable file
138 lines
4.9 KiB
PHP
Executable file
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
use Carbon;
|
|
use Request;
|
|
use Response;
|
|
use App\Models\Coupon;
|
|
use App\Services\Util;
|
|
use App\Models\FewoLodging;
|
|
use App\Libraries\CreatePDF;
|
|
use App\Models\BookingStorno;
|
|
use App\Services\BookingFewo;
|
|
use App\Models\BookingVoucher;
|
|
use App\Models\TravelInsurance;
|
|
use App\Libraries\CreateCouponPDF;
|
|
use App\Models\BookingApplication;
|
|
use App\Models\BookingConfirmation;
|
|
use Illuminate\Support\Facades\URL;
|
|
use App\Models\BookingVoucherAgency;
|
|
use App\Models\InsuranceCertificate;
|
|
use App\Repositories\CustomerFileRepository;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
|
class CustomerFileController extends Controller
|
|
{
|
|
|
|
protected $customerFileRepo;
|
|
|
|
public function __construct(CustomerFileRepository $customerFileRepo)
|
|
{
|
|
$this->customerFileRepo = $customerFileRepo;
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$data = [
|
|
|
|
];
|
|
return view('customer.mail.index', $data);
|
|
}
|
|
|
|
public function show($model, $id, $cd = false){
|
|
|
|
$content_disposition = $cd ? 'attachment' : 'inline';
|
|
$file = false;
|
|
$filename = "";
|
|
|
|
switch ($model){
|
|
case 'registration':
|
|
if($booking_application = BookingApplication::find($id)){
|
|
$filename = "Buchungsauftrag-".$booking_application->booking->getBookingNumber().".pdf";
|
|
$file = base64_decode($booking_application->binary_data);
|
|
}
|
|
break;
|
|
case 'confirmation':
|
|
if($booking_confirmation = BookingConfirmation::find($id)){
|
|
$filename = "Reisebestaetigung-".$booking_confirmation->booking->getBookingNumber().".pdf";
|
|
$file = base64_decode($booking_confirmation->binary_data);
|
|
}
|
|
break;
|
|
case 'storno':
|
|
if($booking_stornos = BookingStorno::find($id)){
|
|
$filename = "Reisestornierung-".$booking_stornos->booking->getBookingNumber().".pdf";
|
|
$file = base64_decode($booking_stornos->binary_data);
|
|
}
|
|
break;
|
|
case 'coupon':
|
|
if($coupon = Coupon::find($id)){
|
|
$filename = "Gutschein-".$coupon->number.".pdf";
|
|
$pdf = new CreateCouponPDF($coupon);
|
|
$pdf->create();
|
|
return $pdf->output($filename, $cd);
|
|
|
|
}
|
|
break;
|
|
case 'voucher':
|
|
if($booking_voucher = BookingVoucher::find($id)){
|
|
$filename = "Voucher-".$booking_voucher->booking->getBookingNumber().".pdf";
|
|
$file = base64_decode($booking_voucher->binary_data);
|
|
}
|
|
break;
|
|
|
|
case 'voucher_agency':
|
|
if($booking_voucher_agency = BookingVoucherAgency::find($id)){
|
|
$filename = "Voucher-Agentur-".$booking_voucher_agency->booking->getBookingNumber().".pdf";
|
|
$file = base64_decode($booking_voucher_agency->binary_data);
|
|
}
|
|
break;
|
|
case 'insurance_certificate':
|
|
if($insurance_certificate = InsuranceCertificate::find($id)){
|
|
$filename = $insurance_certificate->filename;
|
|
$file = base64_decode($insurance_certificate->binary_data);
|
|
}
|
|
break;
|
|
case 'travel_insurance':
|
|
if($booking_application = TravelInsurance::find($id)){
|
|
$filename = "Buchungsauftrag-".$booking_application->booking->getBookingNumber().".pdf";
|
|
$file = base64_decode($booking_application->binary_data);
|
|
}
|
|
break;
|
|
|
|
case 'fewo_instruction_pdf':
|
|
$fewo = FewoLodging::findOrFail($id);
|
|
$identifier_content = config('fewo.identifier_content');
|
|
$identifier_fewo = config('fewo.identifier_fewo');
|
|
$identifier_fewo = $identifier_fewo.Util::sanitize($fewo->pdf_name);
|
|
$pdf_name = \App\Services\BookingFewo::getFeWoInstructionPDFName($fewo);
|
|
$pdf_content = BookingFewo::getFeWoCMSContentForPDF($identifier_content, $identifier_fewo);
|
|
$pdf_file = new CreatePDF('pdf.fewo_instructions');
|
|
return $pdf_file->create([
|
|
'contents' => $pdf_content,
|
|
'fewo' => $fewo
|
|
], $pdf_name, $cd);
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
if($file){
|
|
return Response::make($file, 200, [
|
|
'Content-Type' => 'application/pdf',
|
|
'Content-Disposition' => $content_disposition.'; filename="'.$filename.'"'
|
|
]);
|
|
}
|
|
|
|
die( 'error' );
|
|
}
|
|
|
|
|
|
//$path = storage_path($filename); //file_get_contents($path)
|
|
|
|
//return response()->file($pathToFile, $headers);
|
|
//return response()->download($pathToFile, $name, $headers);
|
|
}
|
|
|
|
|