';
54 |
55 | $yform = new rex_yform();
56 | $yform->setObjectparams('form_action', rex_url::currentBackendPage());
57 |
58 | $yform->setValueField('hidden', ['bookingdate', date('Y-m-d H:i:s')]);
59 | $yform->setValueField('hidden', ['status', 'confirmed']);
60 | $yform->setValueField('hidden', ['object_id', $object_id, 'REQUEST']);
61 |
62 | $yform->setValueField('html', ['', $hidden_start]);
63 | $yform->setValueField('text', ['datestart', '', '', '', ['type' => 'hidden', 'id' => 'datestart']]);
64 | $yform->setValueField('text', ['dateend', '', '', '', ['type' => 'hidden', 'id' => 'dateend']]);
65 | $yform->setValueField('html', ['', $div_end]);
66 |
67 |
68 | $yform->setValueField('html', ['', $row_start_3]);
69 | $yform->setValueField('text', ['date_start', 'Anreise', '', 'no_db', ['id' => 'date_start', 'disabled' => 'disabled']]);
70 | $yform->setValueField('html', ['', $next_col_3]);
71 | $yform->setValueField('text', ['date_end', 'Abreise', '', 'no_db', ['id' => 'date_end', 'disabled' => 'disabled']]);
72 | $yform->setValueField('html', ['', $row_end]);
73 |
74 | $yform->setValueField('html', ['', '
']);
75 |
76 | $yform->setValueField('html', ['', $row_start_6]);
77 | $yform->setValueField('text', ['vorname', 'Vorname']);
78 | $yform->setValueField('html', ['', $next_col_6]);
79 | $yform->setValueField('text', ['nachname', 'Nachname']);
80 | $yform->setValueField('html', ['', $row_end]);
81 |
82 | $yform->setValueField('text', ['anschrift', 'Anschrift']);
83 | $yform->setValueField('html', ['', $row_start_3]);
84 | $yform->setValueField('text', ['plz', 'PLZ']);
85 | $yform->setValueField('html', ['', $next_col_9]);
86 | $yform->setValueField('text', ['ort', 'Ort']);
87 | $yform->setValueField('html', ['', $row_end]);
88 | $yform->setValueField('text', ['land', 'Land']);
89 |
90 | $yform->setValueField('html', ['', $row_start_6]);
91 | $yform->setValueField('text', ['telefon', 'Telefon']);
92 | $yform->setValueField('html', ['', $next_col_6]);
93 | $yform->setValueField('text', ['email', 'E-Mail']);
94 | $yform->setValueField('html', ['', $row_end]);
95 |
96 | $yform->setValueField('html', ['', $row_start_6]);
97 | $yform->setValueField('text', ['personen', 'Anzahl Personen']);
98 | $yform->setValueField('html', ['', $next_col_6]);
99 | $yform->setValueField('text', ['anreisezeit', 'Anreisezeit']);
100 | $yform->setValueField('html', ['', $row_end]);
101 |
102 | $yform->setValueField('textarea', ['nachricht', 'Nachricht']);
103 |
104 | $yform->setValueField('submit', ['Submit', 'Buchung speichern', 'no_db']);
105 | $yform->setValueField('html', ['', 'Zurück ... ']);
106 |
107 | $yform->setValueField('html', ['', '
']);
114 |
115 | $yform->setActionField('db', ['rex_buka_bookings']);
116 | $yform->setActionField('redirect', [rex_url::currentBackendPage()]);
117 |
118 |
119 |
120 | ?>
121 |
122 |
141 |
142 | = $yform->getForm(); ?>
143 |
144 |
147 |
148 |
149 |
150 |
151 |
159 |
--------------------------------------------------------------------------------
/lib/buka_ical.php:
--------------------------------------------------------------------------------
1 | format('Y-m-d');
21 | $strAbreise = $oAbreise->format('Y-m-d');
22 |
23 | $booked = buka_booking::is_booked($strAnreise, $strAbreise, $objectid);
24 |
25 |
26 | // dump(trim(rex_config::get('buchungskalender','ignore_airbnb_blocked'),'|'));
27 | // geblockte Daten von Airbnb nicht übernehmen.
28 | if (trim(rex_config::get('buchungskalender','ignore_airbnb_blocked'),'|')) {
29 | if (strpos($date['UID'],'airbnb')) {
30 | if (strpos($date['SUMMARY'],'Not available')) {
31 | continue;
32 | }
33 | }
34 | }
35 |
36 | // wenn die Periode noch frei ist, eintragen ....
37 | if (!$booked && $strAnreise && $strAbreise) {
38 |
39 | $name = explode(' ', $date['SUMMARY']);
40 | $nachricht = isset($date['DESCRIPTION']) ? str_replace('\n', "\n", $date['DESCRIPTION']) : 'ical-Buchung';
41 |
42 | $sql = rex_sql::factory()->setTable(rex::getTable('buka_bookings'));
43 | $values = [
44 | 'vorname' => $name[0],
45 | 'nachname' => $name[1],
46 | 'nachricht' => $nachricht,
47 | 'email' => $date['UID'] ?? '',
48 | 'object_id' => $objectid,
49 | 'datestart' => $strAnreise,
50 | 'dateend' => $strAbreise,
51 | 'bookingdate' => date('Y-m-d H:i:s'),
52 | 'status' => 'confirmed'
53 | ];
54 | $sql->setValues($values);
55 | $sql->insert();
56 | }
57 | }
58 | }
59 |
60 |
61 | public static function ics_string_to_dates ($icsText) {
62 | $icsDates = [];
63 | // $icsFile = file_get_contents($paramUrl);
64 | // print_r($icsFile);
65 | $icsText = preg_replace('/\r\n |\r |\n /', '', $icsText);
66 |
67 | $icsData = explode("BEGIN:", $icsText);
68 |
69 | foreach ($icsData as $key => $value) {
70 | $icsDatesMeta[$key] = explode("\n", $value);
71 | }
72 |
73 | foreach ($icsDatesMeta as $key => $value) {
74 | foreach ($value as $subKey => $subValue) {
75 | if ($subValue != "") {
76 | if ($key != 0 && $subKey == 0) {
77 | $icsDates[$key]["BEGIN"] = $subValue;
78 | } else {
79 | $subValueArr = explode(":", $subValue, 2);
80 | $icsDates[$key][$subValueArr[0]] = $subValueArr[1];
81 | }
82 | }
83 | }
84 | }
85 |
86 | return $icsDates;
87 |
88 | }
89 |
90 |
91 | public static function send_ical_data_for_obj ($object_id = 0) {
92 | $query = buka_booking::get_query($object_id);
93 | // nur Daten aus der Zukunft ausliefern
94 | $query->whereRaw('(datestart > :today OR dateend > :today)',['today'=>date('Y-m-d')]);
95 | $query->where('status','confirmed');
96 |
97 | $out = 'BEGIN:VCALENDAR
98 | VERSION:2.0
99 | PRODID;X-RICAL-TZSOURCE=TZINFO:-//Agile Websites//buchungskalender 0.5//EN
100 | CALSCALE:GREGORIAN
101 | ';
102 |
103 | foreach ($query->find() as $i => $data) {
104 | // Terminstart
105 | $out .= 'BEGIN:VEVENT
106 | DTSTART;VALUE=DATE:' . str_replace('-', '', $data->datestart) . PHP_EOL;
107 | $out .= 'DTEND;VALUE=DATE:' . str_replace('-', '', $data->dateend) . '
108 | UID:'.rex_config::get('buchungskalender','ical_uid').'
109 | SUMMARY:Booked date
110 | END:VEVENT
111 | ';
112 | }
113 |
114 | $out .= 'END:VCALENDAR';
115 |
116 | return $out;
117 |
118 |
119 | }
120 |
121 |
122 | /**
123 | * Erneuert den Ical Cache alle 15 Minuten
124 | * Wenn ical Source nicht erreichbar ist, bleibt die Datei für 24 Stunden gültig
125 | * Danach wird false zurück gegeben.
126 | *
127 | * @param type $src
128 | * @param type $file
129 | * @return boolean
130 | */
131 | public static function check_ical_data() {
132 |
133 | $objects = rex_yform_manager_table::get(rex::getTable('buka_objects'))->query()->where('ical_sync_link',"",'>')
134 | ->find();
135 |
136 | foreach ($objects as $object) {
137 | $ical_urls = preg_split('/\R/',$object->ical_sync_link);
138 | foreach ($ical_urls as $ical_url) {
139 | self::fetch_ical_data($object,$ical_url);
140 | }
141 | }
142 |
143 | }
144 |
145 | public static function fetch_ical_data ($object,$ical_url) {
146 | $ical_url = trim($ical_url);
147 | // $icalfile = rex_path::cache('buchungskalender/' . md5($object->name.$ical_url).'.ics');
148 | $icalfile = rex_path::addonCache('buchungskalender', md5($object->name.$ical_url).'.ics');
149 |
150 |
151 | // dump($icalfile);
152 |
153 | // Alter prüfen
154 | if (file_exists($icalfile)) {
155 | // Wenn Datei erst 15 Minuten alt, dann ok
156 | if (filemtime($icalfile) > time() - intval(rex_config::get('buchungskalender','ical_interval'))) {
157 | return true;
158 | }
159 | }
160 |
161 | $ch = curl_init($ical_url);
162 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // als String zurückgeben
163 | curl_setopt($ch, CURLOPT_HEADER, false);
164 | $content = curl_exec($ch);
165 | curl_close($ch);
166 |
167 | if (!$content) {
168 | $content = file_get_contents($ical_url);
169 | }
170 |
171 | // dump($content);
172 |
173 |
174 | if (strlen($content) > 5) {
175 | rex_file::putCache($icalfile,$content);
176 | // rex_file::put($icalfile,$content);
177 | self::CheckIcalSource($content,$object->id);
178 | return true;
179 | }
180 |
181 | // Falls nicht erfolgreich, wird geprüft, ob das Alter älter als 1 Tag ist.
182 | if (file_exists($icalfile) && filemtime($icalfile) > time() - 86400) {
183 | return true;
184 | }
185 |
186 | return false;
187 |
188 | }
189 |
190 | }
191 |
--------------------------------------------------------------------------------
/pages/bookings.php:
--------------------------------------------------------------------------------
1 |
';
5 | $row_start_1_4 = '
';
6 | $next_col_3_4 = '
';
7 | $row_end = '
';
8 |
9 | $params = $_REQUEST;
10 | $func = rex_request('func','string');
11 | $id = rex_request('data_id','int');
12 |
13 | $qry = buka_booking::get_query();
14 |
15 | if (rex_request('filter','string') == 'next_arrival') {
16 | $qry->resetWhere();
17 | $qry->whereRaw('dateend >= "'.date('Y-m-d').'" AND status = "confirmed"');
18 | $qry->orderBy('datestart');
19 | }
20 |
21 | // Achtung! Indexwerte des Arrays sind abhängig von der Feldposition
22 |
23 | $next_arrival = [
24 | 'FORM' => [
25 | 'rex_yform_searchvars-rex_buka_bookings' => [
26 | 2 => '>'.date('Y-m-d'),
27 | 9 => [0 => 'confirmed']
28 | ],
29 | ],
30 | 'sort'=>'datestart',
31 | 'sorttype'=>'asc'
32 | ];
33 |
34 | if ($func == 'edit' && $id) {
35 |
36 | $yform = new rex_yform();
37 | $yform->setObjectparams('form_name', 'table-rex_buka_bookings');
38 | $yform->setObjectparams('form_action','index.php');
39 | $yform->setValueField('hidden',['page','buchungskalender/bookings','REQUEST','no_db']);
40 | $yform->setValueField('hidden',['func','edit','REQUEST','no_db']);
41 | $yform->setValueField('hidden',['src',rex_request('src','string'),'REQUEST','no_db']);
42 | $yform->setValueField('hidden',['data_id',$id,'REQUEST','no_db']);
43 | // $yform->setDebug(TRUE);
44 | $yform->setObjectparams('form_showformafterupdate', 0);
45 | $yform->setObjectparams('getdata', true);
46 | $yform->setObjectparams('main_id', $id);
47 | $yform->setObjectparams('main_table', rex::getTable('buka_bookings'));
48 | $yform->setObjectparams('main_where', 'id='.$id);
49 | $yform->setObjectparams('submit_btn_label', rex_i18n::msg('buka_send_button'));
50 |
51 | $yform->setValueField('html', ['html1','HTML','
']);
52 | $yform->setValueField('date', ['datestart','translate:buka_startdate','2019','2050','d.m.Y','0','0','input:date']);
53 | $yform->setValueField('date', ['dateend','translate:buka_enddate','2019','2050','d.m.Y','0','0','input:date']);
54 | $yform->setValueField('text', ['anreisezeit','translate:buka_arrivaltime','','0']);
55 | $yform->setValueField('html', ['html2','html2','
']);
56 | $yform->setValueField('be_manager_relation', ['object_id','translate:buka_object','rex_buka_objects','name','0','1','translate:buka_please_select_object']);
57 | $yform->setValueField('be_manager_relation', ['bookingtype_id','translate:booking_type','rex_buka_bookingtype','name','0','1']);
58 | $yform->setValueField('html', ['html3','html3','
']);
59 | $yform->setValueField('text', ['vorname','translate:buka_firstname','','0']);
60 | $yform->setValueField('text', ['nachname','translate:buka_lastname','','0']);
61 | $yform->setValueField('html', ['html4','html4','
']);
62 | $yform->setValueField('text', ['personen','translate:buka_participants','','0']);
63 | $yform->setValueField('choice', ['status','translate:buka_state','translate:buka_asked=asked,translate:buka_confirmed=confirmed,translate:buka_canceled=storno,translate:buka_pre_booking=pre_booking,translate:buka_blocked=blocked','0','0','asked','','','-- bitte auswählen --','','','','','0']);
64 | $yform->setValueField('text', ['price','translate:buka_price','','0']);
65 | $yform->setValueField('html', ['html5','html5','
']);
66 | $yform->setValueField('textarea', ['nachricht','translate:buka_message','','0']);
67 | $yform->setValueField('html', ['html6','html6','
']);
68 | $yform->setValueField('text', ['telefon','translate:buka_phone','','0']);
69 | $yform->setValueField('text', ['email','E-Mail']);
70 | $yform->setValueField('html', ['html7','html7','
']);
71 | $yform->setValueField('text', ['anschrift','translate:buka_address','','0']);
72 | $yform->setValueField('text', ['plz','translate:buka_zip','','0']);
73 | $yform->setValueField('text', ['ort','translate:buka_city','','0']);
74 | $yform->setValueField('html', ['html8','html8','
']);
75 | $yform->setValueField('text', ['land','translate:buka_country','','0']);
76 | $yform->setValueField('choice', ['bookingstate_id','Buchungsstatus','SELECT id value, name label FROM rex_buka_bookingstate ORDER BY prio','1','1','','','','','','','','','0']);
77 | $yform->setValueField('be_manager_relation', ['participants','translate:buka_participants','rex_buka_participants','booking_id','5','0']);
78 | $yform->setValueField('text', ['hashval','','','','{"type":"hidden"}']);
79 | $yform->setValueField('datestamp', ['bookingdate','translate:buka_bookingdate','Y-m-d H:i:s','0','1']);
80 |
81 | // $yform->setValidateField('customfunction', ['datestart,dateend,object_id,status','buka_booking::unique_booking','','Dieses Buchungsdatum ist ungültig. Es gibt bereits eine Buchung für dieses Datum.','0']);
82 |
83 | $yform->setValidateField('customfunction', ['datestart,dateend,object_id,status','buka_booking::unique_booking','',rex_i18n::msg('buka_booking_uncorrect'),'0']);
84 | $yform->setValidateField('compare', ['datestart','dateend','>=',rex_i18n::msg('datefrom_dateto_booking')]);
85 |
86 | $yform->setActionField('db',['rex_buka_bookings','main_where']);
87 |
88 | if (rex_request('src','string') == 'calendar') {
89 | $yform->setActionField('redirect',['index.php?page=buchungskalender/calendar']);
90 | } elseif (rex_session('returnto')) {
91 | $yform->setActionField('redirect',[str_replace('&','&',rex_session('returnto'))]);
92 | } else {
93 | $yform->setActionField('redirect',['index.php?page=buchungskalender/bookings']);
94 | }
95 |
96 | $fragment = new rex_fragment();
97 | $fragment->setVar('class', 'edit', false);
98 | $fragment->setVar('title', rex_i18n::msg('buka_edit_booking'), false);
99 | $fragment->setVar('body', $yform->getForm(), false);
100 | echo $fragment->parse('core/page/section.php');
101 |
102 |
103 | } else {
104 |
105 | echo '
';
110 |
111 |
112 | $_REQUEST['table_name'] = 'rex_buka_bookings';
113 | include \rex_path::plugin('yform','manager','pages/data_edit.php');
114 |
115 | }
116 |
117 | ?>
--------------------------------------------------------------------------------
/lib/buka_date_cal.php:
--------------------------------------------------------------------------------
1 | set_slots();
11 | $this->set_places();
12 |
13 | }
14 |
15 |
16 | private function set_slots () {
17 | foreach (json_decode($this->object->available_times) as $item) {
18 | $day_str = str_replace($this->weekdays,array_keys($this->weekdays),$item[0]); // Mo-Fr => 0-4
19 | $days = explode('-',$day_str);
20 | if (count($days) > 1) {
21 | for ($i = $days[0]; $i <= $days[1]; $i++) {
22 | $this->time_slots[$i] = array_merge($this->time_slots[$i] ?? [],$this->fill_slots($item[1],$item[2]));
23 | }
24 | } else {
25 | $this->time_slots[$days[0]] = array_merge($this->time_slots[$days[0]] ?? [], $this->fill_slots($item[1],$item[2]));
26 | }
27 | }
28 | }
29 |
30 |
31 | private function set_places () {
32 | foreach (json_decode($this->object->places) as $pl) {
33 | $this->places[$pl[0]] = $pl[0];
34 | }
35 | }
36 |
37 | private function fill_slots($start,$end) {
38 | $slots = [];
39 | $start = str_pad(str_replace('.',':',$start),5,'0',STR_PAD_LEFT);
40 | $end = str_pad(str_replace('.',':',$end),5,'0',STR_PAD_LEFT);
41 |
42 | $period_sek = strtotime($this->object->period) - strtotime('TODAY'); // Sekunden, z.B. 00:45:00 = 2700
43 |
44 | $period = new DateInterval('PT'.$period_sek.'S');
45 | $d0 = new DateTime('2021-09-02 '.$start);
46 |
47 | $current = $d0->format('H:i');
48 |
49 | while($current < $end) {
50 | $slots[$current] = ['start'=>$current];
51 | $d0->add($period);
52 | $current = $d0->format('H:i');
53 | }
54 | array_pop($slots);
55 |
56 | return $slots;
57 | }
58 |
59 |
60 | public function getMonth($year = 0, $month = 0, $nth_month = 0) {
61 | if (!$year) {
62 | $year = date('Y');
63 | }
64 | if (!$month) {
65 | $month = date('m');
66 | }
67 |
68 | $dt = new DateTime();
69 | $dt->setDate($year, $month, 1);
70 |
71 | $class = '';
72 |
73 | foreach ($this->mobile_month_count as $k=>$mclass) {
74 | if ($nth_month > $k) {
75 | $class = $mclass;
76 | }
77 | }
78 |
79 | $out = '
';
80 | $out .= '' . $this->months[$month - 1] . ' ' . $year . ' ';
81 | foreach ($this->weekdays as $wd) {
82 | $out .= '' . $wd . ' ';
83 | }
84 | $out .= str_repeat(' ', ($dt->format('N') - 1));
85 | $day = 1;
86 | while ($day <= $dt->format('t')) {
87 | $date = $year . '-' . $dt->format('m') . '-' . str_pad($day, 2, '0', STR_PAD_LEFT);
88 | $bookingData = $this->get_booking_data_for_date($date);
89 | $season = $this->get_season($date);
90 | $out .= '' . $day . ' ';
91 | if ($date >= date('Y-m-d')) {
92 | $this->set_radio_values_for_date($date);
93 | }
94 | $day++;
95 |
96 | }
97 | $out .= ' ';
98 |
99 | return $out;
100 | }
101 |
102 | public function set_radio_values_for_date($date) {
103 | // dump($this->bookings);
104 | $dateval = strtotime($date);
105 | if (!isset($this->time_slots[date('N',$dateval)-1])) {
106 | return;
107 | }
108 | // dump($this->bookings[0]->slotvalue);
109 | // dump(count(json_decode($this->object->places)));
110 |
111 | foreach ($this->time_slots[date('N',$dateval)-1] as $time) {
112 | self::$radio_values[$date][$time['start']] = $time;
113 | self::$radio_values[$date][$time['start']]['countbookings'] = $this->get_bookings_for_time($date . ' ' . $time['start'],$date,$time['start']);
114 | self::$radio_values[$date][$time['start']]['places'] = $this->get_places_for_time($date,$time['start']);
115 | self::$radio_values[$date][$time['start']]['bookedout'] = self::$radio_values[$date][$time['start']]['countbookings'] >= count(json_decode($this->object->places));
116 | $this->set_available($date,$time['start']);
117 | }
118 | }
119 |
120 |
121 | public static function format_slot_date ($date) {
122 | $weekdays = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
123 | return $weekdays[date('N',strtotime($date))-1] .', '. date('d.m.Y - H:i',strtotime($date)).' Uhr';
124 | }
125 |
126 |
127 | public function get_bookings_for_time($datetime,$date,$time) {
128 | $datebookings = [];
129 | foreach ($this->bookings as $booking) {
130 | if (strpos($booking->slotvalue,$datetime) === 0) {
131 | $datebookings[] = $booking;
132 | }
133 | }
134 | self::$radio_values[$date][$time]['bookings'] = $datebookings;
135 | return count($datebookings);
136 | }
137 |
138 | public function get_places_for_time($date,$time) {
139 | return $this->places;
140 | }
141 |
142 | /**
143 | * Hier lässt sich noch Urlaub einklinken
144 | */
145 |
146 | private function set_available($date,$time) {
147 | $bookings = self::$radio_values[$date][$time]['bookings'];
148 | $places = self::$radio_values[$date][$time]['places'];
149 | $new_places = [];
150 | foreach ($places as $place_name=>$val) {
151 | $new_places[$place_name] = ['status'=>1,'name'=>$val];
152 | foreach ($bookings as $booking) {
153 | if ($booking->place == $place_name) {
154 | $new_places[$place_name]['status'] = 0;
155 | }
156 | }
157 |
158 | }
159 | self::$radio_values[$date][$time]['places'] = $new_places;
160 | $available = [];
161 | foreach ($new_places as $place_name=>$val) {
162 | if ($val['status'] == 1) {
163 | $available[] = $place_name;
164 | }
165 | }
166 | self::$radio_values[$date][$time]['available'] = '"'.implode('","',$available).'"';
167 | }
168 |
169 |
170 | public function set_date_bookings() {
171 | $query = rex_yform_manager_table::get(rex::getTable('buka_date_bookings'))->query();
172 | $query->whereRaw('status = :status AND object_id = :object_id',['status'=>'confirmed','object_id'=>$this->objectId]);
173 | $this->bookings = $query->find();
174 | }
175 |
176 |
177 |
178 |
179 |
180 | }
--------------------------------------------------------------------------------
/lib/module_helpers.php:
--------------------------------------------------------------------------------
1 | ' . $linkText . '';
102 | return $link;
103 | }
104 | }
105 |
106 | public static function downloadYoutubeThumbnailImage($youTubeLink = '', $thumbNamilQuality = '', $fileNameWithExt = '', $fileDownLoadPath = '')
107 | {
108 | $videoIdExploded = explode('?v=', $youTubeLink);
109 | if (sizeof($videoIdExploded) == 1) {
110 | $videoIdExploded = explode('&v=', $youTubeLink);
111 | $videoIdEnd = end($videoIdExploded);
112 | $removeOtherInVideoIdExploded = explode('&', $videoIdEnd);
113 | $youTubeVideoId = current($removeOtherInVideoIdExploded);
114 | } else {
115 | $videoIdExploded = explode('?v=', $youTubeLink);
116 | $videoIdEnd = end($videoIdExploded);
117 | $removeOtherInVideoIdExploded = explode('&', $videoIdEnd);
118 | $youTubeVideoId = current($removeOtherInVideoIdExploded);
119 | }
120 | switch ($thumbNamilQuality) {
121 | case 'LOW':
122 | $imageUrl = 'http://img.youtube.com/vi/' . $youTubeVideoId . '/sddefault.jpg';
123 | break;
124 | case 'MEDIUM':
125 | $imageUrl = 'http://img.youtube.com/vi/' . $youTubeVideoId . '/mqdefault.jpg';
126 | break;
127 | case 'HIGH':
128 | $imageUrl = 'http://img.youtube.com/vi/' . $youTubeVideoId . '/hqdefault.jpg';
129 | break;
130 | case 'MAXIMUM':
131 | $imageUrl = 'http://img.youtube.com/vi/' . $youTubeVideoId . '/maxresdefault.jpg';
132 | break;
133 | default:
134 | return 'Choose The Quality Between [ LOW (or) MEDIUM (or) HIGH (or) MAXIMUM]';
135 | break;
136 | }
137 | if (empty($fileNameWithExt) || is_null($fileNameWithExt) || $fileNameWithExt === '') {
138 | $toArray = explode('/', $imageUrl);
139 | $fileNameWithExt = md5(time() . mt_rand(1, 10)) . '.' . substr(strrchr(end($toArray), '.'), 1);
140 | }
141 | if (!is_dir($fileDownLoadPath)) {
142 | mkdir($fileDownLoadPath, 0777, true);
143 | }
144 | file_put_contents($fileDownLoadPath . $fileNameWithExt, file_get_contents($imageUrl));
145 | return $fileNameWithExt;
146 | }
147 | // Sprachumschaltung
148 | public static function getUrlOfOtherLanguage()
149 | {
150 | $other_language = rex_clang::getCurrentId() == 1 ? 2 : 1;
151 | if (rex_article::get(rex_article::getCurrentId(), $other_language)->isOnline()) {
152 | $other_id = rex_article::getCurrentId();
153 | } else {
154 | $other_id = rex_article::getSiteStartArticle()->getId();
155 | }
156 | return rex_yrewrite::getFullUrlByArticleId($other_id, $other_language);
157 | }
158 |
159 | public static function getArticlesOfList($list)
160 | {
161 | $return = [];
162 | $list = explode(",", $list);
163 | foreach ($list as $art) {
164 | $article = rex_article::get($art);
165 | if ($article && $article->isOnline()) {
166 | $return[] = $article;
167 | }
168 | }
169 | return $return;
170 | }
171 |
172 |
173 | public static function get_icon ($article) {
174 | while (!$article->getValue('art_icon')) {
175 | $article = $article->getParent();
176 | if (!$article) {
177 | break;
178 | }
179 | }
180 | if ($article) {
181 | return $article->getValue('art_icon');
182 | }
183 | return false;
184 | }
185 |
186 | }
187 |
--------------------------------------------------------------------------------
/pages/settings.php:
--------------------------------------------------------------------------------
1 | addFieldset('Buchungskalender - Einstellungen');
4 | foreach (rex_clang::getAll() as $clang) {
5 | $field = $form->addTextField('weekdays_'.$clang->getId());
6 | if (!$field->getValue()) {
7 | $field->setValue('Mo,Di,Mi,Do,Fr,Sa,So');
8 | }
9 | $field->setLabel('Wochentage '.$clang->getName());
10 | $field->setNotice('Wochentage durch Komma getrennt eingeben');
11 | }
12 |
13 | foreach (rex_clang::getAll() as $clang) {
14 | $field = $form->addTextField('months_'.$clang->getId());
15 | if (!$field->getValue()) {
16 | $field->setValue('Januar,Februar,März,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember');
17 | }
18 | $field->setLabel('Monate '.$clang->getName());
19 | $field->setNotice('Monate durch Komma getrennt eingeben');
20 | }
21 |
22 |
23 | $field = $form->addTextField('max_booking_time');
24 | if (!$field->getValue()) {
25 | $field->setValue('365 * 24 * 60 * 60');
26 | }
27 | $field->setLabel('Maximale Buchungszeit');
28 | $field->setNotice('Zeitraum, wie lange im voraus Buchungen vorgenommen werden können in Sekunden. Auch Formel möglich. z.B.
365 * 1.25 * 24 * 60 * 60 ergibt ein Jahr und drei Monate.');
29 |
30 | $field = $form->addTextField('min_booking_days_futur');
31 | if (!$field->getValue()) {
32 | $field->setValue('3');
33 | }
34 | $field->setLabel('Mindestens Tage vor Anreise');
35 | $field->setNotice('Anzahl Tage, die die Buchung mindestens vor der Anreise liegen muss.');
36 |
37 | $field = $form->addTextField('min_booking_days');
38 | if (!$field->getValue()) {
39 | $field->setValue('3');
40 | }
41 | $field->setLabel('Mindestbuchungszeit');
42 | $field->setNotice('Anzahl Nächte, die mindestens gebucht werden müssen.');
43 |
44 | $field = $form->addTextAreaField('message_min_booking_days');
45 | if (!$field->getValue()) {
46 | $field->setValue('Die Mindestbuchungsdauer beträgt drei Nächte.');
47 | }
48 | $field->setLabel('Meldung Mindestbuchungszeit');
49 | $field->setNotice('Die Nachricht wird angezeigt, wenn die Mindestbuchungszeit nicht erreicht ist.');
50 |
51 | $field = $form->addTextField('ical_interval');
52 | $field->setLabel('Ical Cachedauer in Sekunden');
53 | $field->setNotice('Leer lassen, wenn keine ical Synchronisation verwendet wird. Sinnvoller Eintrag:
900 für 15 Minuten.');
54 |
55 | $field = $form->addTextField('ical_uid');
56 | $field->setLabel('Ical Uid');
57 | $field->setNotice('Leer lassen, wenn keine ical Synchronisation verwendet wird. Sinnvoller Eintrag:
ical@ferien-am-tressower-see.de.');
58 |
59 | $field = $form->addCheckboxField('ignore_airbnb_blocked');
60 | $field->setLabel('Geblockte Airbnb Termine ignorieren');
61 | $field->addOption('Geblockte Airbnb Termine ignorieren', "1");
62 | $field->setNotice('Wenn ical Synchronisation mit airbnb verwendet wird, werden standardmäßig in airbnb geblockte Termine auch synchronisiert. Dies kann durch anklicken dieser Checkbox verhindert werden. Es können dann in airbnb Termine blockiert werden, ohne dass diese dann automatisch im Buchungskalender blockiert werden.
rex_config::get(\'buchungskalender\',\'ignore_airbnb_blocked\').');
63 |
64 | $field = $form->addLinkmapField('booking_page');
65 | $field->setLabel('Buchungsseite');
66 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'booking_page\').');
67 |
68 | $field = $form->addLinkmapField('summary_page');
69 | $field->setLabel('Buchung Zusammenfassung');
70 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'summary_page\').');
71 |
72 | $field = $form->addLinkmapField('confirmation_page');
73 | $field->setLabel('E-Mail-Link Bestätigungsseite');
74 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'confirmation_page\').');
75 |
76 | $field = $form->addTextField('email_me');
77 | $field->setLabel('E-Mail Adressen des Betreibers');
78 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'email_me\'). Mehrere Adressen durch Komma trennen. An diese E-Mail Adressen werden die Reservierungsmails geschickt.');
79 |
80 | $field = $form->addTextField('asked_offset');
81 | $field->setLabel('Reservierungsdauer');
82 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'asked_offset\'). Wenn das Feld ausgefüllt wird, werden reservierte Termine im Kalender als belegt gekennzeichnet.
83 | Leer lassen für keine Reservierungsdauer. Mögliche Werte (Beispiele):
10 minutes,
2 hours,
7 days.');
84 |
85 | $field = $form->addSelectField('calendar_view');
86 | $field->setLabel('Kalender Darstellung');
87 | $select = $field->getSelect();
88 | $select->addOptions([
89 | 'month'=>'Monatskalender',
90 | 'gant'=>'Gant Ansicht'
91 | ]);
92 | $field->setNotice('
rex_config::get("buchungskalender","calendar_view")');
93 |
94 | $field = $form->addTextField('minicalendar_count_month');
95 | $field->setLabel('Anzahl Monate im Minikalender');
96 | $field->setNotice('Hier kann eine abweichende Anzahl von Monaten eingestellt werden, die im Minikalender dargestellt werden sollen:
rex_config::get(\'buchungskalender\',\'minicalendar_count_month\').');
97 |
98 |
99 | $form->addFieldset('Währungseinstellungen');
100 |
101 | $field = $form->addTextField('currency_default');
102 | $field->setLabel('Standardwährung');
103 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'currency_default\'). Beispiel:
EUR.');
104 |
105 | $field = $form->addTextField('currency_formula');
106 | $field->setLabel('Währungsformel');
107 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'currency_formula\'). Beispiel:
{"10":0,"100":1,"1000":2}. Bis zu einem Wert von 10 wird auf ganze Stellen gerundet (9.6 => 10, 3.3 => 3) Bis zu einem Wert von 100 wird auf 10er gerundet (123 => 120, 178 => 180), ab 1000 wird auf 100er gerundet. Als Rundungswert sind auch negative Angaben möglich. -2 rundet z.B. auf die zweite Nachkommastelle. Wichtig: die Angaben müssen vom kleinsten Rundungsbetrag zum größten gesetzt werden. Die Rundung bezieht sich immer auf den Einzelpreis. Summen werden nicht gerundet.');
108 |
109 | $field = $form->addTextField('currency_factor');
110 | $field->setLabel('Umrechnungskurs');
111 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'currency_factor\'). Beispiel:
9.9.');
112 |
113 | $field = $form->addTextField('currency_name');
114 | $field->setLabel('Währung');
115 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'currency_name\'). Beispiel:
CHF.');
116 |
117 | $field = $form->addSelectField('currency_langs');
118 | $field->setLabel('Sprachen');
119 | $field->setAttribute('class','form-control selectpicker');
120 | // $field->setStyle('class="form-control selectpicker"');
121 |
122 |
123 |
124 | $select = $field->getSelect();
125 | $select->setAttribute('multiple',1);
126 | $select->addSqlOptions('SELECT name, id FROM rex_clang ORDER BY priority');
127 | $field->setNotice('
rex_config::get("buchungskalender","currency_langs")');
128 |
129 |
130 |
131 |
132 | /*
133 | $form->addFieldset('Terminbuchung - Einstellungen');
134 |
135 | $field = $form->addLinkmapField('summary_datebooking_page');
136 | $field->setLabel('Buchung Zusammenfassung');
137 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'summary_datebooking_page\').');
138 |
139 | $field = $form->addLinkmapField('confirmation_datebooking_page');
140 | $field->setLabel('E-Mail-Link Bestätigungsseite');
141 | $field->setNotice('
rex_config::get(\'buchungskalender\',\'confirmation_datebooking_page\').');
142 | */
143 |
144 |
145 |
146 |
147 |
148 | $content = $form->get();
149 |
150 | $fragment = new rex_fragment();
151 | $fragment->setVar('title', 'Einstellungen');
152 | $fragment->setVar('body', $content, false);
153 | $content = $fragment->parse('core/page/section.php');
154 |
155 | echo $content;
156 |
--------------------------------------------------------------------------------
/install/modules/Buchungskalender - Kalender/output.php:
--------------------------------------------------------------------------------
1 | maxBookingYear = date('Y', buka_booking::get_end_time());
28 | $cal->maxBookingMonth = date('m', buka_booking::get_end_time());
29 | $cal->objectId = $var1['object_id'];
30 | $cal->cal_wrapper_class = 'buka-cal-wrapper';
31 | $cal->monthcount = 4;
32 | $cal->mobile_month_count = [2=>'uk-visible@m',3=>'uk-visible@l',4=>'uk-visible@xl'];
33 |
34 | $cal->set_start_date();
35 | $cal->set_bookings();
36 |
37 | $object = buka_objects::get_object_for_id($var1['object_id']);
38 |
39 |
40 | $row_start_12 = '
';
41 | $row_start_6 = '
';
42 | $row_start_3 = '
';
43 | $next_col_3 = '
';
44 | $next_col_6 = '
';
45 | $next_col_9 = '
';
46 | $row_end = '
';
47 | $div_end = '
';
48 |
49 | $hidden_start = '
';
50 |
51 | $yform = new rex_yform();
52 | $yform->setObjectparams('form_ytemplate','uikit,bootstrap,classic');
53 | $yform->setObjectparams('form_action', rex_getUrl());
54 | $yform->setObjectparams('error_class', 'uk-form-danger has-error');
55 | $yform->setObjectparams('form_class', 'uk-form rex-yform');
56 |
57 | // $yform->setObjectparams('form_showformafterupdate',1);
58 | // $yform->setObjectparams('debug',true);
59 |
60 | $yform->setValueField('hidden', ['bookingdate', date('Y-m-d H:i:s')]);
61 | $yform->setValueField('hidden', ['status', 'asked']);
62 | $yform->setValueField('hidden', ['object_id', $cal->objectId]);
63 | $yform->setValueField('hidden', ['last_art_id', rex_article::getCurrentId()]);
64 |
65 | $yform->setValueField('html', ['', $hidden_start]);
66 | $yform->setValueField('text', ['datestart', '', $booking['datestart'] ?? '', '', ['type' => 'hidden', 'id' => 'datestart']]);
67 | $yform->setValueField('text', ['dateend', '', $booking['dateend'] ?? '', '', ['type' => 'hidden', 'id' => 'dateend']]);
68 |
69 | // $yform->setValueField('html', ['','
']);
70 | // $yform->setValueField('html', ['','
']);
71 |
72 | // $yform->setValueField('hidden', ['datestart', '', 'REQUEST', '', ['id' => 'datestart']]);
73 | // $yform->setValueField('hidden', ['dateend', '','REQUEST', '',['id' => 'dateend']]);
74 | $yform->setValueField('html', ['', $div_end]);
75 |
76 | $yform->setValueField('html', ['', $row_start_3]);
77 | $yform->setValueField('text', ['date_start', 'Anreise', $booking['date_start'] ?? '', 'no_db', ['id' => 'date_start', 'readonly' => 'readonly']]);
78 | $yform->setValueField('html', ['', $next_col_3]);
79 | $yform->setValueField('text', ['date_end', 'Abreise', $booking['date_end'] ?? '', 'no_db', ['id' => 'date_end', 'readonly' => 'readonly']]);
80 | $yform->setValueField('html', ['', $row_end]);
81 |
82 | $yform->setValueField('html', ['', '
']);
83 |
84 | $yform->setValueField('html', ['', $row_start_6]);
85 | $yform->setValueField('text', ['vorname', 'Vorname*', $booking['vorname'] ?? '']);
86 | $yform->setValueField('html', ['', $next_col_6]);
87 | $yform->setValueField('text', ['nachname', 'Nachname*', $booking['nachname'] ?? '']);
88 | $yform->setValueField('html', ['', $row_end]);
89 |
90 | $yform->setValueField('html', ['', $row_start_12]);
91 | $yform->setValueField('text', ['anschrift', 'Anschrift', $booking['anschrift'] ?? '']);
92 | $yform->setValueField('html', ['', $row_end]);
93 | $yform->setValueField('html', ['', $row_start_3]);
94 | $yform->setValueField('text', ['plz', 'PLZ', $booking['plz'] ?? '']);
95 | $yform->setValueField('html', ['', $next_col_9]);
96 | $yform->setValueField('text', ['ort', 'Ort', $booking['ort'] ?? '']);
97 | $yform->setValueField('html', ['', $row_end]);
98 |
99 | $yform->setValueField('html', ['', $row_start_12]);
100 | $yform->setValueField('text', ['land', 'Land', $booking['land'] ?? '']);
101 | $yform->setValueField('html', ['', $row_end]);
102 |
103 | $yform->setValueField('html', ['', $row_start_6]);
104 | $yform->setValueField('text', ['telefon', 'Telefon', $booking['telefon'] ?? '']);
105 | $yform->setValueField('html', ['', $next_col_6]);
106 | $yform->setValueField('text', ['email', 'E-Mail', $booking['email'] ?? '']);
107 | $yform->setValueField('html', ['', $row_end]);
108 |
109 | $yform->setValueField('html', ['', $row_start_6]);
110 | $yform->setValueField('text', ['personen', 'Anzahl Personen', $booking['personen'] ?? '']);
111 | $yform->setValueField('html', ['', $next_col_6]);
112 | $yform->setValueField('text', ['anreisezeit', 'Anreisezeit', $booking['anreisezeit'] ?? '']);
113 | $yform->setValueField('html', ['', $row_end]);
114 |
115 | $yform->setValueField('textarea', ['nachricht', 'Nachricht', $booking['nachricht'] ?? '']);
116 |
117 | $yform->setValueField('html', ['', 'Zurück ... ']);
118 | $yform->setValueField('submit', ['Submit', 'weiter ...', 'no_db','','','uk-active']);
119 |
120 | $yform->setValueField('html', ['', '
']);
121 |
122 | $yform->setValueField('html', ['', '
']);
123 | $yform->setValueField('html', ['', '
']);
124 | $yform->setValueField('html', ['', $cal->getCalendar()]);
125 | if (rex_request('FORM','array') || $booking) {
126 | $yform->setValueField('html', ['', 'Weiter ... ']);
127 | } else {
128 | $yform->setValueField('html', ['', 'Weiter ... ']);
129 | }
130 | $yform->setValueField('html', ['', '
']);
131 | $yform->setValueField('html', ['', '
']);
132 |
133 | // $yform->setValidateField('customfunction',['datestart','buka_booking::save_form1_in_session',['datestart','dateend']]);
134 | $yform->setValidateField('type',['email','email','Bitte geben Sie eine gültige E-Mail Adresse an.']);
135 | $yform->setValidateField('empty',['vorname','Bitte füllen Sie die markierten Felder aus.']);
136 | $yform->setValidateField('empty',['nachname','Bitte füllen Sie die markierten Felder aus.']);
137 | $yform->setValidateField('type',['datestart','date','Bitte geben Sie ein gültiges Datum an.']);
138 | $yform->setValidateField('type',['dateend','date','Bitte geben Sie ein gültiges Datum an.']);
139 |
140 |
141 | // $yform->setActionField('db', ['rex_buka_bookings']);
142 | $yform->setActionField('callback', ['buka_booking::save_in_session']);
143 | $yform->setActionField('redirect', [rex_getUrl(rex_config::get('buchungskalender','summary_page'))]);
144 |
145 | ?>
146 |
147 |
148 |
149 |
150 |
= rex_config::get('buchungskalender', 'message_min_booking_days'); ?>
151 |
152 |
= $object->name .' ' . ($object->reservation == 'book' ? 'buchen' : 'anfragen') ?>
153 | = $yform->getForm() ?>
154 |
155 |
--------------------------------------------------------------------------------
/lib/buka_barcal.php:
--------------------------------------------------------------------------------
1 | set_start_date($start_date);
19 | }
20 | $this->set_weekdays();
21 | return $this;
22 | }
23 |
24 | public function set_num_of_months ($num) {
25 | $this->num_of_months = $num;
26 | }
27 |
28 | public function set_start_date ($start_date = false) {
29 | if (!$start_date) {
30 | $start_date = date('Y-m-d');
31 | }
32 | $this->months = [];
33 | self::$start_date = $start_date;
34 | $this->init_start_end_date();
35 | $this->init_calendar();
36 | return $this;
37 | }
38 |
39 | public function get_calendar () {
40 | return $this;
41 | }
42 |
43 | public function get_months () {
44 | if (!$this->months) {
45 | $this->set_start_date();
46 | }
47 | // dump($this->months);
48 | return $this->months;
49 | }
50 |
51 | public function init_calendar () {
52 | $n = 0;
53 | $this->current_year = $this->start_year;
54 | $this->current_month = $this->start_month;
55 |
56 | $with_reservation = '';
57 | // nur im Backend Reservierte Datensätze im Kalender anzeigen.
58 | if (rex::isBackend()) {
59 | $with_reservation = ' OR status = "asked"';
60 | }
61 |
62 |
63 | $objects = buka_objects::get_query()->find();
64 | foreach ($objects as $object) {
65 | $qry = buka_booking::get_query($object->id,true);
66 | $qry->orderBy('datestart');
67 | if (rex_config::get('buchungskalender','asked_offset')) {
68 | $qry->whereRaw('((
69 | (status = "confirmed"'.$with_reservation.') AND ((dateend >= :start AND datestart <= :end)
70 | OR (dateend <= :start AND datestart >= :end)
71 | OR (datestart >= :start AND datestart <= :end))
72 |
73 | ) OR (status = "asked" AND bookingdate > :bookingdate))',['start'=>self::$start_date,'end'=>self::$end_date,'bookingdate'=>date('Y-m-d H:i:s',strtotime('-'.rex_config::get('buchungskalender','asked_offset')))])
74 | ;
75 | } else {
76 | $qry->whereRaw('((
77 | (status = "confirmed"'.$with_reservation.') AND ((dateend >= :start AND datestart <= :end)
78 | OR (dateend <= :start AND datestart >= :end)
79 | OR (datestart >= :start AND datestart <= :end))
80 |
81 | ))',['start'=>self::$start_date,'end'=>self::$end_date])
82 | ;
83 |
84 | }
85 | $result = $qry->find();
86 | $result->populateRelation('bookingtype_id');
87 | foreach ($result as $res) {
88 | $bt_name = $res->getRelatedDataset('bookingtype_id');
89 | $res->bookingtype_name = '';
90 | if ($bt_name) {
91 | $res->bookingtype_name = $bt_name->name;
92 | }
93 | }
94 | if ($object->combination) {
95 | // Kombinationsobjekte kompaktieren
96 | $result = self::combine_result($result);
97 | }
98 | $object->bookings = $result;
99 |
100 | }
101 |
102 | self::$objects = $objects;
103 | // dump(self::$objects[6]);
104 |
105 | while ($n < $this->num_of_months) {
106 | $this->months[] = $this->get_month($this->current_month,$this->current_year);
107 | $this->current_month ++;
108 |
109 | if ($this->current_month > 12) {
110 | $this->current_month = 1;
111 | $this->current_year ++;
112 | }
113 |
114 | $n++;
115 | }
116 |
117 | }
118 |
119 | private function set_weekdays () {
120 |
121 | self::$weekdays = [
122 | rex_formatter::intlDate(strtotime('2021-12-13'),'ccc'),
123 | rex_formatter::intlDate(strtotime('2021-12-14'),'ccc'),
124 | rex_formatter::intlDate(strtotime('2021-12-15'),'ccc'),
125 | rex_formatter::intlDate(strtotime('2021-12-16'),'ccc'),
126 | rex_formatter::intlDate(strtotime('2021-12-17'),'ccc'),
127 | rex_formatter::intlDate(strtotime('2021-12-18'),'ccc'),
128 | rex_formatter::intlDate(strtotime('2021-12-19'),'ccc'),
129 | ];
130 | }
131 |
132 | private function get_month ($month,$year) {
133 | $dt = new DateTime();
134 | $out = [];
135 | $dt->setDate($year, $month, 1);
136 | $day = 1;
137 | while ($day <= $dt->format('t')) {
138 | $buka_date = new buka_date($year,$month,$day);
139 | $buka_date->booking = $this->get_bookings_for_date($buka_date);
140 | $out[] = $buka_date;
141 | $day++;
142 | }
143 | return $out;
144 | }
145 |
146 | private function get_bookings_for_date($buka_date) {
147 | $date = $buka_date->date->format('Y-m-d');
148 | $bookings = [];
149 | foreach (self::$objects as $object) {
150 | foreach ($object->bookings as $booking) {
151 | if (!$booking) {
152 | continue;
153 | }
154 | if (($date >= $booking->datestart) && ($date <= $booking->dateend)) {
155 | $booking->is_start = $date == $booking->datestart;
156 | $booking->is_end = $date == $booking->dateend;
157 |
158 | // Label Max. Länge errechnen
159 | // Ende der Woche
160 | // verbleibende Tage der Buchung
161 | $endDate = date_create_from_format('Y-m-d', $booking->dateend);
162 | $leftDays = (array) date_diff($endDate, $buka_date->date);
163 | $booking->leftdays = $leftDays['days'] ?? 0; // Tage bis zur Abreise
164 |
165 | if (rex_config::get("buchungskalender", "calendar_view") == 'gant') {
166 | $booking->lbl_max_len = $booking->leftdays;
167 | } else {
168 | $booking->lbl_max_len = min([
169 | $booking->leftdays, // bis zur Abreise
170 | 8 - (int) $buka_date->date->wd, // Ende der Woche
171 | (int) $buka_date->date->format('t') - (int) $buka_date->date->format('d') + 1 // Ende des Monats
172 | ]);
173 | }
174 |
175 | if (!isset($bookings[$object->id])) {
176 | $bookings[$object->id] = [];
177 | }
178 | $bookings[$object->id][] = clone $booking;
179 | }
180 | }
181 | }
182 | return $bookings;
183 | }
184 |
185 | private function init_start_end_date () {
186 | $this->start_year = date('Y',strtotime(self::$start_date));
187 | $this->start_month = date('m',strtotime(self::$start_date));
188 |
189 |
190 | $dt2 = new DateTime();
191 | $dt2->setDate($this->start_year, $this->start_month, 1);
192 | $dt2->modify('+ '.($this->num_of_months - 1).' months');
193 |
194 | self::$end_date = $dt2->format('Y-m-t');
195 |
196 | }
197 |
198 |
199 | // kompaktiert die Ergebnisse für Kombinationsobjekte
200 |
201 | private static function combine_result ($result) {
202 | if (!isset($result[0])) {
203 | return $result;
204 | }
205 | $current = $result[0];
206 | $current_i = 0;
207 | foreach ($result as $i=>$booking) {
208 | if ($i <= $current_i) {
209 | continue;
210 | }
211 | if ($booking->datestart < $current->dateend) {
212 | if ($booking->dateend > $result[$current_i]->dateend) {
213 | $result[$current_i]->dateend = $booking->dateend;
214 | }
215 | unset($result[$i]);
216 | } else {
217 | $current = $booking;
218 | $current_i = $i;
219 | }
220 | }
221 | return $result;
222 | }
223 | }
--------------------------------------------------------------------------------
/ytemplates/uikit/value.ycom_password.tpl.php:
--------------------------------------------------------------------------------
1 | getValue();
7 | }
8 |
9 | $notice = [];
10 | if ($this->getElement('notice') != '') {
11 | $notice[] = rex_i18n::translate($this->getElement('notice'), false);
12 | }
13 | if (isset($this->params['warning_messages'][$this->getId()]) && !$this->params['hide_field_warning_messages']) {
14 | $notice[] = '
' . rex_i18n::translate($this->params['warning_messages'][$this->getId()]) . ' '; // var_dump();
15 | }
16 | if (count($notice) > 0) {
17 | $notice = '
' . implode(' ', $notice) . '
';
18 | } else {
19 | $notice = '';
20 | }
21 |
22 | $class_group = trim('form-group yform-element ' . $this->getWarningClass());
23 |
24 | $class_label[] = 'uk-form-label';
25 |
26 | $attributes = [
27 | 'class' => 'form-control uk-input',
28 | 'name' => $this->getFieldName(),
29 | 'type' => $type,
30 | 'id' => $this->getFieldId(),
31 | 'value' => $value,
32 | 'autocomplete' => 'new-password',
33 | ];
34 |
35 | $attributes = $this->getAttributeElements($attributes, ['placeholder', 'autocomplete', 'pattern', 'required', 'disabled', 'readonly']);
36 |
37 | $span = '';
38 | $input_group_start = '';
39 | $input_group_end = '';
40 |
41 | if ($script) {
42 | $funcName = uniqid('rex_ycom_password_create'.$this->getId());
43 | $span = '
44 |
45 |
46 | '; ?>';
214 | $input_group_end = '
';
215 | }
216 |
217 | echo '
218 |
219 | '.$this->getLabel().'
220 | ' . $input_group_start . '
221 | ' .
222 | $notice .
223 | $span . '
224 | ' . $input_group_end . '
225 |
226 |
';
227 |
228 | ?>
--------------------------------------------------------------------------------
/assets/js/buchungskalender.js:
--------------------------------------------------------------------------------
1 | $(function () {
2 |
3 | let StartDate;
4 |
5 | // Im yform Buchungsformular Teilnehmer auf- und zuklappen
6 | $(document).on('click','.aufklappen',function(e) {
7 | e.preventDefault();
8 | $(this).closest('.yform').find('.zugeklappt').toggle();
9 | });
10 |
11 | $(document).on("click", '.buka-cal-wrapper .bk-day.fix-booked', function(e) {
12 | var DateClicked = $(this);
13 | if (e.shiftKey) {
14 | if (DateClicked.data('bookingid')) {
15 | editBooking(DateClicked.data('bookingid'));
16 | }
17 | return;
18 | }
19 | });
20 |
21 | // Streifenkalender
22 | $(document).on('click','.buka_bar_cal .obj_booking', function(e) {
23 | var DateClicked = $(this);
24 | if (DateClicked.data('bookingid')) {
25 | window.location.href = 'index.php?page=buchungskalender/bookings&func=edit&data_id='+DateClicked.data('bookingid');
26 | }
27 | });
28 |
29 | // Gantkalender
30 | $(document).on('click','.buka_gant_cal .obj_booking', function(e) {
31 | var DateClicked = $(this);
32 | if (DateClicked.data('bookingid')) {
33 | window.location.href = 'index.php?page=buchungskalender/bookings&func=edit&data_id='+DateClicked.data('bookingid');
34 | }
35 | });
36 |
37 | // Backend
38 | function editBooking (bookingid) {
39 | window.location.href = 'index.php?src=calendar&page=buchungskalender/bookings&func=edit&data_id='+bookingid;
40 | }
41 |
42 | $(document).on("click", ".buka-cal-wrapper .bookable", function () {
43 | if ($(".buka-cal-wrapper").hasClass("booking-complete")) {
44 | clear_booking();
45 | }
46 | if ($(this).data("date") < $("input#datestart").val()) {
47 | clear_booking();
48 | }
49 |
50 | if ($(".bk-day.reserve-start").length) {
51 | find_end($(this));
52 | } else {
53 | find_start($(this));
54 | }
55 | });
56 |
57 | // Kalender blättern
58 | $(document).on('click','#bookingform-step1 .buka_pager_nav a',function(e) {
59 | e.preventDefault();
60 | let href = $(this).attr('href')+"&bukacal=1";
61 | $("#bookingform-step1").parent().load(href);
62 | return false;
63 | });
64 |
65 | $(document).on("click", "#to-step-2", function () {
66 | $("#bookingform-step1").slideUp();
67 | $("#bookingform-step2").slideDown();
68 | });
69 | $(document).on("click", "#to-step-1", function () {
70 | $("#bookingform-step2").slideUp();
71 | $("#bookingform-step1").slideDown();
72 | });
73 |
74 | if ($('.uk-form-danger').length) {
75 | $("#bookingform-step1").hide();
76 | $("#bookingform-step2").show();
77 | }
78 |
79 | function clear_booking() {
80 | $(".buka-cal-wrapper").removeClass("booking-complete");
81 | $(".bk-cal-day").removeClass("reserve-start");
82 | $(".bk-cal-day").removeClass("reserve-end");
83 | $(".bk-cal-day").removeClass("add-reserve");
84 | $("input#date_start").val("");
85 | $("input#date_end").val("");
86 | $("input#datestart").val("");
87 | $("input#dateend").val("");
88 | $("#to-step-2").prop("disabled", true);
89 | }
90 |
91 | function mark_end($elem) {
92 | let min_booking_days = $elem.data('minbookingdays');
93 | $(".buka-cal-wrapper").removeClass("booking-start");
94 | $(".buka-cal-wrapper").addClass("booking-complete");
95 | $elem.addClass("reserve-end");
96 | $("input#date_end").val(
97 | $elem.data("date").split("-").reverse().join(".")
98 | );
99 | $("input#dateend").val($elem.data("date"));
100 | $(".mind_booking_message").hide();
101 | $("#to-step-2").prop("disabled", false).addClass('uk-active');
102 | if ($(".add-reserve").length <= min_booking_days) {
103 | $(".mind_booking_message").show();
104 | $("#to-step-2").prop("disabled", true).removeClass('uk-active');
105 | }
106 | }
107 |
108 | function find_end ($elem) {
109 | let EndDate = new Date($elem.data("date"));
110 | if ($elem.data("fullweek") == 1 && EndDate.getDay() != 6 && !$elem.hasClass('fix-booked-start')) {
111 | while (EndDate.getDay() != 6) {
112 | EndDate.setDate(EndDate.getDate() + 1);
113 | if ($("ul").find("[data-date='"+date_to_string(EndDate)+"']").hasClass('fix-booked-start')) {
114 | break;
115 | }
116 | }
117 | let $endElem = $("ul").find("[data-date='"+date_to_string(EndDate)+"']");
118 | mark_range($endElem);
119 | mark_end($endElem);
120 | return;
121 | }
122 | mark_range($elem);
123 | mark_end($elem);
124 | }
125 |
126 |
127 | function find_start($elem) {
128 | let StartDate = new Date($elem.data("date"));
129 | if ($elem.data("fullweek") == 1 && StartDate.getDay() != 6 && !$elem.hasClass('fix-booked-end')) {
130 | while (StartDate.getDay() != 6) {
131 | StartDate.setDate(StartDate.getDate() - 1);
132 | if ($("ul").find("[data-date='"+date_to_string(StartDate)+"']").hasClass('fix-booked-end')) {
133 | break;
134 | }
135 | }
136 | mark_start($("ul").find("[data-date='"+date_to_string(StartDate)+"']"));
137 | $elem.trigger('mouseenter');
138 | return;
139 | }
140 |
141 | mark_start($elem);
142 | }
143 |
144 | function mark_start_old($elem) {
145 | $(".buka-cal-wrapper").addClass("booking-start");
146 | $elem.addClass("reserve-start");
147 | $("input#date_start").val(
148 | $elem.data("date").split("-").reverse().join(".")
149 | );
150 | $("input#datestart").val($elem.data("date"));
151 | }
152 |
153 |
154 | function mark_start($elem) {
155 | let addthis = 0;
156 | $(".buka-cal-wrapper").addClass("booking-start");
157 | $elem.addClass("reserve-start");
158 | $elem.addClass("bookable");
159 | $("input#date_start").val(
160 | $elem.data("date").split("-").reverse().join(".")
161 | );
162 | $("input#datestart").val($elem.data("date"));
163 | $(".bk-cal-day").removeClass("booking-range");
164 |
165 | $(".bk-cal-day").each(function () {
166 | if ($(this).hasClass("reserve-start")) {
167 | addthis = 1;
168 | }
169 | if (addthis && $(this).hasClass("bookable")) {
170 | $(this).addClass("booking-range");
171 | }
172 | if (!$(this).hasClass("bookable")) {
173 | addthis = 0;
174 | }
175 | });
176 |
177 | }
178 |
179 |
180 | function date_to_string(jsDate) {
181 | return (
182 | jsDate.getFullYear() +
183 | "-" +
184 | pad(jsDate.getMonth() + 1, 2) +
185 | "-" +
186 | pad(jsDate.getDate(), 2)
187 | );
188 | }
189 |
190 | function pad(str, max) {
191 | str = str.toString();
192 | return str.length < max ? pad("0" + str, max) : str;
193 | }
194 |
195 | $('.minikalender-wrapper').on('click','a',function(e) {
196 | e.preventDefault();
197 | let href = $(this).attr('href')+"&minicalendar=1";
198 | $($(this).parents('.minikalender-wrapper')).load(href);
199 | return false;
200 | });
201 |
202 | $(document).on(
203 | "mouseenter",
204 | ".buka-cal-wrapper.booking-start .bk-cal-day",
205 | function () {
206 | mark_range($(this));
207 | }
208 | );
209 |
210 | function mark_range ($elem) {
211 | var addthis = 0;
212 | var $current = $elem;
213 | $(".bk-cal-day").removeClass("add-reserve");
214 | if ($current.data("date") >= $(".reserve-start").data("date")) {
215 | $(".bk-cal-day").each(function () {
216 | if ($(this).hasClass("reserve-start")) {
217 | addthis = 1;
218 | }
219 | if ($(this).data("date") > $current.data("date")) {
220 | addthis = 0;
221 | }
222 | if (addthis && $(this).hasClass("bookable")) {
223 | $(this).addClass("add-reserve");
224 | }
225 | if (!$(this).hasClass("bookable")) {
226 | addthis = 0;
227 | }
228 | });
229 | }
230 |
231 | }
232 |
233 | $('#yform-data_edit-rex_buka_bookings-datestart input').on('change',function() {
234 | let fromdatum = $(this).val();
235 | let bisdatum = $('#yform-data_edit-rex_buka_bookings-dateend input').val();
236 | if (bisdatum < fromdatum) {
237 | $('#yform-data_edit-rex_buka_bookings-dateend input').val(fromdatum);
238 | }
239 | });
240 |
241 | $('#yform-data_edit-rex_buka_bookings-dateend input').on('change',function() {
242 | let bisdatum = $(this).val();
243 | let fromdatum = $('#yform-data_edit-rex_buka_bookings-datestart input').val();
244 | if (bisdatum < fromdatum) {
245 | $('#yform-data_edit-rex_buka_bookings-datestart input').val(bisdatum);
246 | }
247 | });
248 |
249 |
250 |
251 |
252 | });
253 |
254 | $(document).on('rex:ready',function() {
255 | $('.sortable_table table tbody').sortable();
256 | })
257 |
--------------------------------------------------------------------------------
/lib/awnav.php:
--------------------------------------------------------------------------------
1 |
Zurück ';
29 | var $ulWrapper = [];
30 | var $func_ul_end = '';
31 | var $func_li_end = '';
32 | var $hasNavPoints = false;
33 | var $withParent = false;
34 | var $MegaMenuFunc = '';
35 |
36 | public function __construct()
37 | {
38 | $this->currentCat = rex_category::getCurrent();
39 | if (is_object($this->currentCat)) {
40 | $this->currentCatId = $this->currentCat->getId();
41 | $this->currentPath = explode('|', trim($this->currentCat->getPath(), '|') . '|' . $this->currentCatId);
42 | if (!is_array($this->currentPath))
43 | $this->currentPath = [];
44 | $this->startCategory = $this->currentPath[0] ? $this->currentPath[0] : $this->currentPath[1];
45 | }
46 | }
47 |
48 | public function getNavigation()
49 | {
50 | $out = '';
51 | $cssclass = (isset($this->ulClasses[0])) ? ' ' . $this->ulClasses[0] : '';
52 | $dataAttribute = (isset($this->dataAttribute[0])) ? ' ' . $this->dataAttribute[0] : '';
53 | $categories = rex_category::getRootCategories($this->ignoreOffline);
54 | if (!empty($categories)) {
55 | if (!empty($categories)) {
56 | $out .= '
';
57 | foreach ($categories as $key => $category) {
58 | if ($this->metaField) {
59 | if ($this->filterNav($category))
60 | continue;
61 | }
62 | $out .= $this->_getCategory($category);
63 | }
64 | $out .= $this->additionalLi;
65 | $out .= ' ';
66 | return $out;
67 | }
68 | }
69 | }
70 |
71 | public function getCategoryNav($category_id)
72 | {
73 | $lev = 0;
74 | $out = '';
75 | if (!$category_id)
76 | return '';
77 | $cssclass = (isset($this->ulClasses[0])) ? ' ' . $this->ulClasses[0] : '';
78 | $dataAttribute = (isset($this->dataAttribute[0])) ? ' ' . $this->dataAttribute[0] : '';
79 | if ($this->withParent) {
80 | $cat = rex_category::get($category_id);
81 | if (!$cat) {
82 | return '';
83 | }
84 | $out .= '
';
85 | $out .= '' . $cat->getName() . ' ';
86 | $lev++;
87 | }
88 | $cssclass = (isset($this->ulClasses[$lev])) ? ' ' . $this->ulClasses[$lev] : '';
89 | $dataAttribute = (isset($this->dataAttribute[$lev])) ? ' ' . $this->dataAttribute[$lev] : '';
90 | $_categories = rex_category::get($category_id)->getChildren($this->ignoreOffline);
91 | if ($_categories) {
92 | $out .= '';
93 | foreach ($_categories as $_cat) {
94 | if ($this->metaField) {
95 | if ($this->filterNav($_cat))
96 | continue;
97 | }
98 |
99 | $out .= $this->_getCategory($_cat, $lev);
100 | }
101 | $out .= ' ';
102 | }
103 | if ($this->withParent) {
104 | $out .= ' ';
105 | }
106 | return $out;
107 | }
108 |
109 | private function filterNav($category)
110 | {
111 | $metaval = explode('|', trim($category->getValue($this->metaField), '|'));
112 | if (array_search($this->metaValue, $metaval) === false) {
113 | return true;
114 | }
115 | return false;
116 | }
117 |
118 | private function _getCategory($cat, $lev = 0)
119 | {
120 | $lev++;
121 |
122 | $out = '';
123 | $class = '';
124 | $cssclass = (isset($this->ulClasses[$lev])) ? ' ' . $this->ulClasses[$lev] : '';
125 | $dataAttribute = (isset($this->dataAttribute[$lev])) ? ' ' . $this->dataAttribute[$lev] : '';
126 | $_categories = $cat->getChildren($this->ignoreOffline);
127 | $li_end_text = '';
128 | if ($this->func_li_end) {
129 | $li_end_text = call_user_func($this->func_li_end, $cat);
130 | }
131 |
132 | if ($this->metaField) {
133 | if ($this->filterNav($cat)) {
134 | return '';
135 | }
136 | }
137 |
138 |
139 | if ($cat->getId() == $this->currentCatId) {
140 | $class = $this->currentClass;
141 | } elseif (is_array($this->currentPath) && in_array($cat->getId(), $this->currentPath)) {
142 | $class = $this->activeClass;
143 | }
144 |
145 | if (isset($this->liClassMeta[$lev - 1])) {
146 | $class .= ' scheme-' . $cat->getValue($this->liClassMeta[$lev - 1]);
147 | }
148 |
149 |
150 | if (isset($this->liClasses[$lev - 1])) {
151 | $class .= ' ' . $this->liClasses[$lev - 1];
152 | }
153 |
154 | if ((!empty($_categories) || $li_end_text) && isset($this->liHasChildsClasses[$lev - 1])) {
155 | $class .= ' ' . $this->liHasChildsClasses[$lev - 1];
156 | }
157 | $class = trim($class);
158 |
159 | $this->hasNavPoints = true;
160 | if (empty($_categories)) {
161 | $class = str_replace('uk-parent', '', $class);
162 | }
163 | $out .= '
164 |
165 | ' . $cat->getName() . ' ';
166 |
167 | // Megamenü einbauen
168 | if ($this->MegaMenuFunc) {
169 | $out .= call_user_func($this->MegaMenuFunc, $cat);
170 | }
171 |
172 |
173 | if (!empty($_categories) && ($this->fullTree || (is_array($this->currentPath) && in_array($cat->getId(), $this->currentPath)) && $lev < $this->maxLev)) {
174 | if (isset($this->ulWrapper[$lev]) && $this->ulWrapper[$lev]) {
175 | $out .= $this->ulWrapper[$lev][0];
176 | }
177 |
178 | if ($lev < $this->maxLev) {
179 | $out .= '';
180 |
181 | if ($this->showBackButton) {
182 | $out .= $this->backButtonText;
183 | }
184 |
185 |
186 | // Wiederholt den übergeordneten Menüpunkt in der Liste
187 | if ($this->showTopCategory) {
188 | $out .= '
189 |
190 | {{ Overview }} '
191 | . ' ';
192 | }
193 |
194 | foreach ($_categories as $_cat) {
195 | $out .= $this->_getCategory($_cat, $lev);
196 | }
197 | $out .= ' ';
198 | }
199 |
200 |
201 | if (isset($this->ulWrapper[$lev]) && $this->ulWrapper[$lev]) {
202 | $out .= $this->ulWrapper[$lev][1];
203 | }
204 | if ($this->func_ul_end) {
205 | $out .= call_user_func($this->func_ul_end, $cat);
206 | }
207 | }
208 | $out .= $li_end_text;
209 | $out .= ' ';
210 | return $out;
211 | }
212 |
213 | public function getBreadcrumb()
214 | {
215 | $out = '';
216 | if ($this->breadcrumbWithHome) {
217 | $out .= '
' . rex_article::get(rex_article::getSiteStartArticleId())->getName() . ' ';
218 | }
219 | if (rex_article::getCurrentId() == rex_article::getSiteStartArticleId()) {
220 | $out = '';
221 | }
222 |
223 | foreach ($this->currentPath as $i => $p) {
224 | $cat = rex_category::get($p);
225 | if (!is_object($cat)) {
226 | continue;
227 | }
228 | if ($p == rex_article::getSiteStartArticleId() && $this->breadcrumbNameHome) {
229 | $out .= '
Home ';
230 | continue;
231 | }
232 | if (count($this->currentPath) == ($i + 1) && !$this->breadcrumbLastLink) { //
Disabled Category
233 | $out .= '
';
234 | $out .= $cat->getName();
235 | $out .= ' ';
236 | } else {
237 | $out .= '
';
238 | $out .= '';
239 | $out .= $cat->getName();
240 | $out .= ' ';
241 | $out .= ' ';
242 | }
243 | }
244 | return '
';
245 | }
246 | }
247 |
--------------------------------------------------------------------------------
/assets/frontend/js/buchungskalender.js:
--------------------------------------------------------------------------------
1 | $(function () {
2 | var StartDate;
3 |
4 | $(document).on("click", '.buka-cal-wrapper .bk-day.fix-booked', function(e) {
5 | var DateClicked = $(this);
6 |
7 | if (e.shiftKey) {
8 | if (DateClicked.data('bookingid')) {
9 | // console.log('click clicked');
10 | editBooking(DateClicked.data('bookingid'));
11 | }
12 | return;
13 | }
14 | });
15 |
16 |
17 | $(document).on('change','.onchangesubmit input',function() {
18 | let this_var = $(this).val();
19 | $('input[name=reloadpage]').val(2);
20 | $(this).parents('form').trigger('submit');
21 | });
22 |
23 | $(document).on('click','#clearbutton',function() {
24 | clear_booking();
25 | })
26 |
27 |
28 |
29 | // Backend
30 | function editBooking (bookingid) {
31 | // window.location.href = 'index.php?page=yform/manager/data_edit&table_name=rex_buka_bookings&rex_yform_manager_popup=0&func=edit&data_id='+bookingid;
32 | window.location.href = 'index.php?src=calendar&page=buchungskalender/bookings&func=edit&id='+bookingid;
33 |
34 | // http://buchungskalender.localhost/redaxo/index.php?page=buchungskalender/bookings&func=edit&id=434&start=&list=89b0b572
35 |
36 | }
37 |
38 | $(document).on("click", ".buka-cal-wrapper .bookable", function () {
39 | let $clicked_elem = $(this);
40 | if ($(".buka-cal-wrapper").hasClass("booking-complete")) {
41 | clear_booking();
42 | }
43 | if ($clicked_elem.data("date") < $("input#datestart").val()) {
44 | clear_booking();
45 | }
46 |
47 | if ($(".bk-day.reserve-start").length) {
48 | find_end($(this));
49 | } else {
50 | find_start($(this));
51 | }
52 | });
53 |
54 | // Kalender blättern
55 | $(document).on('click','#bookingform-step1 .buka_pager_nav a',function(e) {
56 | e.preventDefault();
57 | let rooms = $('#buka_accomodation_select option:selected').val();
58 | let href = $(this).attr('href');
59 | $("#bookingform-step1").parent().load(href,{bukacal:1,count_accomodations:rooms});
60 | return false;
61 | });
62 | $(document).on('change','#bookingform-step1 #buka_daterange_select',function(e) {
63 | e.preventDefault();
64 | // console.log($(this).val());
65 | let param = $(this).val();
66 | let ym = param.split('-');
67 | let rooms = $('#buka_accomodation_select option:selected').val();
68 | let href = location.href;
69 | $("#bookingform-step1").parent().load(href,{year:ym[0],month:ym[1],bukacal:1,ym:param,count_accomodations:rooms});
70 | return false;
71 | });
72 | // Select in .ajax_element (Anzahl Räume)
73 | $(document).on('change','#buka_accomodation_select select',function(e) {
74 | let href = location.href;
75 | let rooms = $(this).val();
76 | let ym = $('#buka_daterange_select option:selected').val().split('-');
77 | $('input[name="count_accomodations"]').val(rooms);
78 | $("#bookingform-step1").parent().load(href,{bukacal:1,count_accomodations:rooms,year:ym[0],month:ym[1]});
79 | return false;
80 | });
81 |
82 |
83 |
84 |
85 | $(document).on("click", "#to-step-2", function () {
86 | $("#bookingform-step1").slideUp();
87 | $("#bookingform-step2").slideDown();
88 | });
89 | $(document).on("click", "#to-step-1", function () {
90 | $("#bookingform-step2").slideUp();
91 | $("#bookingform-step1").slideDown();
92 | });
93 |
94 | if ($('.uk-form-danger').length) {
95 | $("#bookingform-step1").hide();
96 | $("#bookingform-step2").show();
97 | }
98 |
99 | function clear_booking() {
100 | $(".buka-cal-wrapper").removeClass("booking-complete");
101 | $(".buka-cal-wrapper").removeClass("booking-start");
102 | $(".bk-cal-day").removeClass("reserve-start");
103 | $(".bk-cal-day").removeClass("reserve-end");
104 | $(".bk-cal-day").removeClass("add-reserve");
105 | $(".bk-cal-day").removeClass("booking-range");
106 | $("input#date_start").val("");
107 | $("input#date_end").val("");
108 | $("input#datestart").val("");
109 | $("input#dateend").val("");
110 | $("#to-step-2").prop("disabled", true);
111 | }
112 |
113 | function mark_end($elem) {
114 | let min_booking_days = $elem.data('minbookingdays');
115 | $(".bk-cal-day").removeClass("booking-range");
116 | $(".buka-cal-wrapper").removeClass("booking-start");
117 | $(".buka-cal-wrapper").addClass("booking-complete");
118 | $elem.addClass("reserve-end");
119 | $("input#date_end").val(
120 | $elem.data("date").split("-").reverse().join(".")
121 | );
122 | $("input#dateend").val($elem.data("date"));
123 | $(".mind_booking_message").hide();
124 | $("#to-step-2").prop("disabled", false).addClass('uk-active');
125 | $("#to-step-3").prop("disabled", false).addClass('bluered');
126 | if ($(".add-reserve").length <= min_booking_days) {
127 | $(".mind_booking_message").show();
128 | $("#to-step-2").prop("disabled", true).removeClass('uk-active');
129 | $("#to-step-3").prop("disabled", true).removeClass('bluered');
130 | }
131 | }
132 |
133 | function find_end ($elem) {
134 | let EndDate = new Date($elem.data("date"));
135 | if ($elem.data("fullweek") == 1 && EndDate.getDay() != 6 && !$elem.hasClass('fix-booked-start')) {
136 | while (EndDate.getDay() != 6) {
137 | EndDate.setDate(EndDate.getDate() + 1);
138 | if ($("ul").find("[data-date='"+date_to_string(EndDate)+"']").hasClass('fix-booked-start')) {
139 | break;
140 | }
141 | }
142 | let $endElem = $("ul").find("[data-date='"+date_to_string(EndDate)+"']");
143 | mark_range($endElem);
144 | mark_end($endElem);
145 | return;
146 | }
147 | mark_range($elem);
148 | mark_end($elem);
149 | }
150 |
151 |
152 | function find_start($elem) {
153 | StartDate = new Date($elem.data("date"));
154 | if ($elem.data("fullweek") == 1 && StartDate.getDay() != 6 && !$elem.hasClass('fix-booked-end')) {
155 | while (StartDate.getDay() != 6) {
156 | StartDate.setDate(StartDate.getDate() - 1);
157 | if ($("ul").find("[data-date='"+date_to_string(StartDate)+"']").hasClass('fix-booked-end')) {
158 | break;
159 | }
160 | }
161 | mark_start($("ul").find("[data-date='"+date_to_string(StartDate)+"']"));
162 | $elem.trigger('mouseenter');
163 | return;
164 | }
165 |
166 | mark_start($elem);
167 | }
168 |
169 | function mark_start($elem) {
170 | let addthis = 0;
171 | $(".buka-cal-wrapper").addClass("booking-start");
172 | $elem.addClass("reserve-start");
173 | $elem.addClass("bookable");
174 | $("input#date_start").val(
175 | $elem.data("date").split("-").reverse().join(".")
176 | );
177 | $("input#datestart").val($elem.data("date"));
178 | $(".bk-cal-day").removeClass("booking-range");
179 |
180 | $(".bk-cal-day").each(function () {
181 | if ($(this).hasClass("reserve-start")) {
182 | addthis = 1;
183 | }
184 | if (addthis && $(this).hasClass("bookable")) {
185 | $(this).addClass("booking-range");
186 | }
187 | if (!$(this).hasClass("bookable")) {
188 | addthis = 0;
189 | }
190 | if (addthis && $(this).hasClass("fix-booked-start")) {
191 | $(this).addClass("booking-range");
192 | addthis = 0;
193 | }
194 | });
195 |
196 |
197 |
198 | }
199 |
200 | function date_to_string(jsDate) {
201 | return (
202 | jsDate.getFullYear() +
203 | "-" +
204 | pad(jsDate.getMonth() + 1, 2) +
205 | "-" +
206 | pad(jsDate.getDate(), 2)
207 | );
208 | }
209 |
210 | function pad(str, max) {
211 | str = str.toString();
212 | return str.length < max ? pad("0" + str, max) : str;
213 | }
214 |
215 | $('.minikalender-wrapper').on('click','a',function(e) {
216 | e.preventDefault();
217 | let href = $(this).attr('href')+"&minicalendar=1";
218 | $($(this).parents('.minikalender-wrapper')).load(href);
219 | return false;
220 | });
221 |
222 | $(document).on(
223 | "mouseenter",
224 | ".buka-cal-wrapper.booking-start .bk-cal-day",
225 | function () {
226 | mark_range($(this));
227 | }
228 | );
229 |
230 | function mark_range ($elem) {
231 | var addthis = 0;
232 | var $current = $elem;
233 | $(".bk-cal-day").removeClass("add-reserve");
234 | if ($current.data("date") >= $(".reserve-start").data("date")) {
235 | $(".bk-cal-day").each(function () {
236 | if ($(this).hasClass("reserve-start")) {
237 | addthis = 1;
238 | }
239 | if ($(this).data("date") > $current.data("date")) {
240 | addthis = 0;
241 | }
242 | if (addthis && $(this).hasClass("bookable")) {
243 | $(this).addClass("add-reserve");
244 | }
245 | if (!$(this).hasClass("bookable")) {
246 | addthis = 0;
247 | }
248 | });
249 | }
250 |
251 | }
252 |
253 | });
254 |
255 | $(document).on('rex:ready',function() {
256 | $('.sortable_table table tbody').sortable();
257 | })
258 |
--------------------------------------------------------------------------------
/boot.php:
--------------------------------------------------------------------------------
1 | getPath('ytemplates'));
11 |
12 | if (rex::isBackend() && isset($_REQUEST['page'])) {
13 | rex_view::addCssFile(rex_addon::get('buchungskalender')->getAssetsUrl('css/buchungskalender.css'));
14 | rex_view::addJsFile(rex_addon::get('buchungskalender')->getAssetsUrl('js/buchungskalender.js'));
15 | }
16 |
17 | if (rex::isBackend() && rex_request('table_name') == 'rex_buka_objects') {
18 | rex_extension::register('YFORM_DATA_LIST', function( $ep ) {
19 | $list = $ep->getSubject();
20 | $list->setColumnFormat('colorcode', 'custom', function ($params ) {
21 | return '
';
22 | });
23 | });
24 | }
25 |
26 | if (rex::isBackend() && rex::getUser()) {
27 | if (rex::isDebugMode() && rex_request_method() == 'get') {
28 | $run_compiler = false;
29 | if (!file_exists($this->getPath('assets/css/buchungskalender.css'))) {
30 | $run_compiler = true;
31 | } elseif (!file_exists($this->getAssetsPath('css/buchungskalender.css'))) {
32 | $run_compiler = true;
33 | } elseif (filemtime($this->getPath('scss/buchungskalender.scss')) > filemtime($this->getAssetsPath('css/buchungskalender.css'))) {
34 | $run_compiler = true;
35 | }
36 | if ($run_compiler) {
37 | $compiler = new rex_scss_compiler();
38 | $compiler->setRootDir($this->getPath());
39 | $compiler->setScssFile($this->getPath('scss/buchungskalender.scss'));
40 | $compiler->setCssFile($this->getPath('assets/css/buchungskalender.css'));
41 | $compiler->compile();
42 | rex_file::copy($this->getPath('assets/css/buchungskalender.css'), $this->getAssetsPath('css/buchungskalender.css'));
43 | }
44 |
45 | // Backend JS
46 | $copy_js = false;
47 | if (!file_exists($this->getAssetsPath('js/buchungskalender.js'))) {
48 | $copy_js = true;
49 | } elseif (filemtime($this->getPath('assets/js/buchungskalender.js')) > filemtime($this->getAssetsPath('js/buchungskalender.js'))) {
50 | $copy_js = true;
51 | }
52 | if ($copy_js) {
53 | rex_file::copy($this->getPath('assets/js/buchungskalender.js'), $this->getAssetsPath('js/buchungskalender.js'));
54 | }
55 |
56 | // Frontend JS
57 | $copy_js = false;
58 | if (!file_exists($this->getAssetsPath('frontend/js/buchungskalender.js'))) {
59 | $copy_js = true;
60 | } elseif (filemtime($this->getPath('assets/frontend/js/buchungskalender.js')) > filemtime($this->getAssetsPath('frontend/js/buchungskalender.js'))) {
61 | $copy_js = true;
62 | }
63 | if ($copy_js) {
64 | rex_file::copy($this->getPath('assets/frontend/js/buchungskalender.js'), $this->getAssetsPath('frontend/js/buchungskalender.js'));
65 | }
66 | }
67 |
68 |
69 |
70 | rex_extension::register('PACKAGES_INCLUDED', function() {
71 | if (rex_request('addon','string') == 'buka' && rex_request('action','string') == 'editrecord') {
72 | $data_id = rex_get('data_id','int');
73 | $_csrf_key = rex_yform_manager_table::get('rex_buka_bookings')->getCSRFKey();
74 | $token = rex_csrf_token::factory($_csrf_key)->getUrlParams();
75 | $params = [
76 | 'page'=>'yform/manager/data_edit',
77 | 'table_name'=>'rex_buka_bookings',
78 | 'data_id'=>$data_id,
79 | 'func'=>'edit',
80 | '_csrf_token' => $token['_csrf_token']
81 | ];
82 | rex_response::sendRedirect(rex_url::backendPage('yform/manager/data_edit', $params,false));
83 | }
84 | });
85 | }
86 |
87 | if (rex::isFrontend()) {
88 | rex_extension::register('PACKAGES_INCLUDED', function() {
89 |
90 | // rex_file::copy($this->getPath('assets/frontend/js/buchungskalender.js'), $this->getAssetsPath('frontend/js/buchungskalender.js'));
91 |
92 | rex_login::startSession();
93 | if (rex_config::get('buchungskalender','ical_interval') && !rex_request::isXmlHttpRequest()) {
94 | buka_ical::check_ical_data();
95 | }
96 |
97 | if (rex_request('action','string') == 'get_ical_data' && rex_request('object_id','int')) {
98 | rex_logger::factory()->log('info',(string) $_SERVER['HTTP_REFERER'],[],__FILE__,__LINE__);
99 | echo buka_ical::send_ical_data_for_obj(rex_request('object_id','int'));
100 | exit;
101 | }
102 | if (rex_request::isXmlHttpRequest() && rex_request('minicalendar','int') == 1) {
103 | echo buka_cal::get_mini_calendar(rex_request('object_id','int'));
104 | exit;
105 | }
106 |
107 | // Buchungskalender
108 |
109 | if (rex_request::isXmlHttpRequest() && rex_request('bukacal','int') == 1) {
110 | $art = new rex_article_content();
111 | if (rex_config::get('buchungskalender','booking_page')) {
112 | $art->setArticleId(rex_config::get('buchungskalender','booking_page'));
113 | } else {
114 | $art->setArticleId(rex_article::getCurrentId());
115 | }
116 | $content = $art->getArticle();
117 | if (rex_addon::get('sprog')->isAvailable()) {
118 | $content = sprogdown($content);
119 | }
120 | $dom = new DOMDocument('1.0', 'UTF-8');
121 | libxml_use_internal_errors(true);
122 | $dom->preserveWhiteSpace = false;
123 | $dom->formatOutput = true;
124 | $dom->loadHTML(''.$content.'');
125 | libxml_clear_errors();
126 | $node = $dom->getElementById('bookingform-step1');
127 | echo $dom->saveHTML($node);
128 | exit;
129 | }
130 |
131 | // Termine Kalender
132 |
133 | // if (rex_request::isXmlHttpRequest() && rex_request('bukadate','int') == 1) {
134 | if (rex_request('bukadate','int') == 1) {
135 | $art = new rex_article_content();
136 | $art->setArticleId(rex_article::getCurrentId());
137 | $dom = new DOMDocument('1.0', 'UTF-8');
138 | libxml_use_internal_errors(true);
139 | $dom->preserveWhiteSpace = false;
140 | $dom->formatOutput = true;
141 | $dom->loadHTML(''.$art->getArticle().'');
142 | libxml_clear_errors();
143 | $node = $dom->getElementById('datebookingform-step1');
144 | echo $dom->saveHTML($node);
145 | exit;
146 | }
147 |
148 |
149 | // Buchungsbestätigungslink aktiviert
150 | if (rex_request('action') == 'booking_confirm' && rex_request('email') && rex_request('hash')) {
151 | if (buka_booking::confirm_booking()) {
152 | rex_redirect(rex_config::get('buchungskalender','confirmation_page'),'',['success'=>1]);
153 | } else {
154 | rex_redirect(rex_config::get('buchungskalender','confirmation_page'),'',['success'=>0]);
155 | }
156 | }
157 | // Terminbestätigungslink aktiviert
158 | if (rex_request('action') == 'date_booking_confirm' && rex_request('email') && rex_request('hash')) {
159 | if (buka_booking::confirm_date_booking()) {
160 | rex_redirect(rex_config::get('buchungskalender','confirmation_page'),'',['success'=>1]);
161 | } else {
162 | rex_redirect(rex_config::get('buchungskalender','confirmation_page'),'',['success'=>0]);
163 | }
164 | }
165 |
166 |
167 |
168 | });
169 | }
170 |
171 |
172 |
173 |
174 |
175 | // register a custom yrewrite scheme
176 | // rex_yrewrite::setScheme(new rex_project_rewrite_scheme());
177 |
178 | // register yform template path
179 | // rex_yform::addTemplatePath($addon->getPath('yform-templates'));
180 |
181 | // register yorm class
182 | // rex_yform_manager_dataset::setModelClass('rex_my_table', my_classname::class);
183 |
184 | // Example of mediapool Whitelist
185 | /*
186 | rex_addon::get('mediapool')->setProperty('allowed_mime_types', [
187 | 'gif' => ['image/gif'],
188 | 'jpg' => ['image/jpeg', 'image/pjpeg'],
189 | 'jpeg' => ['image/jpeg', 'image/pjpeg'],
190 | 'png' => ['image/png'],
191 | 'eps' => ['application/postscript'],
192 | 'tif' => ['image/tiff'],
193 | 'tiff' => ['image/tiff'],
194 | 'svg' => ['image/svg+xml'],
195 | 'pdf' => ['application/pdf'],
196 | 'xls' => ['application/vnd.ms-excel'],
197 | 'xlsx' => ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
198 | 'xlsm' => ['application/vnd.ms-excel.sheet.macroEnabled.12'],
199 | 'doc' => ['application/msword'],
200 | 'docx' => ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
201 | 'docm' => ['application/vnd.ms-word.document.macroEnabled.12'],
202 | 'dot' => ['application/msword'],
203 | 'dotx' => ['application/vnd.openxmlformats-officedocument.wordprocessingml.template'],
204 | 'dotm' => ['application/vnd.ms-word.template.macroEnabled.12'],
205 | 'ppt' => ['application/vnd.ms-powerpoint'],
206 | 'pptx' => ['application/vnd.openxmlformats-officedocument.presentationml.presentation'],
207 | 'pptm' => ['application/vnd.ms-powerpoint.presentation.macroEnabled.12'],
208 | 'pot' => ['application/vnd.ms-powerpoint'],
209 | 'potx' => ['application/vnd.openxmlformats-officedocument.presentationml.template'],
210 | 'potm' => ['application/vnd.ms-powerpoint.template.macroEnabled.12'],
211 | 'pps' => ['application/vnd.ms-powerpoint'],
212 | 'ppsx' => ['application/vnd.openxmlformats-officedocument.presentationml.slideshow'],
213 | 'ppsm' => ['application/vnd.ms-powerpoint.slideshow.macroEnabled.12'],
214 | 'rtf' => ['application/rtf'],
215 | 'txt' => ['text/plain', 'application/octet-stream'],
216 | 'csv' => ['text/plain', 'application/octet-stream'],
217 | 'zip' => ['application/x-zip-compressed','application/zip'],
218 | 'gz' => ['application/x-gzip'],
219 | 'tar' => ['application/x-tar'],
220 | 'mov' => ['video/quicktime'],
221 | 'movie' => ['video/quicktime'],
222 | 'mp3' => ['audio/mpeg'],
223 | 'mpe' => ['video/mpeg'],
224 | 'mpeg' => ['video/mpeg'],
225 | 'mpg' => ['video/mpeg'],
226 | ]);
227 | */
228 |
--------------------------------------------------------------------------------