'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 $roles = [ 0 => 'Kunde', 1 => 'Admin', 2 => 'SuperAdmin', ]; private static $salutation = [ 1 => 'Herr', 2 => 'Frau', 3 => 'Firma', ]; public static function getMonth($i){ return self::$months[intval($i)]; } public static function getDay($i){ return self::$days[intval($i)]; } public static function getRoleLabel($role_id = 0){ return ''.self::$roles[$role_id].''; } 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; } } public static function getRolesOptions(){ $ret = ""; foreach (self::$roles as $role_id => $value){ $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'); $ret = ""; foreach ($options as $option){ $attr = ($option->id == $setId) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getRangeOptions($id = false, $range = 30, $name = ""){ $range = range(1, $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 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){ $options = TravelCountry::where('active_backend',1)->get(); $ret = ''; foreach ($options as $option){ $attr = ($option->crm_id === $countryId) ? 'selected="selected"' : ''; $ret .= '\n'; } return $ret; } public static function getTravelUserOptions($id = false){ $options = TravelUser::all(); $ret = ''; foreach ($options as $option){ $attr = ($option->id === $id) ? '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 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 = []){ $ret = ""; if(count($weekdays)){ foreach($weekdays as $weekday){ if($weekday !== NULL){ $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(); @$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'); $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] : ''); } */ }