fix Kalender view + Datum aus Konfiguration

This commit is contained in:
Karsten Siegmund 2024-01-14 20:56:54 +01:00
parent f76c5c1db5
commit 30aa75aa01
5 changed files with 177 additions and 92 deletions

View File

@ -133,7 +133,7 @@ while ($zeile = mysqli_fetch_array($db_erg, MYSQLI_ASSOC)) {
</tr>
<!--</table></td> </tr> inner table for indent end-->
<!--<tr><th>Weiteres</th></tr>-->
<tr onclick="window.location.href='Kalender-all.html';">
<tr onclick="window.location.href='Kalender-all.php';">
<td><img src="Bilder/More.jpeg" style="width:30px;height:30px"><b> Admin Kalenderansicht</b> </td>
</tr>
<tr onclick="window.location.href='Ausdrucke.php';">

View File

@ -1,3 +1,12 @@
<?php
// Login und Admin Status testen. Wenn kein Admin-Status, Weiterleiten auf index.php und beenden
SESSION_START();
require_once 'konfiguration.php';
require 'SQL.php';
$db_link = ConnectDB();
require '_login.php';
require '_zeitbereich.php';
?>
<!DOCTYPE html>
<html>
<head>
@ -7,6 +16,7 @@
<script src="scheduler/codebase/dhtmlxscheduler.js"></script>
<!--link href="scheduler/codebase/dhtmlxscheduler.css" rel="stylesheet" type="text/css" charset="utf-8"-->
<link href="scheduler/codebase/dhtmlxscheduler_contrast_black.css" rel="stylesheet" type="text/css" charset="utf-8">
<link rel="stylesheet" href="scheduler/samples/common/controls_styles.css">
<style>
html, body{
@ -24,23 +34,23 @@ border:none !important;
</style>
<!-- darkstyle
style type="text/css" >
.filters_wrapper {
background-color: black;
color: white;
font: 500 14px Roboto;
padding-left: 15px;
padding-right: 15px;
}
.filters_wrapper span {
font-weight: bold;
padding-left: 15px;
padding-right: 15px;
color: rgba(0,0,0,0.7);
}
.filters_wrapper label {
padding-left: 15px;
padding-right: 15px;
}
.filters_wrapper {
background-color: black;
color: white;
font: 500 14px Roboto;
padding-left: 15px;
padding-right: 15px;
}
.filters_wrapper span {
font-weight: bold;
padding-left: 15px;
padding-right: 15px;
color: rgba(0,0,0,0.7);
}
.filters_wrapper label {
padding-left: 15px;
padding-right: 15px;
}
</style-->
</head>
@ -56,30 +66,30 @@ Filtern: <input type="text" id="filterWrap">
</div>
<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button">&nbsp;</div>
<div class="dhx_cal_next_button">&nbsp;</div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab"></div>
<div class="dhx_cal_tab" name="week_tab"></div>
<div class="dhx_cal_tab" name="month_tab"></div>
<div class="dhx_cal_tab" data-tab="con" style="right:280px;"></div>
<div class="dhx_cal_tab" data-tab="prep" style="right:280px;" ></div>
</div>
<div class="dhx_cal_header"></div>
<div class="dhx_cal_data"></div>
</div>
<script>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button">&nbsp;</div>
<div class="dhx_cal_next_button">&nbsp;</div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab"></div>
<div class="dhx_cal_tab" name="week_tab"></div>
<div class="dhx_cal_tab" name="month_tab"></div>
<div class="dhx_cal_tab" data-tab="con" style="right:280px;"></div>
<div class="dhx_cal_tab" data-tab="prep" style="right:280px;" ></div>
</div>
<div class="dhx_cal_header"></div>
<div class="dhx_cal_data"></div>
</div>
<script>
//https://docs.dhtmlx.com/scheduler/filtering.html
var filter = document.querySelector("#filterWrap");
filter.addEventListener("input", function(){
scheduler.setCurrentView();
})
scheduler.setCurrentView();
})
scheduler.filter_month = scheduler.filter_day = scheduler.filter_week = scheduler.filter_con = scheduler.filter_prep = function(id, event) {
if(filter.value == ""){
if(filter.value == ""){
return true;
}
if(event.text.toLowerCase().includes(filter.value.toLowerCase()) ){
@ -151,14 +161,14 @@ function colorize (e){ //KS
scheduler.attachEvent("onTemplatesReady",function(){ // for custom time ranges
//Con timeslot
scheduler.date.con_start = function(date){return date;}; //new Date(202x,5,16);}; // calculates start-day of range from current day
scheduler.date.con_start = function(date){return date;};
scheduler.templates.con_date = scheduler.templates.week_date;
scheduler.templates.con_scale_date = scheduler.templates.week_scale_date;
scheduler.date.add_con=function(date,inc){ return scheduler.date.add(date,inc*4,"day"); }//"next" gives you the next 4 days
scheduler.date.get_con_end=function(date){ return scheduler.date.add(date,4,"day"); }
//preparation phase 2 days
function setprep(){scheduler.setCurrentView(new Date(2023,4,16));}
function setprep(){scheduler.setCurrentView(new Date(<?php echo KalenderDatum ($start_date);?>));}
scheduler.date.prep_start = function(date){return date};
scheduler.templates.prep_date = scheduler.templates.week_date;
scheduler.templates.prep_scale_date = scheduler.templates.week_scale_date;
@ -173,10 +183,10 @@ function colorize (e){ //KS
};
scheduler.config.all_timed = "short"; // night events arent multi-day - events under 24h are shown
scheduler.config.lightbox.sections=[
{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
{name:"Dienstbeschreibung", height:90, type:"textarea", map_to:"Info" },
{name:"Konakt", height:200, type:"textarea", map_to:"Kontakt" },
scheduler.config.lightbox.sections=[
{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
{name:"Dienstbeschreibung", height:90, type:"textarea", map_to:"Info" },
{name:"Konakt", height:200, type:"textarea", map_to:"Kontakt" },
{name:"time", height:72, type:"time", map_to:"auto"}
];
@ -185,7 +195,7 @@ function colorize (e){ //KS
};
// actual init
scheduler.init('scheduler_here', new Date(2023,4,18), "con");
scheduler.init('scheduler_here', new Date(<?php echo KalenderDatum ($start_date);?>), "con");
scheduler.load("data/api-full.php");
//https://docs.dhtmlx.com/scheduler/api__scheduler_createdataprocessor.html
//var dp = scheduler.createDataProcessor("data/api.php"); // this would be for saving

View File

@ -1,64 +1,68 @@
<?php
// Login und Admin Status testen. Wenn kein Admin-Status, Weiterleiten auf index.php und beenden
SESSION_START();
require_once 'konfiguration.php';
require 'SQL.php';
$db_link = ConnectDB();
require '_login.php';
require '_zeitbereich.php';
?>
<!DOCTYPE html>
<html>
<head>
<title> Helferdienste </title>
<meta charset="utf-8">
<!--meta name="viewport" content="width=device-width, initial-scale=1 ,user-scalable=1"-->
<script src="scheduler/codebase/dhtmlxscheduler.js"></script>
<!-- link href="scheduler/codebase/dhtmlxscheduler_contrast_black.css" rel="stylesheet" type="text/css" charset="utf-8"-->
<link href="scheduler/codebase/dhtmlxscheduler.css" rel="stylesheet" type="text/css" charset="utf-8">
<link rel="stylesheet" href="../scheduler/samples/common/controls_styles.css">
<style>
<title> Helferdienste </title>
<meta charset="utf-8">
<!--meta name="viewport" content="width=device-width, initial-scale=1 ,user-scalable=1"-->
<script src="scheduler/codebase/dhtmlxscheduler.js"></script>
<!--link href="scheduler/codebase/dhtmlxscheduler.css" rel="stylesheet" type="text/css" charset="utf-8"-->
<link href="scheduler/codebase/dhtmlxscheduler_contrast_black.css" rel="stylesheet" type="text/css" charset="utf-8">
<link rel="stylesheet" href="scheduler/samples/common/controls_styles.css">
<style>
html, body{
margin:0px;
padding:0px;
height:100%;
overflow:hidden;
html, body{
margin:0px;
padding:0px;
height:100%;
overflow:hidden;
}
.dhx_cal_event_line,.dhx_body,.dhx_cal_event .dhx_footer,.dhx_cal_event .dhx_header,.dhx_cal_event .dhx_title{
border:none !important;
border-radius:3px 3px 3px 3px !important;
}
.dhx_scale_holder {background-image: url('Bilder/calendar_lines1.png') !important; background-blend-mode:color-dodge;}
</style>
<!-- darkstyle
style type="text/css" >
.filters_wrapper {
background-color: black;
color: white;
font: 500 14px Roboto;
padding-left: 15px;
padding-right: 15px;
}
</style>
<!-- darkstyle
style type="text/css" >
.filters_wrapper {
background-color: black;
color: white;
font: 500 14px Roboto;
padding-left: 15px;
padding-right: 15px;
}
.filters_wrapper span {
font-weight: bold;
padding-left: 15px;
padding-right: 15px;
color: rgba(0,0,0,0.7);
}
.filters_wrapper label {
padding-left: 15px;
padding-right: 15px;
}
.filters_wrapper span {
font-weight: bold;
padding-left: 15px;
padding-right: 15px;
color: rgba(0,0,0,0.7);
}
.filters_wrapper label {
padding-left: 15px;
padding-right: 15px;
}
</style-->
</head>
<body>
<button name="BackHelferdaten" value="1" onclick="window.location.href = 'index.php';"><b>&larrhk;</b></button><br>
<div class="filters_wrapper" id="filters_wrapper">
&nbsp;
Mehrtagesdienste anzeigen: <input id="multidaycheck" class="sch_radio" type="checkbox" checked onchange="toggleMultiday(this)">
Einfärben: <input type="text" id="colorize"> <!--onchange="markEntries(this.value);" onpaste = "this.onchange();" onsubmit="markEntries(this.value);"-->
Filtern: <input type="text" id="filterWrap">
<br/>
Achtung: Ende Nachtdienste wird falsch angezeigt (immer Mitternacht) - Popup-Fenster zeigt richtige Zeiten
Mehrtagesdienste anzeigen: <input id="multidaycheck" class="sch_radio" type="checkbox" checked onchange="toggleMultiday(this)">
Einfärben: <input type="text" id="colorize"> <!--onchange="markEntries(this.value);" onpaste = "this.onchange();" onsubmit="markEntries(this.value);"-->
Filtern: <input type="text" id="filterWrap">
<br/>
<!--Achtung: Ende Nachtdienste wird falsch angezeigt (immer Mitternacht) - Popup-Fenster zeigt richtige Zeiten-->
</div>
<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
@ -157,14 +161,14 @@ function colorize (e){ //KS
scheduler.attachEvent("onTemplatesReady",function(){ // for custom time ranges
//Con timeslot
scheduler.date.con_start = function(date){return date;}; //new Date(202,5,16);}; // calculates start-day of range from current day
scheduler.date.con_start = function(date){return date;};
scheduler.templates.con_date = scheduler.templates.week_date;
scheduler.templates.con_scale_date = scheduler.templates.week_scale_date;
scheduler.date.add_con=function(date,inc){ return scheduler.date.add(date,inc*4,"day"); }//"next" gives you the next 4 days
scheduler.date.get_con_end=function(date){ return scheduler.date.add(date,4,"day"); }
//preparation phase 2 days
function setprep(){scheduler.setCurrentView(new Date(2023,4,16));}
function setprep(){scheduler.setCurrentView(new Date(<?php echo KalenderDatum ($start_date);?>));}
scheduler.date.prep_start = function(date){return date};
scheduler.templates.prep_date = scheduler.templates.week_date;
scheduler.templates.prep_scale_date = scheduler.templates.week_scale_date;
@ -179,7 +183,7 @@ function colorize (e){ //KS
};
scheduler.config.all_timed = "short"; // night events arent multi-day - events under 24h are shown
scheduler.config.lightbox.sections=[
scheduler.config.lightbox.sections=[
{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
{name:"Dienstbeschreibung", height:90, type:"textarea", map_to:"Info" },
{name:"Konakt", height:200, type:"textarea", map_to:"Kontakt" },
@ -191,7 +195,7 @@ function colorize (e){ //KS
};
// actual init
scheduler.init('scheduler_here', new Date(2023,4,18), "con");
scheduler.init('scheduler_here', new Date(<?php echo KalenderDatum ($start_date);?>), "con");
scheduler.load("data/api-helfer.php");
//https://docs.dhtmlx.com/scheduler/api__scheduler_createdataprocessor.html
//var dp = scheduler.createDataProcessor("data/api.php"); // this would be for saving

View File

@ -48,8 +48,9 @@ if (!isset($_SESSION["HelferID"])) {
<title>Helfer <?php echo EVENTNAME ?> Home</title>
<link rel="stylesheet" href="css/style_desktop.css" media="screen and (min-width:781px)"/>
<link rel="stylesheet" href="css/style_mobile.css" media="screen and (max-width:780px)"/>
<meta name="viewport" content="width=480" />
<meta charset="utf-8">
<script src="js/helferdb.js" type="text/javascript"></script>
<meta name="viewport" content="width=480" />
<meta charset="utf-8">
</head>
<body>
<form method="post" action="#Info">

70
html/_zeitbereich.php Normal file
View File

@ -0,0 +1,70 @@
<?php
function KalenderDatum ($start_date)
{
$format = 'Y,m,d';
// the calender counts monts from 0 for whatever reason,
// so we have to subtract 1 from the month. Subtracting 1 month is not possible because it can wrap to december
$KalenderDatum = date_format($start_date, "Y");
$KalenerMonat = date_format($start_date, "m")-1;
$KalenderDatum = "$KalenderDatum,$KalenerMonat,".date_format($start_date, "d");
return ($KalenderDatum );
}
function AusgabeZeitbereichZeile ($start_date,$ZeitBereich,$TageNamenDeutsch)
{
// ZeitbereichWerte (array): -1 davor, 0 kein Limit, 1-N Tag N der Con, 1000: nach der Con
$ZeitBereichWerte = ZEITBEREICHWERTE;
$ZeitBereichFelder = count($ZeitBereichWerte);
$ZeitBereichFeldBreite = round(100 / $ZeitBereichFelder); // % width for style
$format = 'Y-m-d';
// iterate over all days plus "before" and "after"
// Wenn TAG_DAUER=4, dann sind die Werte 1-4 die Tage der Con
// ZeitBereichWerte = [-1, 0, 1, 2, 3, 4, 1000]
// -1: davor, 0: alle, 1-4: Tag 1-4, 1000: danach
foreach ($ZeitBereichWerte as &$EinZeitBereich) {
if ($EinZeitBereich > 0 && $EinZeitBereich <= TAGE_DAUER) {
$PlusTage = $EinZeitBereich - 1;
//TODO: only if locale DE
$day = $start_date->add(new DateInterval("P{$PlusTage}D"));
$Wochentag = $TageNamenDeutsch[date_format($day, 'w')];
$Text = "$Wochentag (Tag{$EinZeitBereich})";
$Von = date_format($day, $format) . " 00:00:00";
$Bis = date_format($day, $format) . " 23:59:59";
} elseif ($EinZeitBereich == -1) {
$Text = 'Davor';
$Von = "2000-01-01 00:00:00";
$Bis = date_format($start_date, $format) . " 00:00:00";
} elseif ($EinZeitBereich == 0) {
$Text = 'Alle' ;
$Von = "2000-01-01 00:00:00";
$Bis = "3000-01-01 00:00:00";
} elseif ($EinZeitBereich == 1000) {
$Text = 'Danach';
$tage_dauer = TAGE_DAUER;
$day = $start_date->add(new DateInterval("P{$tage_dauer}D"));
$Von = date_format($day, $format) . " 00:00:00";
$Bis = "3000-01-01 00:00:00";
}
// highlight the selected time range
if ($EinZeitBereich == $ZeitBereich) {
$color = 'background-color:#0000FF; ' ;
$MeinVon = $Von;
$MeinBis = $Bis;
} else {
$color = '';
}
// write the field for each day
echo "<th style='width:{$ZeitBereichFeldBreite}%; $color' ";
echo "onclick='window.location.href=\"TeilnehmerSchichtenAusdruck.php?ZeitBereich={$EinZeitBereich}\";'>";
echo "$Text" . "</th>\n";
}
echo "</tr>"; //Zeitbereich tr
return [
'MeinVon' => $MeinVon,
'MeinBis' => $MeinBis
];
}
?>