Fewo Mail MA, optimation Fewo, view User Fewos

This commit is contained in:
Kevin Adametz 2019-05-08 14:05:35 +02:00
parent e537e47a82
commit 346a7427a5
30 changed files with 915 additions and 963 deletions

View file

@ -55,6 +55,7 @@ class FewoLodging extends Model
'group_id',
'type_id',
'name',
'single_name',
'description',
'equipment',
'adress1',

View file

@ -85,6 +85,7 @@ class TravelUserBookingFewo extends Model
'price_deposit' => 'float',
'price_service' => 'float',
'price_balance' => 'float',
'price_extra' => 'float',
'price_total' => 'float',
'travel_booking_fewo_channel_id' => 'int',
'is_calendar_fewo_direct' => 'bool',
@ -94,6 +95,7 @@ class TravelUserBookingFewo extends Model
'send_user_mail' => 'array',
'send_service_mail' => 'array',
'send_info_mail' => 'array',
'send_employee_mail' => 'array',
];
protected $dates = [
@ -115,9 +117,11 @@ class TravelUserBookingFewo extends Model
'to_date',
'daily_prices',
'price_travel',
'price_balance',
'price_extra',
'price_travel_total',
'price_deposit',
'price_service',
'price_balance',
'price_total',
'travel_booking_fewo_channel_id',
'notice',
@ -155,6 +159,14 @@ class TravelUserBookingFewo extends Model
return "";
}
public function getCheckedBadgeCalendar(){
$back = "";
$back .= $this->is_calendar_fewo_direct ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : ' <span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
$back .= $this->is_calendar_hrs ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : ' <span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
$back .= $this->is_calendar_stern_tours ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : ' <span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
return $back;
}
public function getPersonsAttribute($value)
{
@ -259,6 +271,61 @@ class TravelUserBookingFewo extends Model
return isset($this->attributes['price_travel']) ? $this->attributes['price_travel'] : 0;
}
//price_extra
public function setPriceExtraAttribute($value)
{
$value = Util::_format_number($value);
$this->attributes['price_extra'] = floatval(str_replace(',', '.', $value));
}
public function getPriceExtraAttribute($value)
{
if(!$value){ return 0; }
return number_format(($this->attributes['price_extra']), 2, ',', '.');
}
public function getPriceExtraRaw()
{
return isset($this->attributes['price_extra']) ? $this->attributes['price_extra'] : 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_travel_total
public function setPriceTravelTotalAttribute($value)
{
$value = Util::_format_number($value);
$this->attributes['price_travel_total'] = floatval(str_replace(',', '.', $value));
}
public function getPriceTravelTotalAttribute($value)
{
if(!$value){
$this->attributes['price_travel_total'] = $this->getPriceTravelRaw() + $this->getPriceBalanceRaw() + $this->getPriceExtraRaw();
}
return number_format(($this->attributes['price_travel_total']), 2, ',', '.');
}
public function getPriceTravelTotalRaw()
{
if(!isset($this->attributes['price_travel_total']) || $this->attributes['price_travel_total'] == 0){
$this->attributes['price_travel_total'] = $this->getPriceTravelRaw() + $this->getPriceBalanceRaw() + $this->getPriceExtraRaw();
}
return isset($this->attributes['price_travel_total']) ? $this->attributes['price_travel_total'] : 0;
}
//price_deposit
public function setPriceDepositAttribute($value)
{
@ -295,21 +362,6 @@ class TravelUserBookingFewo extends Model
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)
@ -329,35 +381,23 @@ class TravelUserBookingFewo extends Model
return isset($this->attributes['price_total']) ? $this->attributes['price_total'] : 0;
}
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(){
public function getPriceTravelTotalFirstPay(){
if($this->attributes['price_travel'] == 0){
return 0;
}
$first_pay = $this->attributes['price_travel']/2;
$first_pay = ($this->getPriceTravelTotalRaw() + $this->getPriceServiceRaw()) / 2;
return number_format(($first_pay), 2, ',', '.');
}
public function getPriceTravelSecondPay(){
public function getPriceTravelTotalSecondPay(){
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, ',', '.');
$total_pay = ($this->getPriceTravelTotalRaw() + $this->getPriceServiceRaw());
$first_pay = $total_pay/2;
return number_format(($total_pay - $first_pay + $this->getPriceDepositRaw()), 2, ',', '.');
}
public function getBookingDateYear(){
return Carbon::parse($this->booking_date)->format('Y');
}
@ -487,7 +527,12 @@ class TravelUserBookingFewo extends Model
}
public function getNameAddressLocation($sep = "\n"){
if($this->fewo_lodging){
return $this->fewo_lodging->name.$sep.$this->fewo_lodging->adress1." ".$this->fewo_lodging->adress2.", ".$this->fewo_lodging->zip_code." ".$this->fewo_lodging->city;
$name = trim($this->fewo_lodging->single_name).$sep;
$address = trim($this->fewo_lodging->adress1);
$address .= $this->fewo_lodging->adress2 ? " ".$this->fewo_lodging->adress2.$sep : ", ";
$city = trim($this->fewo_lodging->zip_code)." ".trim($this->fewo_lodging->city);
return $name.$address.$city;
}
return "";
}
@ -517,7 +562,17 @@ class TravelUserBookingFewo extends Model
$this->from_date." - ".$this->to_date." ".$this->travel_user->first_name." ".$this->travel_user->last_name;
}
public function getEmployeeMailSubject(){
if($this->fewo_lodging){
return "CRM Fewo Buchung: ".$this->fewo_lodging->name." | Anreise ".$this->from_date;
}
return "CRM Fewo Buchung | Anreise ".$this->from_date;
}
public function getEmployeeMailContent(){
return ($this->travel_user_id ? "Kunde: ".route('travel_user_detail', [$this->travel_user_id])."\n" : "").
"Buchung: ".route('travel_user_booking_fewo_detail', [$this->id])."\n".
$this->travel_user->first_name." ".$this->travel_user->last_name." | ".$this->from_date." - ".$this->to_date." | ".$this->adults." + ".$this->children." (Erwachsene + Kinder)";
}
}