コード例 #1
0
/**
 * get html formatted content for birthdaylist
 * 
 * @param string $desc; title for list?
 * @param int $diff_from; age?
 * @param int $diff_to; age?
 * @param bool $extended; show extended list?
 * @return string; html
 */
function getBirthdaylistContent($desc, $diff_from, $diff_to, $extended = false)
{
    global $base_url, $files_dir;
    $txt = "";
    $compact = false;
    if (isset($_GET["compact"])) {
        $compact = true;
    }
    if ($extended && !user_access("view birthdaylist", "churchdb")) {
        die(t("no.permission.for", "view birthdaylist"));
    }
    //TODO: replace arg with translated name of view birthdaylist
    include_once "churchdb_db.php";
    $see_details = user_access("view", "churchdb") && user_access("view alldata", "churchdb");
    $res = getBirthdayList($diff_from, $diff_to);
    if ($res) {
        if ($desc) {
            $txt .= "<p><h4>{$desc}</h4>";
        }
        if ($extended) {
            $txt .= "<table class=\"table table-condensed\"><tr><th style=\"max-width:65px;\"><th>" . t("name") . (!$compact ? "<th>" . t("age") : "") . "<th>" . t("birthday");
            if ($see_details) {
                //TODO: I would prefer to use closing tags
                $txt .= "<th>" . t("status") . "<th>" . t("station") . "<th>" . t("department");
            }
        }
        foreach ($res as $arr) {
            //if ($extended)
            $txt .= "<tr><td>";
            // Add 1 to age, so we know the number of the next birthday :-)
            if ($diff_from > 0) {
                $arr->age = $arr->age + 1;
            }
            // link to access person on churchDB
            if ($extended) {
                if ($arr->imageurl == null) {
                    $arr->imageurl = "nobody.gif";
                }
                $txt .= "<img class=\"\" width=\"42px\" style=\"max-width:42px;\" src=\"{$base_url}{$files_dir}/fotos/" . $arr->imageurl . "\"/>";
                $txt .= "<td>";
                if ($see_details) {
                    $txt .= "<a data-person-id=\"{$arr->person_id}\" href=\"{$base_url}?q=churchdb#PersonView/searchEntry:#" . $arr->person_id . "\">";
                }
                $txt .= $arr->vorname . " ";
                if (isset($arr->spitzname) && $arr->spitzname != "") {
                    $txt .= "({$arr->spitzname}) ";
                }
                $txt .= $arr->name . (!$compact ? "<td> " . $arr->age : "") . "<td>" . (!$compact ? $arr->geburtsdatum_d : $arr->geburtsdatum_compact);
                if ($see_details) {
                    $txt .= " <td> " . $arr->status . "<td>" . $arr->bezeichnung . "<td>" . $arr->bereich;
                }
            } else {
                if ($arr->imageurl == null) {
                    $arr->imageurl = "nobody.gif";
                }
                if ($see_details) {
                    $txt .= "<a data-person-id=\"{$arr->person_id}\" href=\"{$base_url}?q=churchdb#PersonView/searchEntry:#" . $arr->person_id . "\">";
                }
                $txt .= "<img class=\"\" width=\"42px\" style=\"max-width:42px;\" src=\"{$base_url}{$files_dir}/fotos/" . $arr->imageurl . "\"/>";
                if ($see_details) {
                    $txt .= "</a>";
                }
                $txt .= "<td>";
                if ($see_details) {
                    $txt .= "<a class=\"tooltip-person\" data-id=\"{$arr->person_id}\" href=\"{$base_url}?q=churchdb#PersonView/searchEntry:#" . $arr->person_id . "\">";
                }
                $txt .= $arr->vorname . " ";
                if (isset($arr->spitzname) && $arr->spitzname != "") {
                    $txt .= "({$arr->spitzname}) ";
                }
                $txt .= $arr->name;
                if ($see_details) {
                    $txt .= "</a>";
                }
                if ($see_details) {
                    $txt .= "<td>" . $arr->age . "";
                }
            }
        }
        if ($extended) {
            $txt .= "</table><p>&nbsp;</p>";
        }
    }
    //}
    return $txt;
}
コード例 #2
0
ファイル: churchdb.php プロジェクト: toXel/churchtools_basic
/**
 * get html formatted content for birthdaylist
 *
 * @param string $desc; title for list?
 * @param int $diff_from; age?
 * @param int $diff_to; age?
 * @param bool $extended; show extended list?
 *
 * @return string; html
 */
