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

@ -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'],