FeWo Mail, Booking Services

This commit is contained in:
Kevin Adametz 2020-07-09 12:36:15 +02:00
parent 730832c8e1
commit e6cc042aee
62 changed files with 1766 additions and 284 deletions

View file

@ -98,7 +98,7 @@ class CMSFeWoController extends Controller
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-';
$identifier_fewo = $this->identifier_fewo.Util::sanitize($fewo->pdf_name); // //this->identifier_fewo = 'fewo-pdf-';
$data = [
'contents' => CMSContent::where('identifier', '=', $this->identifier_content)->get()->sortBy('pos'),
@ -114,7 +114,7 @@ class CMSFeWoController extends Controller
{
$data = Request::all();
$fewo = FewoLodging::findOrFail($id);
$identifier_fewo = $this->identifier_fewo.Util::sanitize($fewo->single_name);
$identifier_fewo = $this->identifier_fewo.Util::sanitize($fewo->pdf_name);
$i = 1;
$last_content_id = null;

View file

@ -97,7 +97,7 @@ class CustomerFileController extends Controller
$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);
$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');

View file

@ -3,6 +3,8 @@
namespace App\Http\Controllers;
use App\Models\GeneralFile;
use App\Models\ServiceProviderService;
use App\Models\TravelCompanyService;
use App\Models\TravelCountry;
use App\Models\TravelCountryService;
use App\Repositories\GeneralFileRepository;
@ -48,6 +50,26 @@ class ModalController extends Controller
$ret = view("admin.modal.country-service", compact('data', 'value'))->render();
}
if($data['action'] === 'modal-travel_company-services'){
if($data['id'] === 'new'){
$value = new TravelCompanyService();
$value->active = true;
}else{
$value = TravelCompanyService::find($data['id']);
}
$ret = view("admin.modal.company-service", compact('data', 'value'))->render();
}
if($data['action'] === 'modal-service_provider-services'){
if($data['id'] === 'new'){
$value = new ServiceProviderService();
$value->active = true;
}else{
$value = ServiceProviderService::find($data['id']);
}
$ret = view("admin.modal.provider-service", compact('data', 'value'))->render();
}
}
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);

View file

