'Anfrage von STERN TOURS', 1 => 'Angebot versandt', 2 => 'Rückfrage Agentur', 3 => 'Rückfrage Kunden', 5 => 'Nachfrage Angebot', 7 => 'gebucht', 8 => 'Absage', 9 => 'Option', 10 => 'Angebot erstellen', 11 => 'Storno durch VA', 12 => 'Storno durch Kunde', 13 => 'Reiseanmeldung verschickt', ]; protected $connection = 'mysql_stern'; protected $table = 'travel_user_booking_fewos'; protected $casts = [ 'travel_user_id' => 'int', 'fewo_lodging_id' => 'int', 'fewo_reservation_id' => 'int', 'persons' => 'int', 'adults' => 'int', 'children' => 'int', 'daily_prices' => 'array', //! 'price_travel' => 'float', 'price_deposit' => 'float', 'price_service' => 'float', 'price_balance' => 'float', 'price_total' => 'float', 'travel_booking_fewo_channel_id' => 'int', 'is_calendar_fewo_direct' => 'bool', 'is_calendar_hrs' => 'bool', 'is_calendar_stern_tours' => 'bool', 'status' => 'int' ]; protected $dates = [ 'booking_date', 'from_date', 'to_date' ]; protected $fillable = [ 'travel_user_id', 'fewo_lodging_id', 'fewo_reservation_id', 'invoice_number', 'adults', 'children', 'persons', 'booking_date', 'from_date', 'to_date', 'daily_prices', 'price_travel', 'price_deposit', 'price_service', 'price_balance', 'price_total', 'travel_booking_fewo_channel_id', 'notice', 'is_calendar_fewo_direct', 'is_calendar_hrs', 'is_calendar_stern_tours', 'status', 'status_text' ]; public function fewo_lodging() { return $this->belongsTo(\App\Models\FewoLodging::class); } public function fewo_reservation() { return $this->belongsTo(\App\Models\FewoReservation::class, 'fewo_reservation_id'); } public function travel_booking_fewo_channel() { return $this->belongsTo(\App\Models\TravelBookingFewoChannel::class); } public function travel_user() { return $this->belongsTo(\App\Models\TravelUser::class); } public function getStatuesName(){ if(isset(self::$statues[$this->status])){ return self::$statues[$this->status]; } return ""; } public function getPersonsAttribute($value) { $this->attributes['persons'] = $this->adults + $this->children; return $this->attributes['persons']; } public function setPersonsAttribute( $value ) { $this->attributes['persons'] = $this->adults + $this->children; } public function getAdultsAttribute() { return isset($this->attributes['adults']) ? $this->attributes['adults'] : 0; } public function setAdultsAttribute( $value ) { $this->attributes['persons'] = $this->adults + $this->children; $this->attributes['adults'] = $value; } public function getChildrenAttribute() { return isset($this->attributes['children']) ? $this->attributes['children'] : 0; } public function setChildrenAttribute( $value ) { $this->attributes['persons'] = $this->adults + $this->children; $this->attributes['children'] = $value; } public static function getStatuesOptions($setKey = false){ $options = self::$statues; $ret = ''; foreach ($options as $key => $option){ $attr = ($key == $setKey) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public function getBookingDateAttribute($value) { if(!$value){ return ""; } return Carbon::parse($value)->format(Util::formatDateDB()); } public function setBookingDateAttribute( $value ) { $this->attributes['booking_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL; } //from_date public function getFromDateAttribute($value) { if(!$value){ return ""; } return Carbon::parse($value)->format(Util::formatDateDB()); } public function setFromDateAttribute( $value ) { $this->attributes['from_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL; } public function getFromDateRaw() { return isset($this->attributes['from_date']) ? $this->attributes['from_date'] : ""; } //to_date public function getToDateAttribute($value) { if(!$value){ return ""; } return Carbon::parse($value)->format(Util::formatDateDB()); } public function setToDateAttribute( $value ) { $this->attributes['to_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL; } public function getToDateRaw() { return isset($this->attributes['to_date']) ? $this->attributes['to_date'] : ""; } //price_travel public function setPriceTravelAttribute($value) { $value = Util::_format_number($value); $this->attributes['price_travel'] = floatval(str_replace(',', '.', $value)); } public function getPriceTravelAttribute($value) { if(!$value){ return 0; } return number_format(($this->attributes['price_travel']), 2, ',', '.'); } public function getPriceTravelRaw() { return isset($this->attributes['price_travel']) ? $this->attributes['price_travel'] : 0; } //price_deposit public function setPriceDepositAttribute($value) { $value = Util::_format_number($value); $this->attributes['price_deposit'] = floatval(str_replace(',', '.', $value)); } public function getPriceDepositAttribute($value) { if(!$value){ return 0; } return number_format(($this->attributes['price_deposit']), 2, ',', '.'); } public function getPriceDepositRaw() { return isset($this->attributes['price_deposit']) ? $this->attributes['price_deposit'] : 0; } //price_service public function setPriceServiceAttribute($value) { $value = Util::_format_number($value); $this->attributes['price_service'] = floatval(str_replace(',', '.', $value)); } public function getPriceServiceAttribute($value) { if(!$value){ return 0; } return number_format(($this->attributes['price_service']), 2, ',', '.'); } public function getPriceServiceRaw() { return isset($this->attributes['price_service']) ? $this->attributes['price_service'] : 0; } //price_balance public function setPriceBalanceAttribute($value) { $value = Util::_format_number($value); $this->attributes['price_balance'] = floatval(str_replace(',', '.', $value)); } public function getPriceBalanceAttribute($value) { if(!$value){ return 0; } return number_format(($this->attributes['price_balance']), 2, ',', '.'); } public function getPriceBalanceRaw() { return isset($this->attributes['price_balance']) ? $this->attributes['price_balance'] : 0; } //price_total public function setPriceTotalAttribute($value) { $value = Util::_format_number($value); $this->attributes['price_total'] = floatval(str_replace(',', '.', $value)); } public function getPriceTotalAttribute($value) { if(!$value){ return 0; } return number_format(($this->attributes['price_total']), 2, ',', '.'); } public function getPriceTotalRaw() { return isset($this->attributes['price_total']) ? $this->attributes['price_total'] : 0; } public function getBookingDateYear(){ return Carbon::parse($this->booking_date)->format('Y'); } public function getPriceTotalFirstPay(){ if($this->attributes['price_total'] == 0){ return 0; } $first_pay = $this->attributes['price_total']/2; return number_format(($first_pay), 2, ',', '.'); } public function getPriceTotalSecondPay(){ if($this->attributes['price_total'] == 0){ return 0; } $first_pay = $this->attributes['price_total']/2; return number_format(($this->attributes['price_total'] - $first_pay), 2, ',', '.'); } public function getPriceTravelFirstPay(){ if($this->attributes['price_travel'] == 0){ return 0; } $first_pay = $this->attributes['price_travel']/2; return number_format(($first_pay), 2, ',', '.'); } public function getPriceTravelSecondPay(){ if($this->attributes['price_travel'] == 0){ return 0; } $first_pay = $this->attributes['price_travel']/2; return number_format(($this->attributes['price_travel'] - $first_pay + $this->attributes['price_deposit']), 2, ',', '.'); } public function getBookingUserAddress(){ if($this->travel_user){ $company = $this->travel_user->company ? $this->travel_user->company ."\n" : ""; $title = $this->travel_user->title ? $this->travel_user->title."\n" : ""; $nationality = $this->travel_user->travel_nationality_id ? "\n".$this->travel_user->travel_nationality->name : ""; return $company.$title.$this->travel_user->first_name." ".$this->travel_user->last_name."\n".$this->travel_user->street."\n".$this->travel_user->zip_code." ".$this->travel_user->city.$nationality; } return ""; } public function getNameAddressLocation(){ if($this->fewo_lodging){ return $this->fewo_lodging->name."\n".$this->fewo_lodging->adress1." ".$this->fewo_lodging->adress2.", ".$this->fewo_lodging->zip_code." ".$this->fewo_lodging->city; } return ""; } }