Lead create Booking

This commit is contained in:
Kevin Adametz 2022-04-14 13:22:03 +02:00
parent 3df0e93c2c
commit 34a3d2196b
18 changed files with 462 additions and 160 deletions

View file

@ -29,13 +29,14 @@ class BookingController extends Controller
{
$request = \Request::all();
if($request['key'] !== $this->successKey){
if(!isset($request['key']) || $request['key'] !== $this->successKey){
return response()->json(['error' => "key"], 401);
}
$travel_booking = TravelBooking::find($request['travel_booking_id']);
// $travel_booking = TravelBooking::find(2458);
if(!$travel_booking){
//# vor testing
//$travel_booking = TravelBooking::find(2922);
if(!isset($travel_booking) || !$travel_booking){
return response()->json(['error' => 'no-booking-found'], $this->successStatus);
}
@ -81,8 +82,6 @@ class BookingController extends Controller
'new_drafts' => $travel_booking->drafts === null ? 0 : 1,
'sf_guard_user_id' => 15,
'branch_id' => 4,
'travel_country_id' => isset($travel_booking->selected_travel['travel_country_id'][0]) ? $travel_booking->selected_travel['travel_country_id'][0] : null,
'travel_category_id' => isset($travel_booking->selected_travel['travel_category_id']) ? $travel_booking->selected_travel['travel_category_id'] : null,
'pax' => $travel_booking->selected_adults,
'title' => isset($travel_booking->selected_travel['travel_title']) ? $travel_booking->selected_travel['travel_title'] : "",
'comfort' => $comfort,
@ -100,13 +99,15 @@ class BookingController extends Controller
'participant_birthdate' => null,
'participant_salutation_id' => null,
'nationality_id' => null,
'travel_company_id' => null,
'price' => $travel_booking->price,
'price_total' => $travel_booking->price_total,
'deposit_total' => $travel_booking->deposit_total,
'final_payment' => $travel_booking->final_payment,
'final_payment_date' => $travel_booking->final_payment_date->format('Y-m-d'),
'travel_country_id' => isset($travel_booking->selected_travel['travel_country_id'][0]) ? $travel_booking->selected_travel['travel_country_id'][0] : null,
'travel_category_id' => isset($travel_booking->selected_travel['travel_category_id']) ? $travel_booking->selected_travel['travel_category_id'] : null,
'travelagenda_id' => isset($travel_booking->selected_travel['travelagenda_id']) ? $travel_booking->selected_travel['travelagenda_id'] : null,
'travel_company_id' => isset($travel_booking->selected_travel['travel_company_id']) ? $travel_booking->selected_travel['travel_company_id'] : 4,
];
//createBooking

View file

@ -60,6 +60,11 @@ class LeadController extends Controller
{
$data = Request::all();
if($data['action'] === 'createBooking'){
$lead = $this->leadRepo->createBooking($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('lead_detail', [$id]).'#collapseLeadBooking');
}
if($data['action'] === 'saveCustomer'){
$customer = $this->custRepo->updateCustomerFromLead($id, $data);
\Session()->flash('alert-save', '1');

View file

@ -31,6 +31,7 @@ class ServiceProviderController extends Controller
$model = new ServiceProvider();
$id = 'new';
$model->active = 1;
$model->id = 0;
}else{
$model = ServiceProvider::findOrFail($id);
$id = $model->id;
@ -49,7 +50,6 @@ class ServiceProviderController extends Controller
public function update($id){
$data = Request::all();
if(isset($data['update-action'])){
if($data['update-action'] === 'save-service-provider-service'){
$data['active'] = true;//isset($data['active']) ? true : false;
@ -70,7 +70,6 @@ class ServiceProviderController extends Controller
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
if($id === "new"){
$model = ServiceProvider::create($data);
}else{
@ -87,8 +86,17 @@ class ServiceProviderController extends Controller
public function delete($id, $del="service_provider"){
if($del === 'service_provider') {
abort(404, 'Noch keine Funktion');
//abort(403, 'Noch keine Funktion');
$model = ServiceProvider::findOrFail($id);
if($model->service_provider_entries->count() > 0){
\Session()->flash('alert-error', 'Der Leistungträger kann nicht gelöscht werden, dieser hat Einträge');
return redirect()->back();
}
if($model->service_provider_services->count() > 0){
\Session()->flash('alert-error', 'Der Leistungträger kann nicht gelöscht werden, dieser hat Einträge Service');
return redirect()->back();
}
$model->delete();
\Session()->flash('alert-success', 'Eintrag gelöscht');
return redirect()->back();

View file

@ -125,8 +125,24 @@ class Customer extends Model
];
public static $salutationType = [
1 => 'Mann',
2 => 'Frau'
1 => 'Herr',
2 => 'Frau',
3 => 'Divers/keine Anrede',
4 => 'Firma'
];
public static $salutationNameType = [
1 => 'Herr',
2 => 'Frau',
3 => '',
4 => 'Firma'
];
public static $salutationDearType = [
1 => 'geehrter',
2 => 'geehrte',
3 => 'geehrte:r',
4 => ''
];
public function travel_country()
@ -155,7 +171,15 @@ class Customer extends Model
}
public function getSalutation(){
return $this->salutation_id == 1 ? 'Herr' : 'Frau';
return isset(self::$salutationType[$this->salutation_id]) ? self::$salutationType[$this->salutation_id] : '';
}
public function getSalutationName(){
return isset(self::$salutationNameType[$this->salutation_id]) ? self::$salutationNameType[$this->salutation_id] : '';
}
public function getSalutationDear(){
return isset(self::$salutationDearType[$this->salutation_id]) ? self::$salutationDearType[$this->salutation_id] : '';
}
public function fullName()

View file

@ -1,26 +1,29 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\TravelProgram
*
* Class TravelProgram
*
* @property int $id
* @property float|null $profit_margin
* @property int|null $category_id
* @property string|null $program_code
* @property int|null $program_duration
* @property int|null $is_seasonal
* @property int|null $youth
* @property bool|null $is_seasonal
* @property bool|null $youth
* @property string|null $title
* @property string|null $subtitle
* @property string|null $slider_info
* @property int|null $program_type
* @property int|null $crm_draft_id_standard
* @property int|null $crm_draft_id_comfort
* @property int|null $organizer
* @property int|null $generalnote
* @property int|null $status
@ -35,8 +38,9 @@ use Illuminate\Database\Eloquent\Model;
* @property int|null $insurance_1
* @property int|null $insurance_2
* @property int|null $insurance_3
* @property int $in_slider
* @property int $show_map
* @property int|null $insurance_4
* @property bool $in_slider
* @property bool $show_map
* @property string|null $map_html
* @property string $map_image
* @property string $map_image_ext
@ -44,7 +48,7 @@ use Illuminate\Database\Eloquent\Model;
* @property int|null $travel_category
* @property int|null $travel_agenda
* @property int|null $deposit_percent
* @property int|null $netto_prices_in_euro
* @property bool|null $netto_prices_in_euro
* @property string|null $text_right
* @property float|null $default_flight_price
* @property int|null $travel_arrival_point_id
@ -52,100 +56,202 @@ use Illuminate\Database\Eloquent\Model;
* @property int|null $position
* @property float|null $discount
* @property int|null $discount_is_percent_value
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereAdvices($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereCategoryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereClassDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereCrmDraftIdComfort($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereCrmDraftIdStandard($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereDefaultFlightPrice($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereDepositPercent($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereDiscount($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereDiscountIsPercentValue($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereExcluded($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereGeneralnote($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereHtmlDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereInSlider($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereIncluded($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereInsurance1($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereInsurance2($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereInsurance3($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereIsSeasonal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereMapHtml($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereMapImage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereMapImageExt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereMaxAgeForChildren($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereNettoPricesInEuro($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereNotes($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereOrganizer($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram wherePosition($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereProfitMargin($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereProgramCode($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereProgramDuration($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereProgramType($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereShowMap($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereSliderInfo($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereSubtitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTextRight($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTravelAgenda($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTravelArrivalPointId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTravelCategory($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereTravelCountry($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereWeekdays($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereYouth($value)
* @mixin \Eloquent
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelClass[] $classes
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereUpdatedAt($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelProgramDraft[] $travel_program_drafts
* @property int|null $insurance_4
* @property-read \App\Models\TravelProgramCountry $travel_program_country
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereInsurance4($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram query()
* @property-read int|null $classes_count
* @property-read int|null $travel_program_drafts_count
* @property string|null $keywords
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelProgram whereKeywords($value)
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
*
* @property TravelArrivalPoint|null $travel_arrival_point
* @property TravelOrganizer|null $travel_organizer
* @property TravelInsurance|null $travel_insurance
* @property TravelGeneralNote|null $travel_general_note
* @property Option $option
* @property Collection|TravelClass[] $travel_classes
* @property Collection|TravelDeparturePoint[] $travel_departure_points
* @property Collection|TravelPeriod[] $travel_periods
* @property TravelProgramCountry $travel_program_country
* @property TravelProgramDestination $travel_program_destination
* @property Collection|TravelProgramDraft[] $travel_program_drafts
* @property Collection|TravelProgramImage[] $travel_program_images
* @property TravelProgramOption $travel_program_option
* @property TravelProgramRelated $travel_program_related
*
* @package App\Models
*/
class TravelProgram extends Model
{
//use the connection to sec. Datebase sterntours
protected $connection = 'mysql_stern';
protected $connection = 'mysql_stern';
protected $table = 'travel_program';
protected $table = 'travel_program';
protected $fillable = [
'title',
'subtitle',
'program_code',
'weekdays',
'keywords',
'status',
];
protected $casts = [
'profit_margin' => 'float',
'category_id' => 'int',
'program_duration' => 'int',
'is_seasonal' => 'bool',
'youth' => 'bool',
'program_type' => 'int',
'organizer' => 'int',
'generalnote' => 'int',
'status' => 'int',
'max_age_for_children' => 'int',
'insurance_1' => 'int',
'insurance_2' => 'int',
'insurance_3' => 'int',
'insurance_4' => 'int',
'in_slider' => 'bool',
'show_map' => 'bool',
'travel_country' => 'int',
'travel_category' => 'int',
'travel_agenda' => 'int',
'travel_company' => 'int',
'deposit_percent' => 'int',
'netto_prices_in_euro' => 'bool',
'default_flight_price' => 'float',
'travel_arrival_point_id' => 'int',
'position' => 'int',
'discount' => 'float',
'discount_is_percent_value' => 'int'
];
public function classes()
protected $fillable = [
'profit_margin',
'category_id',
'program_code',
'program_duration',
'is_seasonal',
'youth',
'title',
'subtitle',
'slider_info',
'program_type',
'organizer',
'generalnote',
'status',
'included',
'class_description',
'excluded',
'advices',
'notes',
'url',
'max_age_for_children',
'html_description',
'insurance_1',
'insurance_2',
'insurance_3',
'insurance_4',
'in_slider',
'show_map',
'map_html',
'map_image',
'map_image_ext',
'travel_country',
'travel_category',
'travel_agenda',
'travel_company',
'deposit_percent',
'netto_prices_in_euro',
'text_right',
'default_flight_price',
'travel_arrival_point_id',
'weekdays',
'position',
'discount',
'discount_is_percent_value'
];
public static $programTypeTypes = [
0 => 'Eigenveranstaltung',
1 => 'Vermittlung'
];
public static $travelCategoryTypes = [
1 => 'Ägypten-Reise',
2 => 'Israel-Reise',
3 => 'Jordanien-Reise',
4 => 'Reise ohne Conversion-Code'
];
public function travel_arrival_point()
{
return $this->belongsTo(TravelArrivalPoint::class);
}
public function travel_organizer()
{
return $this->belongsTo(TravelOrganizer::class, 'organizer');
}
public function travel_insurance()
{
return $this->belongsTo(TravelInsurance::class, 'insurance_3');
}
public function travel_category()
{
return $this->belongsTo(TravelCategory::class, 'category_id');
}
public function travel_general_note()
{
return $this->belongsTo(TravelGeneralNote::class, 'generalnote');
}
public function option()
{
return $this->hasOne(Option::class, 'program_id');
}
public function classes()
{
return $this->hasMany('App\Models\TravelClass', 'program_id', 'id');
return $this->hasMany(TravelClass::class, 'program_id');
}
public function travel_program_drafts()
{
return $this->hasMany('App\Models\TravelProgramDraft', 'travel_program_id', 'id');
}
public function travel_program_country()
{
return $this->hasOne('App\Models\TravelProgramCountry', 'program_id', 'id');
}
public function travel_classes()
{
return $this->hasMany(TravelClass::class, 'program_id');
}
public function hasTravelProgramDrafts (){
public function travel_departure_points()
{
return $this->hasMany(TravelDeparturePoint::class, 'program_id');
}
public function travel_periods()
{
return $this->hasMany(TravelPeriod::class, 'program_id');
}
public function travel_program_country()
{
return $this->hasOne(TravelProgramCountry::class, 'program_id');
}
public function travel_program_destination()
{
return $this->hasOne(TravelProgramDestination::class, 'program_id');
}
public function travel_program_drafts()
{
return $this->hasMany(TravelProgramDraft::class);
}
public function travel_program_images()
{
return $this->hasMany(TravelProgramImage::class, 'program_id');
}
public function travel_program_option()
{
return $this->hasOne(TravelProgramOption::class, 'program_id');
}
public function travel_program_related()
{
return $this->hasOne(TravelProgramRelated::class, 'program_2');
}
public function hasTravelProgramDrafts (){
if($this->travel_program_drafts->count()){
return true;
}
@ -161,7 +267,7 @@ class TravelProgram extends Model
return [];
}
public function setWeekdaysFromArray($value){
public function setWeekdaysFromArray($value){
if($value){
if(is_array($value)){
if($value[0] === NULL){

View file

@ -109,6 +109,27 @@ class TravelUser extends Model
'last_user_data'
];
public static $salutationType = [
1 => 'Herr',
2 => 'Frau',
3 => 'Divers/keine Anrede',
4 => 'Firma'
];
public static $salutationNameType = [
1 => 'Herr',
2 => 'Frau',
3 => '',
4 => 'Firma'
];
public static $salutationDearType = [
1 => 'geehrter',
2 => 'geehrte',
3 => 'geehrte:r',
4 => ''
];
public function travel_nationality()
{
return $this->belongsTo(\App\Models\TravelNationality::class);
@ -132,7 +153,15 @@ class TravelUser extends Model
$this->attributes['birthday'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
}
public function getSalutation(){
return $this->salutation_id == 1 ? 'Herr' : 'Frau';
public function getSalutation(){
return isset(self::$salutationType[$this->salutation_id]) ? self::$salutationType[$this->salutation_id] : '';
}
public function getSalutationName(){
return isset(self::$salutationNameType[$this->salutation_id]) ? self::$salutationNameType[$this->salutation_id] : '';
}
public function getSalutationDear(){
return isset(self::$salutationDearType[$this->salutation_id]) ? self::$salutationDearType[$this->salutation_id] : '';
}
}

View file

@ -274,13 +274,13 @@ class TravelUserBookingFewo extends Model
}
public function getPersonsAttribute($value)
public function getPersonsAttribute()
{
$this->attributes['persons'] = $this->adults + $this->children;
return $this->attributes['persons'];
}
public function setPersonsAttribute( $value ) {
public function setPersonsAttribute($value) {
$this->attributes['persons'] = $this->adults + $this->children;
@ -321,10 +321,9 @@ class TravelUserBookingFewo extends Model
return $ret;
}
public function getBookingDateAttribute($value)
public function getBookingDateAttribute()
{
if(!$value){ return ""; }
return Carbon::parse($value)->format(Util::formatDateDB());
return isset($this->attributes['booking_date']) ? Carbon::parse($this->attributes['booking_date'])->format(Util::formatDateDB()) : NULL;
}
public function setBookingDateAttribute( $value ) {
@ -332,10 +331,9 @@ class TravelUserBookingFewo extends Model
}
//from_date
public function getFromDateAttribute($value)
public function getFromDateAttribute()
{
if(!$value){ return ""; }
return Carbon::parse($value)->format(Util::formatDateDB());
return isset($this->attributes['from_date']) ? Carbon::parse($this->attributes['from_date'])->format(Util::formatDateDB()) : NULL;
}
public function setFromDateAttribute( $value ) {
$this->attributes['from_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
@ -346,10 +344,9 @@ class TravelUserBookingFewo extends Model
}
//to_date
public function getToDateAttribute($value)
public function getToDateAttribute()
{
if(!$value){ return ""; }
return Carbon::parse($value)->format(Util::formatDateDB());
return isset($this->attributes['to_date']) ? Carbon::parse($this->attributes['to_date'])->format(Util::formatDateDB()) : NULL;
}
public function setToDateAttribute( $value ) {
$this->attributes['to_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
@ -367,8 +364,7 @@ class TravelUserBookingFewo extends Model
public function getPriceTravelAttribute($value)
{
if(!$value){ return 0; }
return number_format(($this->attributes['price_travel']), 2, ',', '.');
return isset($this->attributes['price_travel']) ? number_format(($this->attributes['price_travel']), 2, ',', '.') : 0;
}
public function getPriceTravelRaw()
@ -399,8 +395,7 @@ class TravelUserBookingFewo extends Model
}
public function getPriceBalanceAttribute($value)
{
if(!$value){ return 0; }
return number_format(($this->attributes['price_balance']), 2, ',', '.');
return isset($this->attributes['price_balance']) ? number_format(($this->attributes['price_balance']), 2, ',', '.') : 0;
}
public function getPriceBalanceRaw()
{
@ -415,10 +410,10 @@ class TravelUserBookingFewo extends Model
}
public function getPriceTravelTotalAttribute($value)
{
if(!$value){
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 number_format(($this->attributes['price_travel_total']), 2, ',', '.');
}
return isset($this->attributes['price_travel_total']) ? number_format(($this->attributes['price_travel_total']), 2, ',', '.') : 0;
}
public function getPriceTravelTotalRaw()
{
@ -436,8 +431,7 @@ class TravelUserBookingFewo extends Model
public function getPriceDepositAttribute($value)
{
if(!$value){ return 0; }
return number_format(($this->attributes['price_deposit']), 2, ',', '.');
return isset($this->attributes['price_deposit']) ? number_format(($this->attributes['price_deposit']), 2, ',', '.') : 0;
}
public function getPriceDepositRaw()
@ -453,8 +447,7 @@ class TravelUserBookingFewo extends Model
public function getPriceServiceAttribute($value)
{
if(!$value){ return 0; }
return number_format(($this->attributes['price_service']), 2, ',', '.');
return isset($this->attributes['price_service']) ? number_format(($this->attributes['price_service']), 2, ',', '.') : 0;
}
public function getPriceServiceRaw()
@ -471,8 +464,7 @@ class TravelUserBookingFewo extends Model
public function getPriceTotalAttribute($value)
{
if(!$value){ return 0; }
return number_format(($this->attributes['price_total']), 2, ',', '.');
return isset($this->attributes['price_total']) ? number_format(($this->attributes['price_total']), 2, ',', '.') : 0;
}
public function getPriceTotalRaw()
@ -696,8 +688,12 @@ class TravelUserBookingFewo extends Model
if($this->travel_user){
if($this->travel_user->salutation_id == 1){
$salutation = __('Dear Sir')." ".$this->travel_user->last_name;
}else{
$salutation = __('Dear Mrs')." ".$this->travel_user->last_name;
}
if($this->travel_user->salutation_id == 2){
$salutation = __('Dear Sir')." ".$this->travel_user->last_name;
}
if($this->travel_user->salutation_id == 4){
$salutation = __('Dear customer')." ".$this->travel_user->last_name;
}
}
return $salutation;

View file

@ -4,9 +4,11 @@ namespace App\Repositories;
use App\Models\Lead;
use App\Models\Booking;
use App\Models\LeadNotice;
use App\Models\LeadParticipant;
use App\Models\Participant;
use App\Models\StatusHistory;
use App\Models\LeadParticipant;
class LeadRepository extends BaseRepository {
@ -120,5 +122,81 @@ class LeadRepository extends BaseRepository {
return $this->model;
}
public function createBooking($id, $data){
$this->model = Lead::findOrFail($id);
if ($this->model->bookings->count() > 0){
abort(403, 'Die Anfrage hat bereits eine Buchnung.');
}
$data = [
'booking_date' => date('Y-m-d'), //now
'customer_id' => $this->model->customer->id,
'lead_id' => $this->model->id,
'new_drafts' => 1,
'sf_guard_user_id' => $this->model->sf_guard_user_id,
'branch_id' => 4,
'pax' => $this->model->pax,
'title' => "",
'comfort' => false,
'start_date' => $this->model->travelperiod_start,
'end_date' => $this->model->travelperiod_end,
'website_id' => 1,
'travel_number' => null,
'participant_name' => null,
'participant_firstname' => null,
'participant_birthdate' => null,
'participant_salutation_id' => null,
'nationality_id' => null,
'price' => $this->model->price,
'price_total' => null,
'deposit_total' => null,
'final_payment' => null,
'final_payment_date' => null,
'travel_country_id' => $this->model->travelcountry_id,
'travel_category_id' => $this->model->travelcategory_id,
'travelagenda_id' => $this->model->travelagenda_id,
'travel_company_id' => 4,
];
//createBooking
$booking = Booking::create($data);
// copy participants
if($this->model->lead_participants){
foreach($this->model->lead_participants as $participant){
Participant::create([
'booking_id' => $booking->id,
'participant_name' => $participant->participant_name,
'participant_firstname' => $participant->participant_firstname,
'participant_birthdate' => $participant->participant_birthdate,
'participant_salutation_id' => $participant->participant_salutation_id,
'participant_child' => $participant->participant_child,
'nationality_id' => $participant->nationality_id,
]);
}
}
//inquiries
//offers ???
/*if($lead->getInquiry()->count() > 0)
{
foreach($lead->getInquiry() as $inquiry)
{
$arrangement = new Arrangement();
$arrangement->setArrangementType($inquiry->getInquiryType()->getArrangementType());
$arrangement->setBegin($inquiry->getBegin());
$arrangement->setEnd($inquiry->getEnd());
$arrangement->setDataS($inquiry->getDataS());
$arrangement->setInPdf($inquiry->getInPdf());
$arrangement->setBooking($booking);
$arrangement->save();
}
}*/
return $this->model;
}
}

View file

@ -75,7 +75,9 @@ class HTMLHelper
private static $salutation = [
1 => 'Herr',
2 => 'Frau',
3 => 'Firma',
3 => 'Divers/keine Anrede',
4 => 'Firma',
];

View file

@ -74,7 +74,7 @@ class Model
}
public static function getSalutationArray($emtpy = false){
$Salutation = Salutation::orderBy('name')->get()->pluck('name', 'id');
$Salutation = Salutation::orderBy('id')->get()->pluck('name', 'id');
return $emtpy ? $Salutation->prepend('-', 0) : $Salutation;
}

View file

@ -147,13 +147,13 @@ class Placeholder
public static function replaceBooking(Booking $booking, $content)
{
$dear = $booking->customer->salutation_id == 1 ? 'geehrter' : 'geehrte';
$dear = $booking->customer->getSalutationDear();
$first_name = $booking->customer->firstname;
$last_name = $booking->customer->name;
$title = $booking->customer->title;
$country = $booking->travel_country_id ? $booking->travel_country->name : "-";
$program = $booking->travelagenda_id ? $booking->travel_agenda->name : "-";
$salutation = isset($booking->customer->salutation) ? $booking->customer->salutation->name : '-';
$salutation = isset($booking->customer->salutation) ? $booking->customer->getSalutationName() : '-';
$filekey = $booking->filekey;
$flight_info = "";
@ -174,7 +174,7 @@ class Placeholder
$myjack_nr = $booking->merlin_order_number;
$participants = "Teilnehmer:<br>";
$participants = "Teilnehmer:in<br>";
//first
if($booking->participant_firstname){
$participants .= $booking->participant_salutation_id ? \App\Services\Model::getSalutationById($booking->participant_salutation_id)." " : '';
@ -209,12 +209,12 @@ class Placeholder
public static function replaceBookingFewo(TravelUserBookingFewo $booking_fewo, $content)
{
$dear = $booking_fewo->travel_user->salutation_id == 1 ? 'geehrter' : 'geehrte';
$dear = $booking_fewo->travel_user->getSalutationDear();
$first_name = $booking_fewo->travel_user->first_name;
$last_name = $booking_fewo->travel_user->last_name;
$title = $booking_fewo->travel_user->title;
$program = $booking_fewo->fewo_lodging_id ? $booking_fewo->fewo_lodging->name : "-";
$salutation = $booking_fewo->travel_user->salutation_id == 1 ? 'Herr' : 'Frau';
$salutation = $booking_fewo->travel_user->getSalutationName();
$start_date = $booking_fewo->from_date;
$end_date = $booking_fewo->to_date;
$booking_date = $booking_fewo->booking_date;
@ -232,19 +232,19 @@ class Placeholder
public static function replaceLead(Lead $lead, $content)
{
$dear = $lead->customer->salutation_id == 1 ? 'geehrter' : 'geehrte';
$dear = $lead->customer->getSalutationDear();
$first_name = $lead->customer->firstname;
$last_name = $lead->customer->name;
$title = $lead->customer->title;
$country = $lead->travelcountry_id ? $lead->travel_country->name : "-";
$program = $lead->travelagenda_id ? $lead->travel_agenda->name : "-";
$salutation = $lead->customer->salutation_id == 1 ? 'Herr' : 'Frau';
$salutation = $lead->customer->getSalutationName();
$start_date = $lead->travelperiod_start ? _format_date($lead->travelperiod_start) : '-';
$end_date = $lead->travelperiod_end ? _format_date($lead->travelperiod_end) : '-';
$booking_date = $lead->request_date ? _format_date($lead->request_date) : '-';
$participants = "";
if($lead->lead_participants->count()){
$participants = "Teilnehmer:<br>";
$participants = "Teilnehmer:in<br>";
foreach($lead->lead_participants as $participant){
$participants .= $participant->salutation ? $participant->salutation->name." " : '';
$participants .= $participant->participant_firstname." ".$participant->participant_name;