app = $app;
$this->year = date('Y');
if($jahr)$this->year = $jahr;
$this->sql ="";
$this->maxcellcount = 1;
$this->customcellcolor = '#0B8092';
$this->limit ="";
$this->headings[] = '{|Monat|}';
for($i = 1; $i <= 31; $i++)$this->headings[] = $i;
$this->monatheading = array(1=>'{|Januar|}',2=>'{|Februar|}',3=>'{|März|}',4=>'{|April|}',5=>'{|Mai|}',6=>'{|Juni|}',7=>'{|Juli|}',8=>'{|August|}',9=>'{|September|}',10=>'{|Oktober|}',11=>'{|November|}',12=>'{|Dezember|}');
}
function AddHolidays($holidays){
$this->holidays = $holidays;
}
function AddCell($datum, $el)
{
$datumu = strtotime($datum);
$jahr = (int)date('Y',$datumu);
$tag = (int)date('d',$datumu);
$monat = (int)date('m',$datumu);
$this->cells[$jahr][$monat][$tag][] = $el;
}
function AddOnCellClick($datum, $js)
{
$datumu = strtotime($datum);
$jahr = (int)date('Y',$datumu);
$tag = (int)date('d',$datumu);
$monat = (int)date('m',$datumu);
$this->js[$jahr][$monat][$tag] = $js;
}
function AddCellTitle($datum, $title)
{
$datumu = strtotime($datum);
$jahr = (int)date('Y',$datumu);
$tag = (int)date('d',$datumu);
$monat = (int)date('m',$datumu);
$this->title[$jahr][$monat][$tag] = $title;
}
function Display($parsetarget,$clickmodule="",$clickaction="",$clicklabel="",$newevent="")
{
$htmltable = new HTMLTable(0,"100%","",3,1);
$htmltable->width_headings = $this->width_headings;
$htmltable->AddRowAsHeading($this->headings);
$htmltable->ChangingRowColors('#eee','#eee');
for($monat = 1; $monat <= 12 ; $monat++)
{
$htmltable->NewRow();
if(isset($row))unset($row);
$field = $this->monatheading[$monat];
if(!empty($this->additionalMonthInfo)){
if(isset($this->additionalMonthInfo[$monat])){
$field = '
'.$field.' |
';
foreach($this->additionalMonthInfo[$monat] as $member){
$field.=''.$member.' |
';
}
$field .='
';
}
else{
$field = '';
}
}
$htmltable->AddCellClass('monat');
$htmltable->AddCol($field);
for($tag = 1; $tag <= 31; $tag++)
{
$css = 'standard';
if(checkdate($monat , $tag , $this->year ))
{
$kalenderTag = date('w', mktime(0,0,0,$monat,$tag,$this->year));
if ($kalenderTag == 0 || $kalenderTag == 6) {
$css = 'wochenende';
}
} else {
$css = 'keintag';
}
if(!empty($this->holidays)){
$curDate = $this->year.'-'.($monat<10?'0'.$monat:$monat).'-'.($tag<10?'0'.$tag:$tag);
if(array_key_exists($curDate,$this->holidays)){
$css = 'feiertag';
}
}
if(is_array($this->cells) && isset($this->cells[$this->year]) && isset($this->cells[$this->year][$monat]) && isset($this->cells[$this->year][$monat][$tag]) && is_array($this->cells[$this->year][$monat][$tag]))
{
$anz = count($this->cells[$this->year][$monat][$tag]);
if($this->maxcellcount > 0)
{
if($anz < 1)
{
$field = '';
}elseif($anz == 1){
$field = $this->cells[$this->year][$monat][$tag][0];
}elseif($anz <= $this->maxcellcount) {
$zelle = '';
foreach($this->cells[$this->year][$monat][$tag] as $value)
{
$zelle .= ''.$value.' |
';
}
$zelle .= '
';
$field = $zelle;
} else {
$zelle = '';
for($i = 0; $i < $this->maxcellcount; $i++)
{
$zelle .= ''.$this->cells[$this->year][$monat][$tag][$i].' |
';
}
$zelle .= '
';
$field = $zelle;
}
} else {
if($anz)
{
$field = ''.$anz.'';
$css = 'custom';
}
}
} else
{
$field = '';
}
if($css)$htmltable->AddCellClass($css);
if($css == 'standard'){
$htmltable->AddCustomAttributes(['data-day'=>$tag,'data-month'=>$monat,'data-year'=>$this->year]);
}
if(isset($this->js[$this->year][$monat][$tag]) && $this->js[$this->year][$monat][$tag])$htmltable->AddCellonclick($this->js[$this->year][$monat][$tag]);
if(isset($this->title[$this->year][$monat][$tag]) && $this->title[$this->year][$monat][$tag])$htmltable->AddCellTitle($this->title[$this->year][$monat][$tag]);
$htmltable->AddCol($field);
}
}
$this->app->Tpl->Add($parsetarget,'');
$this->app->Tpl->Add($parsetarget,$htmltable->Get());
$this->app->Tpl->Add($parsetarget,'
');
}
}
?>