Reiseland Kontaktdaten, Rabatt API

This commit is contained in:
Kevin Adametz 2019-11-07 17:08:16 +01:00
parent 8f29c15a2b
commit 70704be1ea
30 changed files with 471 additions and 95 deletions

View file

@ -162,8 +162,8 @@ class DraftController extends Controller
$room_adult += $room['adult'];
$room_children += $room['children'];
$room_price_adult += ($room['price_adult'] * $room['adult']);
$room_price_children += ($room['price_children'] * $room['children']);
$room_price_adult += ($room['price_adult_full'] * $room['adult']);
$room_price_children += ($room['price_children_full'] * $room['children']);
if(isset($room_names[$room['name']])){
$room_names[$room['name']] = $room_names[$room['name']]+1;
@ -188,9 +188,9 @@ class DraftController extends Controller
'start_date' => $data['startDateStr'],
'end_date' => $data['endDateStr'],
'service' => $service,
'price_adult' => $room['price_adult'],
'price_adult' => $room['price_adult_full'],
'adult' => $room['adult'],
'price_children' => $room['price_children'],
'price_children' => $room['price_children_full'],
'children' => $room['children'],
'pos' => 0,
'in_pdf' => true,
@ -375,6 +375,41 @@ class DraftController extends Controller
'comfort' => $data['comfort']
];
}
$price_info_travel_discounts = [];
foreach ($data['discount'] as $travel_discount){
$service = trans('_vorlagen.aufpreis_option');
$this->option = "";
$service = $this->replaceService($service);
if($travel_discount['price'] > 0){
$travel_discount['price'] = $travel_discount['price']*-1;
}
$price_info_travel_options[] = [
'booking_id' => $data['booking_id'],
'travel_program_id' => $data['travel_program_id'],
'fewo_lodging_id' => null,
'travel_class_id' => null,
'draft_item_id' => null,
'draft_type_id' => 42,
'request_date' => $data['request_date'],
'days_start' => null,
'days_duration' => null,
'start_date' => null,
'end_date' => null,
'service' => $service,
'price_adult' => $travel_discount['price'],
'adult' => $travel_discount['count'],
'price_children' => 0,
'children' => 0,
'pos' => 0,
'in_pdf' => true,
'comfort' => $data['comfort']
];
}
$info_texts = [];
$last_post = 0;
foreach ($draft->draft_items as $draft_item){
@ -522,6 +557,15 @@ class DraftController extends Controller
}
}
//set travel discount prices
if(count($price_info_travel_discounts)){
foreach ($price_info_travel_discounts as $price_info_travel_discount){
$last_post ++;
$price_info_travel_option['pos'] = $last_post;
BookingDraftItem::create($price_info_travel_option);
}
}
//set travel options prices
if(count($info_texts)){
foreach ($info_texts as $info_text){

View file

@ -50,12 +50,20 @@ class CMSContentController extends Controller
return back()->withErrors($validator);
}
if($data['id'] == "new"){
if($data['id'] === "new"){
CMSContent::create($data);
//store in cms old Datebase
\App\Models\Sym\CmsContent::create($data);
}else{
$model = CMSContent::find($data['id']);
$model->fill($data);
$model->save();
$m = \App\Models\Sym\CmsContent::find($data['id']);
$m->fill($data);
$m->save();
}
\Session()->flash('alert-save', '1');
return redirect(route('cms_content_all'));

View file

@ -54,7 +54,9 @@ class CMSContentCountryController extends Controller
{
$data = Input::all();
if(!isset($data['contact_lands'])){
$data['contact_lands'] = null;
}
$model = TravelCountry::findOrFail($id);
$model->fill($data);
$model->save();

View file

@ -151,12 +151,15 @@ class DraftController extends Controller
'name' => $data['name'],
'active' => isset($data['active']) ? true : false,
'color' => $data['color'],
'pos' => $data['pos'],
]);
}else{
$draft_type = DraftType::find($data['id']);
$draft_type->name = $data['name'];
$draft_type->active = isset($data['active']) ? true : false;
$draft_type->color = $data['color'];
$draft_type->pos = $data['pos'];
$draft_type->save();
}

View file

@ -68,6 +68,7 @@ class HomeController extends Controller
public function checkLogin($identify, $token, $show = false)
{
if($identify){
//user find by $identify
$user = User::where('identify', '=', $identify)->first();
@ -83,9 +84,11 @@ class HomeController extends Controller
return abort(404);
}
if($sf_guard_user->token != $token){
return abort(404);
}
$time = Carbon::parse($sf_guard_user->token_at);
$now = Carbon::now();
$duration = $time->diffInSeconds($now);
@ -123,6 +126,10 @@ class HomeController extends Controller
if($show == 'travel_country'){
return redirect(route('admin_settings_travel_country'));
}
if($show == 'cms_content_country'){
return redirect(route('cms_content_country'));
}
}

