Fewo PDF Hinweise, Generator, Anhang Mail
This commit is contained in:
parent
a3bef8d1aa
commit
730832c8e1
31 changed files with 1786 additions and 147 deletions
164
app/Http/Controllers/CMS/CMSFeWoController.php
Executable file
164
app/Http/Controllers/CMS/CMSFeWoController.php
Executable file
|
|
@ -0,0 +1,164 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\CMS;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\FewoLodging;
|
||||
use App\Services\BookingFewo;
|
||||
use App\Services\CreatePDF;
|
||||
use App\Services\Util;
|
||||
use Request;
|
||||
|
||||
|
||||
class CMSFeWoController extends Controller
|
||||
{
|
||||
|
||||
protected $identifier_content;
|
||||
protected $identifier_fewo;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->identifier_content = config('fewo.identifier_content');
|
||||
$this->identifier_fewo = config('fewo.identifier_fewo');
|
||||
}
|
||||
/*
|
||||
* ALL
|
||||
*/
|
||||
public function all($step = false)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'contents' => CMSContent::where('identifier', '=', $this->identifier_content)->get()->sortBy('pos'),
|
||||
'identifier_content' => $this->identifier_content,
|
||||
'step' => $step
|
||||
];
|
||||
return view('cms.fewo.all.index', $data);
|
||||
}
|
||||
|
||||
public function storeAll($step = false)
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
/*if($data['action'] === 'saveAll') {
|
||||
//saveAll on each change
|
||||
}*/
|
||||
$i = 1;
|
||||
if(isset($data['contents'] )) {
|
||||
foreach ($data['contents'] as $content_id => $item) {
|
||||
$content = CMSContent::findOrFail($content_id);
|
||||
$content->setObjectBy('page-break', (isset($item['page-break']) ? true : false));
|
||||
$content->name = $item['name'];
|
||||
$content->slug = null;
|
||||
$content->decimal = isset($item['in_pdf']) ? 1 : 0;
|
||||
$content->full_text = $item['full_text'];
|
||||
$content->pos = $i++;
|
||||
$content->save();
|
||||
}
|
||||
}
|
||||
//last
|
||||
if($data['action'] === 'addItem'){
|
||||
$create = [
|
||||
'name' => 'Abschnitt',
|
||||
'field' => 'full_text',
|
||||
'decimal' => 1,
|
||||
'identifier' => $this->identifier_content,
|
||||
'pos' => $i,
|
||||
];
|
||||
CMSContent::create($create);
|
||||
//store in cms old Datebase
|
||||
\App\Models\Sym\CmsContent::create($create);
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('cms_fewo_all', [$step]));
|
||||
}
|
||||
|
||||
public function deleteAll($id){
|
||||
$content = CMSContent::findOrFail($id);
|
||||
$content->delete();
|
||||
$m = \App\Models\Sym\CmsContent::find($id);
|
||||
$m->delete();
|
||||
\Session()->flash('alert-success', __('Content gelöscht'));
|
||||
return back(); //redirect(route('cms_content_all'));
|
||||
}
|
||||
/*
|
||||
* CONTENT
|
||||
*/
|
||||
public function content()
|
||||
{
|
||||
$data = [
|
||||
'fewo_lodgings' => FewoLodging::all()
|
||||
];
|
||||
return view('cms.fewo.content.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id, $step = false)
|
||||
{
|
||||
$fewo = FewoLodging::findOrFail($id);
|
||||
$identifier_fewo = $this->identifier_fewo.Util::sanitize($fewo->single_name); // //this->identifier_fewo = 'fewo-pdf-';
|
||||
|
||||
$data = [
|
||||
'contents' => CMSContent::where('identifier', '=', $this->identifier_content)->get()->sortBy('pos'),
|
||||
'fewo' => $fewo,
|
||||
'identifier_content' => $this->identifier_content,
|
||||
'identifier_fewo' => $identifier_fewo,
|
||||
'step' => $step
|
||||
];
|
||||
return view('cms.fewo.content.detail', $data);
|
||||
}
|
||||
|
||||
public function store($id, $step = false)
|
||||
{
|
||||
$data = Request::all();
|
||||
$fewo = FewoLodging::findOrFail($id);
|
||||
$identifier_fewo = $this->identifier_fewo.Util::sanitize($fewo->single_name);
|
||||
|
||||
$i = 1;
|
||||
$last_content_id = null;
|
||||
if(isset($data['contents'] )) {
|
||||
foreach ($data['contents'] as $content_id => $item) {
|
||||
$content = CMSContent::findOrFail($content_id);
|
||||
if ($item['identifier'] === $this->identifier_content) {
|
||||
$last_content_id = $content->id;
|
||||
}
|
||||
if ($item['identifier'] === $identifier_fewo) {
|
||||
$content->setObjectBy('page-break', (isset($item['page-break']) ? true : false));
|
||||
$content->name = $item['name'];
|
||||
$content->slug = null;
|
||||
$content->decimal = isset($item['in_pdf']) ? 1 : 0;
|
||||
$content->full_text = $item['full_text'];
|
||||
$content->integer = $last_content_id != null ? $last_content_id : $content->integer; //is the main obj
|
||||
$content->pos = $i++;
|
||||
$content->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($data['action'] === 'previewPDF'){
|
||||
$pdf_content = BookingFewo::getFeWoCMSContentForPDF($this->identifier_content, $identifier_fewo);
|
||||
$pdf_file = new CreatePDF('pdf.fewo_instructions');
|
||||
return $pdf_file->create($fewo, $pdf_content);
|
||||
}
|
||||
|
||||
if($data['action'] === 'addItem' && isset($data['content_pos_id'])) {
|
||||
$create = [
|
||||
'name' => 'Abschnitt',
|
||||
'field' => 'full_text',
|
||||
'decimal' => 1,
|
||||
'integer' => $data['content_pos_id'],
|
||||
'identifier' => $identifier_fewo,
|
||||
'pos' => 0,
|
||||
];
|
||||
CMSContent::create($create);
|
||||
//store in cms old Datebase
|
||||
\App\Models\Sym\CmsContent::create($create);
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('cms_fewo_content_detail', [$id, $step]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,10 +8,14 @@ use App\Models\BookingConfirmation;
|
|||
use App\Models\BookingStorno;
|
||||
use App\Models\BookingVoucher;
|
||||
use App\Models\Coupon;
|
||||
use App\Models\FewoLodging;
|
||||
use App\Models\InsuranceCertificate;
|
||||
use App\Models\TravelInsurance;
|
||||
use App\Repositories\CustomerFileRepository;
|
||||
use App\Services\BookingFewo;
|
||||
use App\Services\CreateCouponPDF;
|
||||
use App\Services\CreatePDF;
|
||||
use App\Services\Util;
|
||||
use Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
|
@ -39,7 +43,6 @@ class CustomerFileController extends Controller
|
|||
public function show($model, $id, $cd = false){
|
||||
|
||||
$content_disposition = $cd ? 'attachment' : 'inline';
|
||||
|
||||
$file = false;
|
||||
$filename = "";
|
||||
switch ($model){
|
||||
|
|
@ -90,6 +93,18 @@ class CustomerFileController extends Controller
|
|||
}
|
||||
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->single_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($fewo, $pdf_content, $pdf_name, $cd);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class DraftController extends Controller
|
|||
$i = 1;
|
||||
if(isset($data['draft_item'])){
|
||||
foreach ($data['draft_item'] as $draft_item_id => $draft_item){
|
||||
if($data['action'] == 'saveAllFromOld'){
|
||||
if($data['action'] === 'saveAllFromOld'){
|
||||
$di = $draft->draft_items()->create([]);
|
||||
}else{
|
||||
$di = DraftItem::findOrFail($draft_item_id);
|
||||
|
|
@ -82,7 +82,7 @@ class DraftController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
if($data['action'] == 'addItem'){
|
||||
if($data['action'] === 'addItem'){
|
||||
$draft->draft_items()->create(['pos' => $i]);
|
||||
}
|
||||
if(strpos($data['action'], 'up_') !== false) {
|
||||
|
|
|
|||
|
|
@ -21,14 +21,13 @@ use Request;
|
|||
class TravelUserBookingFewoController extends Controller
|
||||
{
|
||||
protected $userBookingFewoRepo;
|
||||
// protected $identifier_fewo;
|
||||
|
||||
public function __construct(TravelUserBookingFewoRepository $userBookingFewoRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->userBookingFewoRepo = $userBookingFewoRepo;
|
||||
|
||||
|
||||
|
||||
// $this->identifier_fewo = 'fewo-pdf-';
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
|
|
@ -59,6 +58,11 @@ class TravelUserBookingFewoController extends Controller
|
|||
$id = $travel_user_booking_fewo->id;
|
||||
$replace_info_text['fewo_user_anrede'] = $travel_user_booking_fewo->getUserSalutation();
|
||||
$replace_info_text['fewo_adresse'] = $travel_user_booking_fewo->getNameAddressLocation(", ");
|
||||
|
||||
/* if($travel_user_booking_fewo->fewo_lodging){
|
||||
|
||||
$this->identifier_fewo = $this->identifier_fewo.Util::sanitize($travel_user_booking_fewo->fewo_lodging->single_name);
|
||||
}*/
|
||||
}
|
||||
if(!$travel_user_booking_fewo->info_mail_text) {
|
||||
$travel_user_booking_fewo->info_mail_text = CMSContent::getContentBySlug('pdf-vorlage-anreiseinfo-fewo');
|
||||
|
|
@ -78,10 +82,10 @@ class TravelUserBookingFewoController extends Controller
|
|||
public function store($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
if($data['action'] == 'saveAll'){
|
||||
if($data['action'] === 'saveAll'){
|
||||
return $this->userBookingFewoRepo->update($id, $data);
|
||||
}
|
||||
if($data['action'] == 'createInvoice'){
|
||||
if($data['action'] === 'createInvoice'){
|
||||
if(!TravelUserBookingFewo::find($id)){
|
||||
\Session()->flash('alert-error', __('Buchung nicht gefunden.'));
|
||||
return back()->withRequest(Request::all());
|
||||
|
|
@ -97,7 +101,7 @@ class TravelUserBookingFewoController extends Controller
|
|||
|
||||
}
|
||||
}
|
||||
if($data['action'] == 'createTravelInfo'){
|
||||
if($data['action'] === 'createTravelInfo'){
|
||||
if(!TravelUserBookingFewo::find($id)){
|
||||
\Session()->flash('alert-error', __('Buchung nicht gefunden.'));
|
||||
return back()->withRequest(Request::all());
|
||||
|
|
@ -114,7 +118,7 @@ class TravelUserBookingFewoController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
if($data['action'] == 'sendMailtoUser') {
|
||||
if($data['action'] === 'sendMailtoUser') {
|
||||
$travel_user_booking_fewo = TravelUserBookingFewo::findOrFail($id);
|
||||
if($travel_user_booking_fewo->travel_user_id && $travel_user_booking_fewo->travel_user->email){
|
||||
$mail_bbc = config('mail.mail_bbc');
|
||||
|
|
@ -128,7 +132,7 @@ class TravelUserBookingFewoController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
if($data['action'] == 'sendInfosMailtoUser') {
|
||||
if($data['action'] === 'sendInfosMailtoUser') {
|
||||
$travel_user_booking_fewo = TravelUserBookingFewo::findOrFail($id);
|
||||
if($travel_user_booking_fewo->travel_user_id && $travel_user_booking_fewo->travel_user->email){
|
||||
$mail_bbc = config('mail.mail_bbc');
|
||||
|
|
@ -142,7 +146,7 @@ class TravelUserBookingFewoController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
if($data['action'] == 'sendMailtoService') {
|
||||
if($data['action'] === 'sendMailtoService') {
|
||||
$travel_user_booking_fewo = TravelUserBookingFewo::findOrFail($id);
|
||||
if($travel_user_booking_fewo){
|
||||
$mail_bbc = config('mail.mail_bbc');
|
||||
|
|
@ -160,7 +164,7 @@ class TravelUserBookingFewoController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
if($data['action'] == 'sendMailtoEmployee') {
|
||||
if($data['action'] === 'sendMailtoEmployee') {
|
||||
$travel_user_booking_fewo = TravelUserBookingFewo::findOrFail($id);
|
||||
if($travel_user_booking_fewo){
|
||||
$mails = explode(",", Request::get('send_mail_employee_mail'));
|
||||
|
|
@ -220,7 +224,6 @@ class TravelUserBookingFewoController extends Controller
|
|||
|
||||
public function getTravelUserBookingFewos()
|
||||
{
|
||||
|
||||
$query = $this->prozessTravelUserBookingFewosSearch();
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue