'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember', ]; private static $days = [ 0 => 'Sonntag', 1 => 'Montag', 2 => 'Dienstag', 3 => 'Mittwoch', 4 => 'Donnerstag', 5 => 'Freitag', 6 => 'Samstag', ]; private static $shortDays = [ 0 => 'So', 1 => 'Mo', 2 => 'Di', 3 => 'Mi', 4 => 'Do', 5 => 'Fr', 6 => 'Sa', ]; public static $de_days = [ 1 => 'Montag', 2 => 'Dienstag', 3 => 'Mittwoch', 4 => 'Donnerstag', 5 => 'Freitag', 6 => 'Samstag', 7 => 'Sonntag', ]; private static $roles = [ 0 => 'Kunde', 1 => 'Admin', 2 => 'SuperAdmin', 3 => 'SysAdmin', ]; private static $salutation = [ 1 => 'Herr', 2 => 'Frau', 3 => 'Divers/keine Anrede', 4 => 'Firma', ]; public static function getMonth($i){ return self::$months[$i]; } public static function getDay($i){ return self::$days[$i]; } public static function getShortDay($i){ return self::$shortDays[$i]; } public static function getDeDays(){ return self::$de_days; } public static function getDeDay($i){ return self::$de_days[$i]; } public static function getRoleLabel($role_id = 0, $pre = "", $post = ""){ return ''.$pre.self::$roles[$role_id].$post.''; } public static function getLable($id){ switch ($id) { case 0: return 'badge-default'; break; case 1: return 'badge-warning'; break; case 2: return 'badge-primary'; break; case 3: return 'badge-success'; break; } } public static function getSelectedOptions($values, $id = null, $empty = false){ $ret = ""; if($empty){ $ret .= '\n'; } foreach ($values as $key => $value){ $attr = ($key == $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getActiveIcon($active){ return $active ? '' : ''; } public static function getRolesOptions($id = 0){ $ret = ""; foreach (self::$roles as $role_id => $value){ $attr = ($role_id == $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getSalutationOptions($id){ $ret = ""; foreach (self::$salutation as $s_id => $value){ $attr = ($s_id == $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getYearSelectOptions(){ $start = date("Y", strtotime("-5 years", time())); $end = date("Y", strtotime("+1 years", time())); $values = range($start, $end); $now = date("Y", time()); $ret = ""; foreach ($values as $value){ $attr = ($value == $now) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getDraftTypes($setId = false){ $options = DraftType::all()->sortByDesc('id')->sortByDesc('pos'); $ret = ""; foreach ($options as $option){ $attr = ($option->id == $setId) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function createTimeRange($start = '0:00', $end = "23:30", $interval = '30 mins'){ $start_time = strtotime($start); $end_time = strtotime($end); $format = 'G:i'; $current = time(); $add_time = strtotime('+'.$interval, $current); $diff = $add_time - $current; $times = []; while ($start_time < $end_time){ $times[] = date($format, $start_time); $start_time += $diff; } $times[] = date($format, $start_time); return $times; } public static function getTimeInSteps($id = false){ $times = self::createTimeRange(); $ret = ''; foreach ($times as $item){ $attr = ($item === $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getRangeOptions($id = false, $range = 30, $name = "", $start=1){ $range = range($start, $range); $ret = ""; foreach ($range as $item){ $attr = ($item === $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getDraftOptions($setId = false){ $options = Draft::where('active', 1)->orderBy('id', 'DESC')->get(); $ret = ""; foreach ($options as $option){ $attr = ($option->id === $setId) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getAuthorOptions($setId = false){ $options = CMSAuthor::orderBy('id', "DESC")->get(); $ret = ""; foreach ($options as $option){ $attr = ($option->id === $setId) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getCMSContentOptions($identifier, $setId = false, $empty=false){ $options = CMSContent::where('identifier', '=', $identifier)->get()->sortBy('pos'); $ret = ""; if($empty){ $ret = '\n'; } foreach ($options as $option){ $attr = ($option->id === intval($setId)) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getTravelClassOptions($programId = false, $setId = false){ $options = TravelClass::where('program_id', $programId)->get(); $ret = '\n'; foreach ($options as $option){ $attr = ($option->id === $setId) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getTravelCountriesOptions($countryId = false, $crm = true){ $checked = []; if($countryId){ !is_array($countryId) ? $checked = array($countryId) : $checked = $countryId; } $options = TravelCountry::where('active_backend',1)->get(); $ret = ''; foreach ($options as $option){ $id = $crm ? $option->crm_id : $option->id; $attr = (in_array($id, $checked)) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getTravelUserOptions($id = false, $order = "ASC", $empty=false){ $options = TravelUser::orderBy('id', $order)->get(); $ret = ''; if($empty){ $ret = '\n'; } foreach ($options as $option){ $attr = ($option->id === $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getTravelPlaceOptions($id = false, $order = "ASC", $empty=false){ $options = TravelPlace::where('active',1)->orderBy('id', $order)->get(); $ret = ''; if($empty){ $ret = '\n'; } foreach ($options as $option){ $attr = ($option->id === $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getIQTravelItemsOptions($id = false, $order = "ASC", $empty=false){ $options = IQTravelItem::where('active',1)->orderBy('id', $order)->get(); $ret = ''; if($empty){ $ret = '\n'; } foreach ($options as $option){ $attr = ($option->id === $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getIQTravelGroupsOptions($id = false, $order = "ASC", $empty=false){ $options = IQTravelGroup::where('active',1)->orderBy('id', $order)->get(); $ret = ''; if($empty){ $ret = '\n'; } foreach ($options as $option){ $attr = ($option->id === $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getCustomerMailDirsOptions(CMSContent $customer_mail_dir, $checked = []){ //$checked = []; $model = $customer_mail_dir->getArrayContent('model'); switch ($model){ case 'TravelCountry': $options = \App\Models\Sym\TravelCountry::where('active_backend',1)->get(); break; case 'Airline': $options = Airline::where('name_full', 'like', '%Xemail%')->get(); break; case 'Insurance': $options = Insurance::where('active',1)->get(); break; case 'TravelCompany': $options = TravelCompany::where('active',1)->get(); break; default: return ''; } $ret = ''; foreach ($options as $option){ $attr = (in_array($option->id, $checked)) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getFewoLodgingOptions($id = false){ $options = FewoLodging::all(); $ret = ''; foreach ($options as $option){ $attr = ($option->id === $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getTravelBookingFewoChannelOptions($id = false){ $options = TravelBookingFewoChannel::all(); $ret = ''; foreach ($options as $option){ $attr = ($option->id === $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getTravelNationalityOptions($id = false){ $options = TravelNationality::where('active',1)->get(); $ret = ''; foreach ($options as $option){ $attr = ($option->id === $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getTravelGuideOptions($id = false){ $options = TravelGuide::where('active',1)->get(); $ret = '\n'; foreach ($options as $option){ $attr = ($option->id === $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getWeekdaysOptions($programId = false, $weekdays = []){ if($programId){ $tp = TravelProgram::findOrFail($programId); $options = explode(',', $tp->weekdays); }else{ $options = range(0, 6); } $ret = '\n'; foreach ($options as $option){ $attr = (in_array($option, $weekdays)) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getWeekdaysString($weekdays = [], $short = false){ $ret = ""; if(is_array($weekdays) && count($weekdays)){ foreach($weekdays as $weekday){ if($weekday !== NULL){ if($short){ $ret .= self::getShortDay($weekday).', '; }else{ $ret .= self::getDay($weekday).', '; } } } if($ret != ""){ return rtrim($ret, ", "); } } return "alle Wochentage"; } public static function getParentBy($obj = NULL, $options, $empty=true){ $ret = ""; $setId = 0; if($obj){ $setId = $obj->id; } if($empty){ // $ret .= '\n'; } foreach ($options as $id => $name){ $attr = ($id === $setId) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function filterHTML($html, $arg = [], $save = false){ $dom = new \DOMDocument('1.0', 'UTF-8'); //@$dom->loadHTML(); if($html == ""){ return ""; } @$dom->loadHTML( mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); if(isset($arg['src'])){ if(in_array('addHost', $arg['src'])){ $images = $dom->getElementsByTagName('img'); foreach ($images as $image) { $src = $image->getAttribute('src'); if(strpos($src, 'http') === false){ $host = config('app.url_stern'); if(strpos($src, $host) === false){ $src = $host."/".ltrim($src, '/'); } $image->setAttribute('src', $src); } } } if(in_array('removeHost', $arg['src'])){ $images = $dom->getElementsByTagName('img'); foreach ($images as $image) { $src = $image->getAttribute('src'); $host = config('app.url_stern'); if(strpos($src, $host) !== false){ $src = str_replace($host, '', $src); } $image->setAttribute('src', $src); } } } $html = $dom->saveHTML(); $html = preg_replace('~<(?:!DOCTYPE|/?(?:html|head|body))[^>]*>\s*~i', '', $html); if($save){ return mb_convert_encoding($html, "UTF-8", "HTML-ENTITIES"); } return $html; } /* public static function getIndustrySectorsWithoutParents($id = false, $sameId = false, $all = true){ $values = IndustrySector::where('parent_id', null)->get(); $ret = ""; if($all){ $ret .= '\n'; } foreach ($values as $value){ if($sameId == $value->id){ continue; } $attr = ($value->id == $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getContriesWithMore($id, $all=true){# $values = Country::all(); $counter = 1; $ret = ""; if($all){ $ret .= '\n'; } foreach ($values as $value){ if( $counter == 7){ $ret .= ''; } $attr = ($value->id == $id) ? 'selected="selected"' : ''; $ret .= '\n'; $counter ++; } $ret .= ''; return $ret; } public static function getContriesCodes($id, $all=true){# $values = Country::all(); $counter = 1; $ret = ""; if($all){ $ret .= '\n'; } foreach ($values as $value){ if(!$value->phone) continue; if( $counter == 7){ $ret .= ''; } $attr = ($value->id == $id) ? 'selected="selected"' : ''; $ret .= '\n'; $counter ++; } $ret .= ''; return $ret; } public static function getSalutation($id){ $values = array('mr' => __('MR'), 'ms' => __('MS')); $ret = ""; $ret .= '\n'; foreach ($values as $key => $value){ $attr = ($key == $id) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getSalutationLang($id){ $values = array('mr' => __('MR'), 'ms' => __('MS')); return (!empty($values[$id]) ? $values[$id] : ''); } */ }