function getBirthdaylistContent($desc, $diff_from, $diff_to, $extended = false)
{
    global $base_url, $files_dir;
    $txt = "";
    $compact = getVar('compact');
    if ($extended && !user_access("view birthdaylist", "churchdb")) {
        die(t("no.permission.for", "view birthdaylist"));
        // TODO: use exception?
    }
    include_once "churchdb_db.php";
    $see_details = user_access("view", "churchdb") && user_access("view alldata", "churchdb");
    $res = getBirthdayList($diff_from, $diff_to);
    if ($res) {
        if ($desc) {
            $txt .= "<p><h4>{$desc}</h4>";
        }
        if ($extended) {
            $txt .= "<table class='table table-condensed'><tr><th style='max-width:65px;'><th>" . t("name") . (!$compact ? "<th>" . t("age") : "") . "<th>" . t("birthday");
            // TODO: I would prefer to use closing tags
            // TODO: use template
            if ($see_details) {
                $txt .= "<th>" . t("status") . "<th>" . t("station") . "<th>" . t("department");
            }
        }
        foreach ($res as $arr) {
            // if ($extended)
            $txt .= "<tr><td>";
            // Add 1 to age, so we know the number of the next birthday :-)
            if ($diff_from > 0) {
                $arr->age = $arr->age + 1;
            }
            // link to access person on churchDB
            if ($extended) {
                if (!$arr->imageurl) {
                    $arr->imageurl = "nobody.gif";
                }
                $txt .= "<img class='' width='42px' style='max-width:42px;' src='{$base_url}{$files_dir}/fotos/" . $arr->imageurl . "'/>";
                $txt .= "<td>";
                if ($see_details) {
                    $txt .= "<a data-person-id='{$arr->person_id}' href='{$base_url}?q=churchdb#PersonView/searchEntry:#" . $arr->person_id . "'>";
                }
                $txt .= $arr->vorname . " ";
                if (!empty($arr->spitzname)) {
                    $txt .= "({$arr->spitzname}) ";
                }
                $txt .= $arr->name . (!$compact ? "<td> " . $arr->age : "") . "<td>" . (!$compact ? $arr->geburtsdatum_d : $arr->geburtsdatum_compact);
                if ($see_details) {
                    $txt .= " <td> " . $arr->status . "<td>" . $arr->bezeichnung . "<td>" . $arr->bereich;
                }
            } else {
                if (!$arr->imageurl) {
                    $arr->imageurl = "nobody.gif";
                }
                if ($see_details) {
                    $txt .= "<a data-person-id='{$arr->person_id}' href='{$base_url}?q=churchdb#PersonView/searchEntry:#" . $arr->person_id . "'>";
                }
                $txt .= "<img class='' width='42px' style='max-width:42px;' src='{$base_url}{$files_dir}/fotos/" . $arr->imageurl . "'/>";
                if ($see_details) {
                    $txt .= "</a>";
                }
                $txt .= "<td>";
                if ($see_details) {
                    $txt .= "<a class='tooltip-person' data-id='{$arr->person_id}' href='{$base_url}?q=churchdb#PersonView/searchEntry:#" . $arr->person_id . "'>";
                }
                $txt .= $arr->vorname . " ";
                if (!empty($arr->spitzname)) {
                    $txt .= "({$arr->spitzname}) ";
                }
                $txt .= $arr->name;
                if ($see_details) {
                    $txt .= "</a>";
                }
                if ($see_details) {
                    $txt .= "<td>" . $arr->age . "";
                }
            }
        }
        if ($extended) {
            $txt .= "</table><p>&nbsp;</p>";
        }
    }
    return $txt;
}