Bernd Wurst commited on 2023-04-28 11:50:48
Zeige 4 geänderte Dateien mit 25 Einfügungen und 74 Löschungen.
| ... | ... |
@@ -428,32 +428,11 @@ function html_select($name, $options, $default='', $free='') |
| 428 | 428 |
} |
| 429 | 429 |
|
| 430 | 430 |
|
| 431 |
-function html_datepicker($nameprefix, $timestamp) |
|
| 432 |
-{
|
|
| 433 |
- $valid_days = [ 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, |
|
| 434 |
- 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, |
|
| 435 |
- 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, |
|
| 436 |
- 16 => 16, 17 => 17, 18 => 18, 19 => 19, 20 => 20, |
|
| 437 |
- 21 => 21, 22 => 22, 23 => 23, 24 => 24, 25 => 25, |
|
| 438 |
- 26 => 26, 27 => 27, 28 => 28, 29 => 29, 30 => 30, |
|
| 439 |
- 31 => 31, ]; |
|
| 440 |
- $valid_months = [ 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, |
|
| 441 |
- 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, |
|
| 442 |
- 11 => 11, 12 => 12, ]; |
|
| 443 |
- $current_year = (int) date('Y');
|
|
| 444 |
- $valid_years = [$current_year => $current_year, |
|
| 445 |
- $current_year+1 => $current_year+1, |
|
| 446 |
- $current_year+2 => $current_year+2, |
|
| 447 |
- $current_year+3 => $current_year+3, |
|
| 448 |
- $current_year+4 => $current_year+4, ]; |
|
| 449 |
- |
|
| 450 |
- $selected_day = date('d', $timestamp);
|
|
| 451 |
- $selected_month = date('m', $timestamp);
|
|
| 452 |
- $selected_year = date('Y', $timestamp);
|
|
| 431 |
+function html_datepicker($htmlname, $timestamp) |
|
| 432 |
+{
|
|
| 433 |
+ $date = date('Y-m-d', $timestamp);
|
|
| 453 | 434 |
$ret = ''; |
| 454 |
- $ret .= html_select($nameprefix.'_day', $valid_days, $selected_day, 'style="text-align: right;"').". "; |
|
| 455 |
- $ret .= html_select($nameprefix.'_month', $valid_months, $selected_month, 'style="text-align: right;"').". "; |
|
| 456 |
- $ret .= html_select($nameprefix.'_year', $valid_years, $selected_year); |
|
| 435 |
+ $ret .= '<input type="date" id="'.$htmlname.'" name="'.$htmlname.'" value="'.$date.'">'; |
|
| 457 | 436 |
return $ret; |
| 458 | 437 |
} |
| 459 | 438 |
|
| ... | ... |
@@ -146,47 +146,20 @@ $(document).ready(function(){
|
| 146 | 146 |
$('div.vmail-forward input').change();
|
| 147 | 147 |
|
| 148 | 148 |
|
| 149 |
- $.datepicker.regional['de'] = {clearText: 'löschen', clearStatus: 'aktuelles Datum löschen',
|
|
| 150 |
- closeText: 'schließen', closeStatus: 'ohne Änderungen schließen', |
|
| 151 |
- prevText: '< zurück', prevStatus: 'letzten Monat zeigen', |
|
| 152 |
- nextText: 'vor >', nextStatus: 'nächsten Monat zeigen', |
|
| 153 |
- currentText: 'heute', currentStatus: '', |
|
| 154 |
- monthNames: ['Januar','Februar','März','April','Mai','Juni', |
|
| 155 |
- 'Juli','August','September','Oktober','November','Dezember'], |
|
| 156 |
- monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun', |
|
| 157 |
- 'Jul','Aug','Sep','Okt','Nov','Dez'], |
|
| 158 |
- monthStatus: 'anderen Monat anzeigen', yearStatus: 'anderes Jahr anzeigen', |
|
| 159 |
- weekHeader: 'Wo', weekStatus: 'Woche des Monats', |
|
| 160 |
- dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'], |
|
| 161 |
- dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'], |
|
| 162 |
- dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'], |
|
| 163 |
- dayStatus: 'Setze DD als ersten Wochentag', dateStatus: 'Wähle D, M d', |
|
| 164 |
- dateFormat: 'dd.mm.yy', firstDay: 1, |
|
| 165 |
- initStatus: 'Wähle ein Datum', isRTL: false}; |
|
| 166 |
- $.datepicker.setDefaults( $.datepicker.regional[ "de" ] ); |
|
| 167 |
- $.datepicker.setDefaults({
|
|
| 168 |
- dateFormat: 'yy-mm-dd', |
|
| 169 |
- minDate: 1, |
|
| 170 |
- maxDate: "+2m" |
|
| 171 |
- |
|
| 172 |
- }); |
|
| 173 |
- |
|
| 174 |
- $('#ar_startdate').datepicker();
|
|
| 175 |
- $('#ar_startdate').change(function () {
|
|
| 176 |
- $('#ar_valid_from_date').prop('checked', true)
|
|
| 177 |
- mindate = $('#ar_startdate').datepicker("getDate");
|
|
| 178 |
- mindate.setDate(mindate.getDate()+1); |
|
| 179 |
- $('#ar_enddate').datepicker("option", "minDate", mindate);
|
|
| 180 |
- maxdate = $('#ar_startdate').datepicker("getDate");
|
|
| 181 |
- maxdate.setDate(maxdate.getDate()+60); |
|
| 182 |
- $('#ar_enddate').datepicker("option", "maxDate", maxdate);
|
|
| 149 |
+ document.querySelector("#ar_startdate").addEventListener("change", (e) => {
|
|
| 150 |
+ document.querySelector("#ar_enddate").min = document.querySelector("#ar_startdate").value;
|
|
| 151 |
+ startdate = new Date(document.querySelector("#ar_startdate").value)
|
|
| 152 |
+ minenddate = new Date(startdate); |
|
| 153 |
+ minenddate.setDate(startdate.getDate() + 1); |
|
| 154 |
+ document.querySelector("#ar_enddate").min = minenddate.toISOString().split("T")[0];
|
|
| 155 |
+ if (document.querySelector("#ar_enddate").value < document.querySelector("#ar_startdate").value) {
|
|
| 156 |
+ document.querySelector("#ar_enddate").value = minenddate.toISOString().split("T")[0];
|
|
| 157 |
+ } |
|
| 158 |
+ maxenddate = new Date(startdate); |
|
| 159 |
+ maxenddate.setDate(startdate.getDate() + 60); |
|
| 160 |
+ document.querySelector("#ar_enddate").max = maxenddate.toISOString().split("T")[0];
|
|
| 183 | 161 |
}); |
| 184 | 162 |
|
| 185 |
- $('#ar_enddate').datepicker();
|
|
| 186 |
- $('#ar_enddate').datepicker("option", "minDate", $('#ar_startdate').val());
|
|
| 187 |
- $('#ar_enddate').change(function () {
|
|
| 188 |
- $('#ar_valid_until_date').prop('checked', true)
|
|
| 189 |
- }); |
|
| 190 | 163 |
}); |
| 191 | 164 |
|
| 192 | 165 |
|
| ... | ... |
@@ -128,25 +128,24 @@ if (! $startdate || $startdate <= date('Y-m-d')) {
|
| 128 | 128 |
} |
| 129 | 129 |
$form .= "<p><input type=\"radio\" name=\"ar_valid_from\" value=\"now\" id=\"ar_valid_from_now\"{$valid_from_now_checked} /> <label for=\"ar_valid_from_now\">Ab sofort</label><br />".
|
| 130 | 130 |
"<input type=\"radio\" name=\"ar_valid_from\" value=\"date\" id=\"ar_valid_from_date\"{$valid_from_future_checked} /> <label for=\"ar_valid_from_date\">Erst ab dem </label>".
|
| 131 |
- "<input type=\"text\" value=\"$startdate\" id=\"ar_startdate\" name=\"ar_startdate\" /></p>"; |
|
| 131 |
+ "<input type=\"date\" value=\"$startdate\" id=\"ar_startdate\" name=\"ar_startdate\" min=\"".date('Y-m-d')."\" max=\"".date('Y-m-d', time() + 60*24*60*60)."\" /></p>";
|
|
| 132 | 132 |
|
| 133 |
-$valid_until_infinity_checked = ($ar['valid_until'] == null) ? ' checked="checked"' : ''; |
|
| 134 |
-$valid_until_date_checked = ($ar['valid_until'] != null) ? ' checked="checked"' : ''; |
|
| 135 | 133 |
$enddate = $ar['valid_until']; |
| 136 | 134 |
if (! $enddate) {
|
| 137 | 135 |
$enddate = date('Y-m-d', time() + 7*24*60*60);
|
| 138 | 136 |
} |
| 137 |
+$max_end = date('Y-m-d', time() + 60*24*60*60);
|
|
| 138 |
+if ($ar['valid_from'] > date('Y-m-d')) {
|
|
| 139 |
+ $max_end = date_create($ar['valid_from']); |
|
| 140 |
+ $max_end->modify("+60 day");
|
|
| 141 |
+ $max_end = $max_end->format('Y-m-d');
|
|
| 142 |
+} |
|
| 139 | 143 |
$form .= "<h4>Deaktivierung</h4>"; |
| 140 | 144 |
$form .= "<p><label for=\"ar_valid_until_date\">Keine Antworten mehr versenden ab dem </label>". |
| 141 |
- "<input type=\"text\" value=\"$enddate\" id=\"ar_enddate\" name=\"ar_enddate\" /><br/>"; |
|
| 145 |
+ "<input type=\"date\" value=\"$enddate\" id=\"ar_enddate\" name=\"ar_enddate\" min=\"".date('Y-m-d')."\" max=\"".$max_end."\" /><br/>";
|
|
| 142 | 146 |
if (!$accountlogin && ($id != 0)) {
|
| 143 | 147 |
$form .= "<small>(Automatische Antworten sind nur befristet erlaubt. Wenn Sie diese Adresse dauerhaft stilllegen möchten, können Sie dies am Ende dieser Seite tun.)</small></p>"; |
| 144 | 148 |
} |
| 145 |
-/* |
|
| 146 |
-$form .= "<p><input type=\"radio\" name=\"ar_valid_until\" value=\"infinity\" id=\"ar_valid_until_infinity\"{$valid_until_infinity_checked} /> <label for=\"ar_valid_until_infinity\">Unbefristet</label><br />".
|
|
| 147 |
- "<input type=\"radio\" name=\"ar_valid_until\" value=\"date\" id=\"ar_valid_until_date\"{$valid_until_date_checked} /> <label for=\"ar_valid_until_date\">Keine Antworten mehr versenden ab dem </label>".
|
|
| 148 |
- "<input type=\"text\" value=\"$enddate\" id=\"ar_enddate\" name=\"ar_enddate\" /><br/><small>(Automatische Antworten sind nur befristet erlaubt. Benötigen Sie langfristig funktionierende automatische Antworten, sprechen Sie unsere Administratoren bitte an, dann suchen wir eine Lösung.)</small></p>"; |
|
| 149 |
-*/ |
|
| 150 | 149 |
|
| 151 | 150 |
$subject = filter_output_html($ar['subject']); |
| 152 | 151 |
$ar_subject_default_checked = ($subject == null) ? ' checked="checked"' : ''; |
| ... | ... |
@@ -26,7 +26,7 @@ if ($_GET['action'] == 'new') {
|
| 26 | 26 |
|
| 27 | 27 |
$gueltig_ab = $_REQUEST['gueltig_ab']; |
| 28 | 28 |
if ($gueltig_ab == 'datum') {
|
| 29 |
- $gueltig_ab = $_REQUEST['gueltig_ab_datum_year'].'-'.$_REQUEST['gueltig_ab_datum_month'].'-'.$_REQUEST['gueltig_ab_datum_day']; |
|
| 29 |
+ $gueltig_ab = $_REQUEST['gueltig_ab_datum']; |
|
| 30 | 30 |
} |
| 31 | 31 |
if (! check_date($gueltig_ab)) {
|
| 32 | 32 |
system_failure('Konnte das Datum nicht auslesen');
|
| 33 | 33 |