<?php

################################################
## Robert Schrenk, 2007, phPIMap              ##
## This code is distributed under the GNU/GPL ##
################################################
if (phPIMap != "ok") {
    die("Direct access to this location is not allowed");
}
$id = RetrieveVar("id", "0111");
$item = $GLOBALS["restree"]["todo"][$id];
if ($id == "" or $item == "") {
    append("<h1>Anstehende Aufgaben</h1>");
    $selection = $GLOBALS["restree"]["todo"];
    //$selection = filterResources($GLOBALS["restree"]["todo"],"due",TimeStamp(0),">",null);
    $selection = sortResources($selection, null, "due", "ASC");
    for ($i = 0; $i < count($selection); $i++) {
        $item = $selection[$i];
        append("<li><a href=\"?module=todo&id=" . $item[internalid] . "\">" . $item["summary"] . "</a></li>");
    }
} else {
    $tpl = file_get_contents(designroot . "/display/item.todo.html");
    $tpl = replaceFields($tpl, "todo", $item);
    append($tpl);
}
        verbose("Orientiert an Timestamp: " . $time . ", Woche ist " . $GLOBALS["calendar"]["week"]);
        verbose("Woche geht von " . $GLOBALS["calendar"]["start"] . " bis " . $GLOBALS["calendar"]["end"]);
        break;
    case "day":
        $GLOBALS["calendar"]["start"] = date("YmdHis", mktime(0, 0, 0, date("m", $time), date("d", $time), date("Y", $time)));
        $GLOBALS["calendar"]["end"] = date("YmdHis", mktime(23, 59, 59, date("m", $time), date("d", $time), date("Y", $time)));
        break;
}
$selection = $GLOBALS["restree"]["calendar"];
$selection1 = filterResources($selection, "to", $GLOBALS["calendar"]["start"], ">=", null);
$selection1x = filterResources($selection1, "to", $GLOBALS["calendar"]["end"], "<=", null);
$selection2 = filterResources($selection, "from", $GLOBALS["calendar"]["end"], "<=", null);
$selection2x = filterResources($selection2, "from", $GLOBALS["calendar"]["start"], ">=", null);
$selection = mergeSelections($selection1x, $selection2x);
//$selection = intersectSelections($selection1x,$selection2x);
$selection = sortResources($selection, null, "from", "ASC");
switch ($_SESSION["calrange"]) {
    case "month":
        for ($i = 0; $i < count($selection); $i++) {
            $hasevent[date("j", TimeStamp2Time($selection[$i]["from"]))] = true;
        }
        append("<table border=\"1\" width=\"100%\" height=\"100%\">\n");
        append("     <tr height=\"40\">\n");
        append("          <td colspan=\"8\"><h1>Termine im Monat " . date("M", $time) . "</h1></td>");
        append("     </tr>\n");
        append("     <tr height=\"25\">\n");
        append("          <td>&nbsp;</td>\n");
        append("          <td><a href=\"?module=calendar&calorientation=" . $prevyear . "\">&lt;&lt;</a></td>\n");
        append("          <td><a href=\"?module=calendar&calorientation=" . $prevmonth . "\">&lt;</a></td>\n");
        append("          <td colspan=\"3\">\n" . "               <a href=\"?module=calendar&calrange=month\">\n" . $GLOBALS["calendar"]["month"] . " " . date("M", $time) . "</a>\n" . "          </td>\n");
        append("          <td><a href=\"?module=calendar&calorientation=" . $nextmonth . "\">&gt;</a></td>\n");
<?php

################################################
## Robert Schrenk, 2007, phPIMap              ##
## This code is distributed under the GNU/GPL ##
################################################
if (phPIMap != "ok") {
    die("Direct access to this location is not allowed");
}
$selection = sortResources($GLOBALS["restree"]["contact"], null, "surname", "ASC");
for ($i = 0; $i < count($selection); $i++) {
    $item = $selection[$i];
    append("<div><a href=\"?module=contact&id=" . $item[internalid] . "\" " . "onclick=\"return AjaxGet(getElement('details'),'?module=contact&" . "id=" . $item[internalid] . "&ajax=1',null,'highlight');\">\n                <div style=\"width: 49%;\">" . $item["surname"] . "</div>\n               <div style=\"width: 50%;\">" . $item["firstname"] . "</div>\n             </a></div>");
}
/*
for($i=0;$i<count($GLOBALS["restree"]["contact"]);$i++)
     append("<div><div style=\"width: 49%;\">".$GLOBALS["restree"]["contact"][$i]["surname"]."</div><div style=\"width: 50%;\">".$GLOBALS["restree"]["contact"][$i]["firstname"]."</div></div>");
*/