@ -233,14 +233,55 @@ class RequestController extends Controller
$booking = Booking::findOrFail($data['booking_id']);
$ret = "";
$count = false;
foreach($booking->travel_country->getContactLandsModels() as $TravelCountry){
if($TravelCountry->stern_travel_country){
$hl = $TravelCountry->stern_travel_country->name."<br>";
$tmp = "";
foreach($TravelCountry->stern_travel_country->travel_country_services as $travel_country_service){
$ret .= \App\Models\BookingCountryService::getStatus($travel_country_service->id, $booking->id) ?
$tmp .= \App\Models\BookingCountryService::getStatus($travel_country_service->id, $booking->id) ?
'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$travel_country_service->name.'</span>' :
'<span class="badge badge-pill badge-danger""><i class="fa fa-times"></i> '.$travel_country_service->name.'</span>';
$ret .= '<br>';
$tmp .= '<br>';
}
if($tmp !== ""){
$ret .= $hl.$tmp;
}
}
}
if($booking->service_provider_entries->count()){
foreach($booking->service_provider_entries as $service_provider_entry){
if($service_provider_entry->service_provider->service_provider_services->count()){
$hl = $service_provider_entry->service_provider->name."<br>";
$tmp = "";
foreach($service_provider_entry->service_provider->service_provider_services as $service_provider_service){
$tmp .= \App\Models\BookingProviderService::getStatus($service_provider_service->id, $booking->id) ?
'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$service_provider_service->name.'</span>' :
'<span class="badge badge-pill badge-danger""><i class="fa fa-times"></i> '.$service_provider_service->name.'</span>';
$tmp .= '<br>';
}
if($tmp !== ""){
$ret .= $hl.$tmp;
}
}
}
}
if($booking->booking_service_items->count()){
foreach($booking->booking_service_items as $booking_service_item){
if($booking_service_item->travel_company->travel_company_services->count()){
$hl = $booking_service_item->travel_company->name."<br>";
$tmp = "";
foreach($booking_service_item->travel_company->travel_company_services as $travel_company_service){
$tmp .= \App\Models\BookingCompanyService::getStatus($travel_company_service->id, $booking->id) ?
'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$travel_company_service->name.'</span>' :
'<span class="badge badge-pill badge-danger""><i class="fa fa-times"></i> '.$travel_company_service->name.'</span>';
$tmp .= '<br>';
}
if($tmp !== ""){
$ret .= $hl.$tmp;
}
}
}
}
@ -317,9 +358,9 @@ class RequestController extends Controller
->addColumn('travel_documents', function (Booking $booking) {
return $booking->travel_documents ? '<span data-order="1" class="badge badge-pill badge-success" title="Reiseunterlagen" data-placement="top" rel="tooltip"><i class="fa fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger" title="Reiseunterlagen" data-placement="top" rel="tooltip"><i class="fa fa-times"></i></span>';
})
->addColumn('booking_country_services', function (Booking $booking) {
return $booking->hasBookingCountryServicesUnchecked() ? '<span data-order="1" class="badge badge-pill badge-success" data-booking_id="'.$booking->id.'" data-placement="top" data-toggle="popover" title="Reise-, Agenturleistungen"><i class="fa fa-check"></i></span>' :
'<span data-order="0" class="badge badge-pill badge-danger" data-booking_id="'.$booking->id.'" data-placement="top" data-toggle="popover" title="Reise-, Agenturleistungen"><i class="fa fa-times"></i></span>';
->addColumn('booking_services', function (Booking $booking) {
return $booking->hasBookingServicesUnchecked() ? '<span data-order="1" class="badge badge-pill badge-success" data-booking_id="'.$booking->id.'" data-placement="top" data-toggle="popover" title="ServiceLeistungen"><i class="fa fa-check"></i></span>' :
'<span data-order="0" class="badge badge-pill badge-danger" data-booking_id="'.$booking->id.'" data-placement="top" data-toggle="popover" title="ServiceLeistungen"><i class="fa fa-times"></i></span>';
})
->addColumn('sf_guard_user_id', function (Booking $booking) {
@ -421,7 +462,7 @@ class RequestController extends Controller
->orderColumn('hold', 'hold $1')
->orderColumn('xx_tkt', 'xx_tkt_date $1')
//->orderColumn('travel_documents', 'travel_documents $1')
->rawColumns(['action_lead_edit', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'travel_company_id', 'sf_guard_user_id', 'lead.status_id', 'last_customer_email', 'id', 'travel_documents', 'booking_country_services', 'paying_out', 'paying_out_status', 'airline_id', 'refund', 'hold', 'xx_tkt'])
->rawColumns(['action_lead_edit', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'travel_company_id', 'sf_guard_user_id', 'lead.status_id', 'last_customer_email', 'id', 'travel_documents', 'booking_services', 'paying_out', 'paying_out_status', 'airline_id', 'refund', 'hold', 'xx_tkt'])
->make(true);
}
}

View file

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller;
use App\Models\ServiceProvider;
use App\Models\ServiceProviderService;
use App\Services\Util;
use Request;
@ -24,31 +25,87 @@ class ServiceProviderController extends Controller
}
public function update(){
public function detail($id, $step = false)
{
if($id === "new") {
$model = new ServiceProvider();
$id = 'new';
$model->active = 1;
}else{
$model = ServiceProvider::findOrFail($id);
$id = $model->id;
}
$data = [
'model' => $model,
'id' => $id,
'step' => $step,
];
return view('settings.service_provider.detail', $data);
}
public function update($id){
$data = Request::all();
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
$data['active'] = isset($data['active']) ? true : false;
if($data['id'] === "new"){
if(isset($data['update-action'])){
if($data['update-action'] === 'save-service-provider-service'){
$data['active'] = true;//isset($data['active']) ? true : false;
$service_provider = ServiceProvider::findOrFail($id);
$data['service_provider_id'] = $service_provider->id;
if($data['service_provider_service_id'] === 'new'){
$model = ServiceProviderService::create($data);
}else{
$model = ServiceProviderService::find($data['service_provider_service_id']);
$model->fill($data);
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect($data['back']);
}
}
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
if($id === "new"){
$model = ServiceProvider::create($data);
}else{
$model = ServiceProvider::find($data['id']);
$model = ServiceProvider::find($id);
$model->fill($data);
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_settings_service_provider'));
return redirect(route('admin_settings_service_provider_detail', [$model->id, $data['action']]));
}
public function delete($id){
public function delete($id, $del="service_provider"){
abort(404, 'Noch keine Funktion');
$model = ServiceProvider::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect()->back();
if($del === 'service_provider') {
abort(404, 'Noch keine Funktion');
$model = ServiceProvider::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect()->back();
}
if($del === 'provider_service'){
$service = ServiceProviderService::findOrFail($id);
$service_provider = $service->service_provider;
//check as entry
if($service->booking_provider_services->count() > 0){
\Session()->flash('alert-error', 'Die Leistung kann nicht gelöscht werden, diese hat Einträge bei den Buchungen');
return redirect(route('admin_settings_service_provider_detail', [$service_provider->id, 'services']));
}
$service->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_settings_service_provider_detail', [$service_provider->id, 'services']));
}
}

View file

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller;
use App\Models\TravelCompany;
use App\Models\TravelCompanyService;
use App\Services\Util;
use Request;
@ -24,33 +25,85 @@ class TravelCompanyController extends Controller
}
public function update(){
public function detail($id, $step = false)
{
if($id === "new") {
$model = new TravelCompany();
$id = 'new';
$model->active = 1;
}else{
$model = TravelCompany::findOrFail($id);
$id = $model->id;
}
$data = [
'model' => $model,
'id' => $id,
'step' => $step,
];
return view('settings.travel_company.detail', $data);
}
public function update($id){
$data = Request::all();
if(isset($data['update-action'])){
if($data['update-action'] === 'save-travel-company-service'){
$data['active'] = true;//isset($data['active']) ? true : false;
$travel_company = TravelCompany::findOrFail($id);
$data['travel_company_id'] = $travel_company->id;
if($data['travel_company_service_id'] === 'new'){
$model = TravelCompanyService::create($data);
}else{
$model = TravelCompanyService::find($data['travel_company_service_id']);
$model->fill($data);
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect($data['back']);
}
}
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
$data['active'] = isset($data['active']) ? true : false;
$data['is_allowed_edit_commission'] = isset($data['is_allowed_edit_commission']) ? true : false;
$data['is_inhouse'] = isset($data['is_inhouse']) ? true : false;
if($data['id'] === "new"){
if($id === "new"){
$model = TravelCompany::create($data);
}else{
$model = TravelCompany::find($data['id']);
$model = TravelCompany::find($id);
$model->fill($data);
$model->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('admin_settings_travel_company'));
return redirect(route('admin_settings_travel_company_detail', [$model->id, $data['action']]));
}
public function delete($id){
public function delete($id, $del="travel_company"){
abort(404, 'Noch keine Funktion');
$model = TravelCompany::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect()->back();
if($del === 'travel_country') {
abort(404, 'Noch keine Funktion');
$model = TravelCompany::findOrFail($id);
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect()->back();
}
if($del === 'company_service'){
$service = TravelCompanyService::findOrFail($id);
$travel_company = $service->travel_company;
//check as entry
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');
return redirect(route('admin_settings_travel_company_detail', [$travel_company->id, 'services']));
}
$service->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect(route('admin_settings_travel_company_detail', [$travel_company->id, 'services']));
}
}
}

View file

@ -140,9 +140,6 @@ class ContentLinkController extends Controller
return redirect()->back();
}
public function h1ToTitleTravelGuide()
{
$TravelGuides = TravelGuide::all();

View file

@ -61,7 +61,7 @@ class TravelUserBookingFewoController extends Controller
/* if($travel_user_booking_fewo->fewo_lodging){
$this->identifier_fewo = $this->identifier_fewo.Util::sanitize($travel_user_booking_fewo->fewo_lodging->single_name);
$this->identifier_fewo = $this->identifier_fewo.Util::sanitize($travel_user_booking_fewo->fewo_lodging->pdf_name);
}*/
}
if(!$travel_user_booking_fewo->info_mail_text) {
@ -187,13 +187,27 @@ class TravelUserBookingFewoController extends Controller
if($del === 'travel_user_booking_fewo') {
$model = TravelUserBookingFewo::findOrFail($id);
//Reservations
$FewoReservations = FewoReservation::where('lodging_id', $model->fewo_lodging_id)->where('from_date', $model->getFromDateRaw())->where('to_date', $model->getToDateRaw())->get();
foreach ($FewoReservations as $FewoReservation) {
$FewoReservation->delete();
}
//Files
$FewoFiles = TravelUserBookingFile::where('travel_user_booking_fewo_id', $model->id)->get();
foreach ($FewoFiles as $file) {
$fileRepo = new BookingFewoFileRepository($file);
$fileRepo->_set('disk', 'booking_fewo');
$fileRepo->delete();
$file->delete();
}
//Mails
//CASCADE
$model->delete();
\Session()->flash('alert-success', __('Buchung gelöscht sowie die Reservierung im Sterntrous Kalender'));
}
if($del === 'booking_fewo_files'){
$booking_fewo_file = TravelUserBookingFile::findOrFail($id);
$travel_user_booking_fewo = $booking_fewo_file->travel_user_booking_fewo;

View file

@ -163,6 +163,10 @@ use Illuminate\Database\Eloquent\Model;
* @property-read int|null $booking_files_count
* @property float|null $price_balance
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking wherePriceBalance($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingCountryService[] $booking_country_services
* @property-read int|null $booking_country_services_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingCountryService[] $booking_country_services_checked
* @property-read int|null $booking_country_services_checked_count
*/
class Booking extends Model
{
@ -484,12 +488,45 @@ class Booking extends Model
return $this->hasMany(BookingCountryService::class, 'booking_id')->where('status', '=', 0);
}
public function hasBookingCountryServicesUnchecked(){
public function booking_company_services()
{
return $this->hasMany(BookingCompanyService::class, 'booking_id');
}
public function booking_company_services_checked()
{
return $this->hasMany(BookingCompanyService::class, 'booking_id')->where('status', '=', 0);
}
public function booking_provider_services()
{
return $this->hasMany(BookingProviderService::class, 'booking_id');
}
public function booking_provider_services_checked()
{
return $this->hasMany(BookingProviderService::class, 'booking_id')->where('status', '=', 0);
}
public function hasBookingServicesUnchecked(){
$country_services = true;
$provider_services = true;
$company_services = true;
if(!$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())){
return false;
$country_services = false;
}
return true;
if(!$this->booking_provider_services->count() || $this->booking_provider_services_checked->count()){
$provider_services = false;
}
if(!$this->booking_company_services->count() || $this->booking_company_services_checked->count()){
$company_services = false;
}
if($country_services && $provider_services && $provider_services){
return true;
}
return false;
}
public function calculate_price_total()
@ -662,7 +699,7 @@ class Booking extends Model
{
$total = 0;
foreach ($this->service_provider_entries as $entry){
$total += $entry->amount / $entry->factor;
$total += $entry->getAmountRaw() / $entry->factor;
}
return $raw ? $total : Util::_number_format($total);
}
@ -671,7 +708,7 @@ class Booking extends Model
{
$total = 0;
foreach ($this->service_provider_entries as $entry){
$total += $entry->amount;
$total += $entry->getAmountRaw();
}
return $raw ? $total : Util::_number_format($total);
}

View file

@ -0,0 +1,77 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class BookingCompanyService
*
* @property int $id
* @property int $travel_company_service_id
* @property int $booking_id
* @property int $status
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Booking $booking
* @property TravelCompanyService $travel_company_service
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCompanyService newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCompanyService newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCompanyService query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCompanyService whereBookingId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCompanyService whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCompanyService whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCompanyService whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCompanyService whereTravelCompanyServiceId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCompanyService whereUpdatedAt($value)
* @mixin \Eloquent
*/
class BookingCompanyService extends Model
{
protected $connection = 'mysql';
protected $table = 'booking_company_services';
protected $casts = [
'travel_company_service_id' => 'int',
'booking_id' => 'int',
'status' => 'int'
];
protected $fillable = [
'travel_company_service_id',
'booking_id',
'status'
];
protected $status_type = [
0 => 'offen',
1 => 'erledigt',
];
public function booking()
{
return $this->belongsTo(Booking::class);
}
public function travel_company_service()
{
return $this->belongsTo(TravelCompanyService::class);
}
public static function getStatus($travel_company_service_id, $booking_id){
$service = BookingCompanyService::where('travel_company_service_id', '=', $travel_company_service_id)
->where('booking_id', '=', $booking_id)->first();
if($service){
return $service->status;
}
return 0;
}
}

View file

@ -29,6 +29,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereTravelCountryServiceId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereUpdatedAt($value)
* @mixin \Eloquent
* @property int|null $status
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereStatus($value)
*/
class BookingCountryService extends Model
{
@ -64,11 +66,11 @@ class BookingCountryService extends Model
}
public static function getStatus($travel_country_service_id, $booking_id){
$booking_country_service = BookingCountryService::where('travel_country_service_id', '=', $travel_country_service_id)
$service = BookingCountryService::where('travel_country_service_id', '=', $travel_country_service_id)
->where('booking_id', '=', $booking_id)->first();
if($booking_country_service){
return $booking_country_service->status;
if($service){
return $service->status;
}
return 0;
}

View file

@ -0,0 +1,77 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class BookingProviderService
*
* @property int $id
* @property int $service_provider_service_id
* @property int $booking_id
* @property int $status
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Booking $booking
* @property ServiceProviderService $service_provider_service
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingProviderService newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingProviderService newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingProviderService query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingProviderService whereBookingId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingProviderService whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingProviderService whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingProviderService whereServiceProviderServiceId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingProviderService whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingProviderService whereUpdatedAt($value)
* @mixin \Eloquent
*/
class BookingProviderService extends Model
{
protected $connection = 'mysql';
protected $table = 'booking_provider_services';
protected $casts = [
'service_provider_service_id' => 'int',
'booking_id' => 'int',
'status' => 'int'
];
protected $fillable = [
'service_provider_service_id',
'booking_id',
'status'
];
protected $status_type = [
0 => 'offen',
1 => 'erledigt',
];
public function booking()
{
return $this->belongsTo(Booking::class);
}
public function service_provider_service()
{
return $this->belongsTo(ServiceProviderService::class);
}
public static function getStatus($service_provider_service_id, $booking_id){
$service = BookingProviderService::where('service_provider_service_id', '=', $service_provider_service_id)
->where('booking_id', '=', $booking_id)->first();
if($service){
return $service->status;
}
return 0;
}
}

View file

@ -43,9 +43,16 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereTravelUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereUpdatedAt($value)
* @mixin \Eloquent
* @property \Illuminate\Support\Carbon|null $deleted_at
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoFile onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereDeletedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoFile withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoFile withoutTrashed()
*/
class CustomerFewoFile extends Model
{
use \Illuminate\Database\Eloquent\SoftDeletes;
protected $connection = 'mysql_stern';
protected $table = 'customer_fewo_files';
@ -56,6 +63,8 @@ class CustomerFewoFile extends Model
'size' => 'int'
];
protected $dates = ['deleted_at'];
protected $fillable = [
'travel_user_id',
'customer_fewo_mail_id',

View file

@ -76,9 +76,16 @@ use Illuminate\Database\Eloquent\Model;
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CustomerFewoFile[] $customer_files
* @property-read int|null $customer_files_count
* @property-read \App\Models\CustomerFewoMail|null $customer_mail
* @property \Illuminate\Support\Carbon|null $deleted_at
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoMail onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDeletedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoMail withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoMail withoutTrashed()
*/
class CustomerFewoMail extends Model
{
use \Illuminate\Database\Eloquent\SoftDeletes;
protected $connection = 'mysql_stern';
protected $table = 'customer_fewo_mails';
@ -102,7 +109,8 @@ class CustomerFewoMail extends Model
protected $dates = [
'sent_at',
'scheduled_at',
'delivered_at'
'delivered_at',
'deleted_at'
];
protected $fillable = [
@ -128,6 +136,16 @@ class CustomerFewoMail extends Model
'delivered_at'
];
protected static function boot() {
parent::boot();
static::deleting(function($model) {
foreach ($model->customer_fewo_files as $relation)
{
$relation->delete();
}
});
}
public function customer_fewo_mail()
{
return $this->belongsTo(CustomerFewoMail::class, 'reply_id');

View file

@ -63,6 +63,8 @@ use Reliese\Database\Eloquent\Model as Eloquent;
* @property-read int|null $fewo_reservations_count
* @property-read int|null $pages_count
* @property-read int|null $travel_user_booking_fewos_count
* @property string|null $pdf_name
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\FewoLodging wherePdfName($value)
*/
class FewoLodging extends Model
{

View file

@ -61,4 +61,5 @@ class FewoReservation extends Model
{
return $this->belongsTo(\App\Models\FewoLodging::class, 'lodging_id');
}
}

View file

@ -31,6 +31,8 @@ use Illuminate\Database\Eloquent\Model;
* @property bool|null $active
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProvider whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProvider whereContactEmails($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ServiceProviderService[] $service_provider_services
* @property-read int|null $service_provider_services_count
*/
class ServiceProvider extends Model
{
@ -60,4 +62,9 @@ class ServiceProvider extends Model
{
return $this->hasMany(ServiceProviderEntry::class);
}
public function service_provider_services()
{
return $this->hasMany(ServiceProviderService::class, 'service_provider_id', 'id')->orderBy('pos', 'DESC');
}
}

View file

@ -6,6 +6,7 @@
namespace App\Models;
use App\Services\Util;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
@ -96,19 +97,38 @@ class ServiceProviderEntry extends Model
}
}
public function getAmountAttribute()
{
return Util::_number_format($this->attributes['amount']);
}
public function getAmountRaw()
{
return $this->attributes['amount'];
}
public function getAmountEurAttribute()
{
return Util::_number_format($this->attributes['amount_eur']);
}
public function getAmountEurRaw()
{
return $this->attributes['amount_eur'];
}
public function getAmountFinalEur(){
$ret = $this->amount;
if($this->amount_eur && $this->amount_eur > 0){
$ret = $this->amount_eur;
$ret = $this->attributes['amount'];
if($this->attributes['amount_eur'] && $this->attributes['amount_eur'] > 0){
$ret = $this->attributes['amount_eur'];
}
return number_format($ret, 2, ',', '.');
}
public function getAmountFinalEurRaw(){
if($this->amount_eur && $this->amount_eur > 0){
return $this->amount_eur;
if($this->attributes['amount_eur'] && $this->attributes['amount_eur'] > 0){
return $this->attributes['amount_eur'];
}
return $this->amount;
return $this->attributes['amount'];
}
public function getPaymentDateFormat(){

View file

@ -0,0 +1,76 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class ServiceProviderService
*
* @property int $id
* @property int $service_provider_id
* @property string $name
* @property string $description
* @property bool $active
* @property int $pos
* @property Carbon $created_at
* @property Carbon $updated_at
* @property ServiceProvider $service_provider
* @property Collection|BookingProviderService[] $booking_provider_services
* @package App\Models
* @property-read int|null $booking_provider_services_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService whereServiceProviderId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProviderService whereUpdatedAt($value)
* @mixin \Eloquent
*/
class ServiceProviderService extends Model
{
protected $connection = 'mysql';
protected $table = 'service_provider_services';
protected $casts = [
'service_provider_id' => 'int',
'active' => 'bool',
'pos' => 'int'
];
protected $fillable = [
'service_provider_id',
'name',
'description',
'active',
'pos'
];
protected $status_type = [
0 => 'offen',
1 => 'erledigt',
];
public function service_provider()
{
return $this->belongsTo(ServiceProvider::class);
}
public function booking_provider_services()
{
return $this->hasMany(BookingProviderService::class);
}
}

View file

@ -36,6 +36,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereActive($value)
* @property array|null $contact_emails
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereContactEmails($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelCompanyService[] $travel_company_services
* @property-read int|null $travel_company_services_count
*/
class TravelCompany extends Model
{
@ -70,6 +72,10 @@ class TravelCompany extends Model
{
return $this->hasMany(BookingServiceItem::class);
}
public function travel_company_services()
{
return $this->hasMany(TravelCompanyService::class, 'travel_company_id', 'id')->orderBy('pos', 'DESC');
}
public function setPercentageAttribute($value)
{

View file

@ -0,0 +1,75 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class TravelCompanyService
*
* @property int $id
* @property int $travel_company_id
* @property string $name
* @property string $description
* @property bool $active
* @property int $pos
* @property Carbon $created_at
* @property Carbon $updated_at
* @property TravelCompany $travel_company
* @property Collection|BookingCompanyService[] $booking_company_services
* @package App\Models
* @property-read int|null $booking_company_services_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService whereTravelCompanyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompanyService whereUpdatedAt($value)
* @mixin \Eloquent
*/
class TravelCompanyService extends Model
{
protected $connection = 'mysql';
protected $table = 'travel_company_services';
protected $casts = [
'travel_company_id' => 'int',
'active' => 'bool',
'pos' => 'int'
];
protected $fillable = [
'travel_company_id',
'name',
'description',
'active',
'pos'
];
protected $status_type = [
0 => 'offen',
1 => 'erledigt',
];
public function travel_company()
{
return $this->belongsTo(TravelCompany::class);
}
public function booking_company_services()
{
return $this->hasMany(BookingCompanyService::class);
}
}

View file

@ -159,7 +159,8 @@ class TravelUserBookingFewo extends Model
protected $dates = [
'booking_date',
'from_date',
'to_date'
'to_date',
'deleted_at'
];
protected $fillable = [
@ -190,6 +191,16 @@ class TravelUserBookingFewo extends Model
'status_text'
];
protected static function boot() {
parent::boot();
static::deleting(function($model) {
foreach ($model->customer_fewo_mails as $relation)
{
$relation->delete();
}
});
}
public static $customer_mail_dirs = [
11 => ['name' => 'Entwürfe', 'icon'=>'ion-md-create'],
12 => ['name' => 'Papierkorb', 'icon'=>'ion-md-trash'],

View file

@ -4,7 +4,9 @@ namespace App\Repositories;
use App\Models\Booking;
use App\Models\BookingCompanyService;
use App\Models\BookingCountryService;
use App\Models\BookingProviderService;
class BookingRepository extends BaseRepository {
@ -45,17 +47,24 @@ class BookingRepository extends BaseRepository {
$this->updateCountryService($data['country_service']);
}
if(isset($data['provider_service'])){
$this->updateProviderService($data['provider_service']);
}
if(isset($data['company_service'])){
$this->updateCompanyService($data['company_service']);
}
return $this->model;
}
public function updateCountryService($country_services){
foreach ($country_services as $country_service_id=>$val){
$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){
$booking_country_service = BookingCountryService::create([
BookingCountryService::create([
'travel_country_service_id' => $country_service_id,
'booking_id' => $this->model->id,
'status' => $val
@ -67,7 +76,46 @@ class BookingRepository extends BaseRepository {
$booking_country_service->save();
}
}
}
public function updateProviderService($provider_service){
foreach ($provider_service as $provider_service_id=>$val){
$booking_provider_service = BookingProviderService::where('service_provider_service_id', '=', $provider_service_id)
->where('booking_id', '=', $this->model->id)->first();
if(!$booking_provider_service){
BookingProviderService::create([
'service_provider_service_id' => $provider_service_id,
'booking_id' => $this->model->id,
'status' => $val
]);
}else{
$booking_provider_service->fill([
'status' => $val
]);
$booking_provider_service->save();
}
}
}
public function updateCompanyService($company_service){
foreach ($company_service as $company_service_id=>$val){
$booking_company_service = BookingCompanyService::where('travel_company_service_id', '=', $company_service_id)
->where('booking_id', '=', $this->model->id)->first();
if(!$booking_company_service){
BookingCompanyService::create([
'travel_company_service_id' => $company_service_id,
'booking_id' => $this->model->id,
'status' => $val
]);
}else{
$booking_company_service->fill([
'status' => $val
]);
$booking_company_service->save();
}
}
}
}