--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/fhiiqm/test/date_mod.php Wed Aug 31 14:22:19 2011 +0200
@@ -0,0 +1,67 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
+ <link href="../css/db.css" rel="STYLESHEET" type="TEXT/CSS" />
+ <meta name="author" content="Bettina Schwarzer" />
+
+ <title>Test Vertragsablauf</title>
+</head>
+
+<body>
+<h3> Übersicht Vertragsende</h3>
+<?php
+
+/**
+ * @author Bettina Schwarzer
+ * @copyright 2011
+ *
+ * Berechnung von Datum-Werten
+ * SQL: SELECT *,DATEDIFF(contract_end,DATE_ADD(CURDATE(),INTERVAL 7 DAY)) AS days FROM `fhiiqm`.`Vertrag`
+
+ */
+
+
+ include_once($_SERVER['DOCUMENT_ROOT'] ."/fhiiqm/inc/dbconnect.inc.php");
+ if (!isset($dbc) || !$dbc) $dbc = new dbconnection();
+
+ $sql = "SELECT contract_ID, contract_name, contract_begin, contract_end FROM Vertrag ORDER BY 2";
+ if ($result = $dbc ->queryObjectArray($sql))
+ {
+ $now = new DateTime; // heute
+ $now = $now->add(new DateInterval('P7D')); //7 Tage zu heute addieren
+ echo " 'heute' + 7 Tage = " . $now->format('d.m.Y') ."<br />";
+
+ foreach ($result as $row)
+ {
+ if (isset($row->contract_end) && $row->contract_end)
+ {
+ $cend = new DateTime($row->contract_end);
+ // list($year,$month,$day) = explode($row->contract_end,"-");
+ // $cend = $cend -> setDate($year,$month,$day);
+ $diff = $cend -> diff($now);
+ // $diff1 = $now -> diff($cend); // $diff = $diff1
+ // print_r($diff);
+ if ($cend <= $now && $diff->format('%a') < 8)
+ echo "<p class='red'> Vertrag <b>$row->contract_name</b> endet in <b> ". (7 - $diff->format('%a')) . "</b> Tagen!</p>\n";
+ elseif ($cend > $now && $diff->format('%a') < 8)
+ echo "<p class='red'> Vertrag <b>$row->contract_name</b> endet in <b> ". $diff->format('%a') . "</b> Tagen!</p>\n";
+ elseif ($cend > $now)
+ {
+ if ($diff->format('%a') > 365-7)
+ echo "<p> Vertrag <b>$row->contract_name</b> läuft noch länger als ein Jahr. </p>\n";
+ else
+ echo "<p> Vertrag <b>$row->contract_name</b> endet erst in " . ($diff->format('%a') + 7) . " Tagen.</p>\n";
+ }
+ else
+ echo "<p> Vertrag <b>$row->contract_name</b> ist bereits ausgelaufen.</p>\n";
+ }
+ else
+ echo "<p> kein Endedatum für <b>$row->contract_name</b> angegeben!</p>\n";
+
+ }
+ }
+?>
+</body>
+</html>
\ No newline at end of file