View file

@ -201,9 +201,16 @@ class TravelUserBookingFewoController extends Controller
})
->addColumn('is_calendar', function (TravelUserBookingFewo $travel_user_booking_fewo) {
$back = "";
$back .= $travel_user_booking_fewo->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 .= $travel_user_booking_fewo->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 .= $travel_user_booking_fewo->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>';
$back .= get_active_badge($travel_user_booking_fewo->is_calendar_fewo_direct, "FEWO Direkt")." ";
$back .= get_active_badge($travel_user_booking_fewo->is_calendar_hrs, "HRS")." ";
$back .= get_active_badge($travel_user_booking_fewo->is_calendar_stern_tours, "STERN TOURS");
return $back;
})
->addColumn('is_mail', function (TravelUserBookingFewo $travel_user_booking_fewo) {
$back = "";
$back .= get_active_badge($travel_user_booking_fewo->isSendUserMail(), "Mietbestätigung")." ";
$back .= get_active_badge($travel_user_booking_fewo->isSendInfoMail(), "Anrreiseinfo")." ";
$back .= get_active_badge($travel_user_booking_fewo->isSendServiceMail(), "Dienstleister Mail");
return $back;
})
->addColumn('status_name', function (TravelUserBookingFewo $travel_user_booking_fewo) {
@ -212,7 +219,7 @@ class TravelUserBookingFewoController extends Controller
->addColumn('action_delete', function (TravelUserBookingFewo $travel_user_booking_fewo) {
return '<a href="' . route('travel_user_booking_fewo_delete', [$travel_user_booking_fewo->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="far fa-trash"></span></a>';
})
->rawColumns(['action_edit', 'fewo_lodging', 'travel_user', 'is_calendar', 'action_delete'])
->rawColumns(['action_edit', 'fewo_lodging', 'travel_user', 'is_calendar', 'is_mail', 'action_delete'])
->make(true);
}

View file

@ -4,7 +4,6 @@ namespace App\Models;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\CMSContent
*

View file

@ -24,6 +24,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType query()
* @property int|null $pos
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DraftType wherePos($value)
*/
class DraftType extends Model
{
@ -32,7 +34,7 @@ class DraftType extends Model
protected $table = 'draft_types';
protected $fillable = [
'name', 'active', 'color',
'name', 'active', 'color', 'pos'
];
public function draft_items()

View file

@ -0,0 +1,88 @@
<?php
namespace App\Models\Sym;
use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\Sym\CmsContent
*
* @property int $id
* @property string $name
* @property string $slug
* @property string $field
* @property string|null $text
* @property string|null $full_text
* @property int|null $integer
* @property float|null $decimal
* @property string|null $created_at
* @property string|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereDecimal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereField($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereFullText($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereInteger($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereText($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereUpdatedAt($value)
* @mixin \Eloquent
*/
class CmsContent extends Model
{
use Sluggable;
protected $connection = 'mysql';
protected $table = 'cms_contents';
protected $fillable = [
'name', 'slug', 'field', 'text', 'full_text', 'integer', 'decimal',
];
public $timestamps = false;
public function sluggable()
{
return [
'slug' => [
'source' => 'name'
]
];
}
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
}
public function setDecimalAttribute($value)
{
$value = $this->_format_number($value);
$value = substr($value, -13);
$this->attributes['decimal'] = floatval(str_replace(',', '.', $value));
}
public function getDecimalAttribute()
{
if(isset($this->attributes['decimal'])){
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
return number_format(($this->attributes['decimal']), 2, ',', '.');
}
return "";
}
public function setIntegerAttribute($value)
{
$value = $this->_format_number($value);
$value = substr($value, -10);
$this->attributes['integer'] = intval($value);
}
}

View file

@ -20,6 +20,18 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry query()
* @property string|null $contact_headline
* @property string|null $contact_text_1
* @property string|null $contact_text_2
* @property string|null $contact_text_3
* @property string|null $contact_text_4
* @property string|null $contact_footer
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactFooter($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactHeadline($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactText1($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactText2($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactText3($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactText4($value)
*/
class TravelCountry extends Model
{
@ -32,6 +44,7 @@ class TravelCountry extends Model
'name',
'is_customer_country',
'active_backend',
'contact_lands',
'contact_headline',
'contact_text_1',
'contact_text_2',
@ -41,6 +54,9 @@ class TravelCountry extends Model
];
protected $casts = ['contact_lands' => 'array'];
public $timestamps = false;

View file

@ -37,6 +37,24 @@ use Illuminate\Support\Str;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry query()
* @property string|null $slug
* @property string|null $text_before
* @property string|null $text_after
* @property string|null $contact_headline
* @property string|null $contact_text_1
* @property string|null $contact_text_2
* @property string|null $contact_text_3
* @property string|null $contact_text_4
* @property string|null $contact_footer
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactFooter($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactHeadline($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactText1($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactText2($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactText3($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactText4($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereSlug($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereTextAfter($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereTextBefore($value)
*/
class TravelCountry extends Model
{
@ -52,6 +70,7 @@ class TravelCountry extends Model
'html_information',
'text_before',
'text_after',
'contact_lands',
'contact_headline',
'contact_text_1',
'contact_text_2',
@ -65,6 +84,9 @@ class TravelCountry extends Model
];
protected $casts = ['contact_lands' => 'array'];
public $timestamps = false;
public function travel_program_country()

View file

@ -96,6 +96,8 @@ use App\Services\Util;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFewo whereTravelBookingFewoChannelId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFewo whereTravelUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFewo whereUpdatedAt($value)
* @property string|null $last_change_at
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFewo whereLastChangeAt($value)
*/
class TravelUserBookingFewo extends Model
{
@ -670,4 +672,27 @@ class TravelUserBookingFewo extends Model
$this->travel_user->first_name." ".$this->travel_user->last_name." | ".$this->from_date." - ".$this->to_date." | ".$this->adults." + ".$this->children." (Erwachsene + Kinder)";
}
public function isSendUserMail(){
if($this->send_user_mail != NULL){
return true;
}
return false;
}
public function isSendInfoMail(){
if($this->send_info_mail != NULL){
return true;
}
return false;
}
public function isSendServiceMail(){
if($this->send_service_mail != NULL){
return true;
}
return false;
}
}

View file

@ -121,7 +121,7 @@ class HTMLHelper
}
public static function getDraftTypes($setId = false){
$options = DraftType::all()->sortByDesc('id');
$options = DraftType::all()->sortByDesc('id')->sortByDesc('pos');
$ret = "";
foreach ($options as $option){
$attr = ($option->id == $setId) ? 'selected="selected"' : '';
@ -165,17 +165,23 @@ class HTMLHelper
}
public static function getTravelCountriesOptions($countryId = false){
$checked = [];
if($countryId){
!is_array($countryId) ? $checked = array($countryId) : $checked = $countryId;
}
$options = TravelCountry::where('active_backend',1)->get();
$ret = '';
foreach ($options as $option){
$attr = ($option->crm_id === $countryId) ? 'selected="selected"' : '';
$attr = (in_array($option->crm_id, $checked)) ? 'selected="selected"' : '';
$ret .= '<option value="'.$option->crm_id.'" '.$attr.'>'.$option->name.'</option>\n';
}
return $ret;
}
public static function getTravelUserOptions($id = false){
$options = TravelUser::all();
public static function getTravelUserOptions($id = false, $order = "ASC"){
$options = TravelUser::orderBy('id', $order)->get();
$ret = '';
foreach ($options as $option){
$attr = ($option->id === $id) ? 'selected="selected"' : '';

View file

@ -35,8 +35,12 @@ class Util
}
public static function _clean_float($value){
$groups = explode(".", preg_replace("/[^0-9.]/", "", str_replace(',', '.', $value)));
$lastGroup = array_pop($groups);
$groups = explode(".", preg_replace("/[^0-9.-]/", "", str_replace(',', '.', $value)));
$lastGroup = 0;
if(count($groups) > 1){
$lastGroup = array_pop($groups);
}
$number = implode('', $groups);
return (strlen($lastGroup) < 3) ? floatval($number.'.'.$lastGroup) : floatval($number.$lastGroup);
}

View file

@ -46,12 +46,16 @@ if (! function_exists('pre_slug')) {
if (! function_exists('get_active_badge')) {
function get_active_badge($active)
function get_active_badge($active, $tooltip = false, $pos = "top")
{
return $active ? '<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>';
if($tooltip){
$tooltip = 'data-toggle="tooltip" data-placement="top" data-original-title="'.$tooltip.'"';
}
return $active ? '<span class="badge badge-pill badge-success" '.$tooltip.'><i class="far fa-check"></i></span>' : '<span class="badge badge-pill badge-danger" '.$tooltip.'><i class="far fa-times"></i></span>';
}
}
if (! function_exists('get_switcher_input')) {
function get_switcher_input($active = false, $name = "", $label = "")
{