Um im Webfront die Termine angezeigt zu bekommen ist folgendes zu tun:
- Stringvariable termine mit Variablenprofil ~TextBox im Baum unter .Terminverwaltung anlegen
- Link auf diese Stringvariable in der root im Objektbaum (Link als Termine benennen)
- Modifikationen im Terminscript vornehmen, entsprechene Codezeilen einfach ersetzen:
foreach(
array(
'term_anz1_farbe', 'term_anz2_farbe', 'term_anz3_farbe', 'term_anz4_farbe', 'term_anz5_farbe', 'term_anz6_farbe', 'terminmodus', 'term_zahl',
'counter_summe', 'counter', 'term_stunde', 'term_minute', 'term_tag', 'term_monat', 'term_trigger', 'term_trigger_para', 'term_anz1_inhalt', 'term_anz2_inhalt',
'term_anz3_inhalt', 'term_anz4_inhalt', 'term_anz5_inhalt', 'term_anz6_inhalt', 'term_inhalt', 'term_aktuell', 'term_meldung', 'term',
'term_mor', 'term_mod1_ansage', 'term_mod2_ansage', 'term_mod3_ansage', 'term_mod4_ansage', 'term_mod5_ansage', 'term_mod6_ansage', 'term_aktiv',
'term_einmalig', 'term_mo', 'term_di', 'term_mi', 'term_do', 'term_fr', 'term_sa', 'term_so', 'term_loe', 'term_trigger',
'term_jaerlich','termine'
) as $var)
{
${'id_'.$var} = IPS_GetVariableIDByName($var, $id_kat);
}
//Daten holen
$termfile = file_get_contents($filename); //Termine in Variable einlesen
$term_arr_komplett = explode("
", $termfile); // nach Zeilenumbruch trennen und in array
//Termine suchen
$term_zahl = 0;
$erg = "";
$term_para = 0;
$wo = 0;
$wf = array();
foreach($term_arr_komplett as $key => $value) //alle Termine durchlaufen
{
$term_arr = explode(",", $value); // einzelnen Datensatz in Daten zerlegen
$term_einmalig = $term_arr[1];
$term_jaerlich = $term_arr[2];
$term_mo = $term_arr[3];
$term_di = $term_arr[4];
$term_mi = $term_arr[5];
$term_do = $term_arr[6];
$term_fr = $term_arr[7];
$term_sa = $term_arr[8];
$term_so = $term_arr[9];
$term_aktiv = $term_arr[10];
$term_stunde = $term_arr[11];
$term_minute = $term_arr[12];
$term_tag = $term_arr[13];
$term_monat = $term_arr[14];
$term_inhalt = $term_arr[15];
$term_loe = $term_arr[16];
$term_trigger = $term_arr[17];
$term_trigger_para = $term_arr[18];
if($term_aktiv) //wenn aktiver Termin gefunden => prüfen
{
//Timestamp von heute
$heute = mktime (0,0,0,date("m"),date("d"),date("y"));
//Timestamp des Termins aus der for Schleife
$termin_dat = mktime (0,0,0, $term_monat, $term_tag ,date("y"));
//schauen ob Termin auf heute($erg = 0) oder morgen fällt ($erg = -1)
$diff = $heute-$termin_dat;
$erg = $diff/((60*60)*24);
//heutigen Tag ermitteln
$tag = (date("w"));
//wiederkehrende Wöchentliche Termine die auf heute fallen prüfen
if ($tag == 0 and $term_so == 1 or $tag == 1 and $term_mo == 1 or
$tag == 2 and $term_di == 1 or $tag == 3 and $term_mi == 1 or
$tag == 4 and $term_do == 1 or $tag == 5 and $term_fr == 1 or
$tag == 6 and $term_sa == 1)
{
$erg = 0;
$wo = 1;
}
//wiederkehrende Wöchentliche Termine die auf morgen fallen prüfen
if ($tag == 6 and $term_so == 1 or $tag == 0 and $term_mo == 1 or
$tag == 1 and $term_di == 1 or $tag == 2 and $term_mi == 1 or
$tag == 3 and $term_do == 1 or $tag == 4 and $term_fr == 1 or
$tag == 5 and $term_sa == 1)
{
$erg = -1;
$wo = 1;
}
//Termin zur genauen Uhrzeit (Einmalig oder Wöchentlich) => Script ID aufrufen, wenn vorhanden
if($erg == 0 and $hrs == $term_stunde and
$min == $term_minute and $term_jaerlich != true)
{
SetValueString($id_term_aktuell, $term_inhalt); //Variable triggert Sprachausgabe
if((int)$term_trigger != 0 and $terminmodus == 0)
{
IPS_RunScriptEx((int)$term_trigger,array("term_trigger_para" => $term_trigger_para));
}
}
//jährlicher Termin immer um 00:01 => Script ID aufrufen, wenn vorhanden
if ($erg == 0 and $term_jaerlich and $hrs == 00 and $min == 01)
{
if((int)$term_trigger != 0 and $terminmodus == 0)
{
IPS_RunScriptEx((int)$term_trigger,array("term_trigger_para" => $term_trigger_para));
}
}
//automatisches löschen von einmaligen Terminen
if ($erg == 0 and $term_einmalig and $term_loe and $hrs == 23 and $min == 59)
{
unset ($term_arr_komplett[$key]);
$term_neu_komplett = implode("
", $term_arr_komplett); // in String zurück
$handle=fopen($filename, "w");
fwrite($handle,$term_neu_komplett);
fclose($handle);
}
//für die Bereinigung Designer
if($hrs == 23 and $min == 59 or $hrs == 00 and $min == 01 or $terminmodus !=0)
{
if($erg == 0 or $erg == -1)
{
SetValueInteger($id_term_zahl, $term_zahl+1);
$term_zahl = GetValueInteger($id_term_zahl);
if($wo != 1)
{
$term_text = $term_tag.".";
$term_text.= $term_monat.". ";
}
else //wöchentliche Termine heute und morgen
{
if($erg == 0)
{
$term_text = date("d.");
$term_text.= date("m. ");
}
else
{
$term_text = date("d.");
$term_text.= date("m.");
$term_text = strtotime("+1 day", strtotime($term_text));
$term_text = date("d.m. ", $term_text);
}
}
//Formatierung
$term_stunde = sprintf("%02s", $term_stunde);
$term_minute = sprintf("%02s", $term_minute);
if(!$term_jaerlich) $term_text.= $term_stunde.".";
if(!$term_jaerlich) $term_text.= $term_minute." Uhr ";
$term_text.= $term_inhalt;
if($term_zahl == 1)
{
$id = $id_term_anz1_inhalt;
$wf[] = $term_text;
}
if($term_zahl == 2)
{
$id = $id_term_anz2_inhalt;
$wf[] = $term_text;
}
if($term_zahl == 3)
{
$id = $id_term_anz3_inhalt;
$wf[] = $term_text;
}
if($term_zahl == 4)
{
$id = $id_term_anz4_inhalt;
$wf[] = $term_text;
}
if($term_zahl == 5)
{
$id = $id_term_anz5_inhalt;
$wf[] = $term_text;
}
if($term_zahl == 6)
{
$id = $id_term_anz6_inhalt;
$wf[] = $term_text;
}
SetValueString($id, $term_text);
//WebFront Ausgabe
sort($wf);
$term_wf = implode("
", $wf);
SetValueString($id_termine, $term_wf);
//Farbe für Termin heute oder morgen
if($erg == 0) $farbe = 1;
if($erg == -1) $farbe = 2;
if($term_zahl == 1) $id = $id_term_anz1_farbe;
if($term_zahl == 2) $id = $id_term_anz2_farbe;
if($term_zahl == 3) $id = $id_term_anz3_farbe;
if($term_zahl == 4) $id = $id_term_anz4_farbe;
if($term_zahl == 5) $id = $id_term_anz5_farbe;
if($term_zahl == 6) $id = $id_term_anz6_farbe;
SetValueInteger($id, $farbe);
$wo = 0; // falls wiederkehrender Termin, zurücksetzen
}
}
//jährliche Termine ermitteln
if(!isset($year) || empty($year)) $year = date('Y');
$tag = new Feiertag();
$days = $tag->getHolidays($year);
foreach($days as $value)
{
list($key, $value) = each($days);
//Timestamp von heute
$heute = mktime (0,0,0,date("m"),date("d"),date("y"));
//schauen ob Termin auf heute($erg = 0) oder morgen fällt ($erg = -1)
$diff = $heute-$value;
$erg = $diff/((60*60)*24);
//Feiertag gefunden => hier speichern
if ($erg == 0 or $erg == -1)
{
//nur für den Designer
if ($hrs == 23 and $min == 59 or $hrs == 00 and $min == 01 or $terminmodus !=0)
{
SetValueInteger($id_term_zahl, $term_zahl+1);
$term_zahl = GetValueInteger($id_term_zahl);
if($erg == -1)
{
$term_text = date("d.m. ", strtotime("+1 day", strtotime(date('d.m.'))));
}
else
{
$term_text = date("d.m. ");
}
$term_text.= $key;
$farbe = 3;
if($term_zahl == 1) $id = $id_term_anz1_inhalt;
if($term_zahl == 2) $id = $id_term_anz2_inhalt;
if($term_zahl == 3) $id = $id_term_anz3_inhalt;
if($term_zahl == 4) $id = $id_term_anz4_inhalt;
if($term_zahl == 5) $id = $id_term_anz5_inhalt;
if($term_zahl == 6) $id = $id_term_anz6_inhalt;
SetValueString($id, $term_text);
$wf[] = $term_text;
//WebFront Ausgabe
sort($wf);
$term_wf = implode("
", $wf);
SetValueString($id_termine, $term_wf);
if($term_zahl == 1) $id = $id_term_anz1_farbe;
if($term_zahl == 2) $id = $id_term_anz2_farbe;
if($term_zahl == 3) $id = $id_term_anz3_farbe;
if($term_zahl == 4) $id = $id_term_anz4_farbe;
if($term_zahl == 5) $id = $id_term_anz5_farbe;
if($term_zahl == 6) $id = $id_term_anz6_farbe;
SetValueInteger($id, $farbe);
}
}
//Feiertag für die einzelnen Modi vorlesen
Auf ein Update der Terminverwaltung habe ich erstmal verzichtet, weil sonst alle ID´s neu vergeben werden, welche dann im Dashboard alle hätten angepasst werden müssen.