loadUserAmpel($user); $rot = 0; $gelb = 0; $gruen = 0; $verpflichtend = false; $cnt_verpflichtend = 0; $cnt_abgelaufen = 0; $cnt_notConf_notOverdue = 0; //counts mandatory, not confirmed && not overdued ampeln (for popup) $datum = new datum(); $now = $datum->mktime_fromdate(date('Y-m-d')); foreach ($ampel->result as $row) { $deadline = $datum->mktime_fromdate($row->deadline); $vorlaufzeit = $row->vorlaufzeit; $verfallszeit = $row->verfallszeit; $bestaetigt = $ampel->isBestaetigt($user, $row->ampel_id); $verpflichtend = $row->verpflichtend; $abgelaufen = false; $datum_liegt_vor_vorlaufzeit = false; $datum_liegt_nach_verfallszeit = false; if (!is_null($vorlaufzeit)) { $datum_liegt_vor_vorlaufzeit = $now < strtotime('-'.$vorlaufzeit.' day', $deadline); } if (!is_null($verfallszeit)) { $datum_liegt_nach_verfallszeit = $now > strtotime('+'.$verfallszeit.' day', $deadline); } //count mandatory if ($verpflichtend == 't') { $cnt_verpflichtend++; } //count overdue if ($datum_liegt_nach_verfallszeit) { $cnt_abgelaufen++; } //set status if ($bestaetigt) { $gruen++; } else { if ($now >= $deadline && !$datum_liegt_nach_verfallszeit && !$bestaetigt) { $rot++; } else { if (!$datum_liegt_nach_verfallszeit && !$datum_liegt_vor_vorlaufzeit) { $gelb++; } } } //count mandatory ampeln that are not confirmed and not overdue (for popup) if ($verpflichtend == 't' && !$bestaetigt && !$datum_liegt_nach_verfallszeit && !$datum_liegt_vor_vorlaufzeit) { $cnt_notConf_notOverdue++; } } //if at least ONE mandatory notification, which is not overdue -> trigger notification-POPUP if ($cnt_notConf_notOverdue > 0) { echo ' '; echo ' '; } //show & color header ampel-link if ($rot > 0) { echo ''.$p->t("tools/ampelsystem").' | '; } elseif ($gelb > 0) { echo ''.$p->t("tools/ampelsystem").' | '; } elseif ($rot == 0 || $rot <= $cnt_abgelaufen && $gelb == 0) { echo ''.$p->t("tools/ampelsystem").' | '; } } else { echo ""; } ?>