Esempio n. 1
0
 /**
  * Returns the html output if login failed or redirects to patients if login was successful.
  *
  * @return string Html output.
  */
 public function getOutput()
 {
     $attempt = isset($_POST['username']) && isset($_POST['password']);
     $success = false;
     if ($attempt) {
         $success = $this->validateLogin();
     }
     $tpl = new \template("login/login");
     if ($attempt) {
         if ($success) {
             $_SESSION['login'] = new \DateTime();
             $_SESSION['user'] = $_POST['username'];
             $_SESSION['userId'] = \dbConn::querySingle("SELECT userId FROM :prefix:user WHERE email = :0", $_POST['username']);
             $_SESSION['isAdmin'] = $this->isAdmin();
             $_SESSION['username'] = \dbConn::querySingle("SELECT CONCAT(CONCAT(firstname, ' '), lastname) AS name \n                                                                FROM :prefix:user WHERE email = :0", $_POST['username']);
             if ($_SESSION['isAdmin']) {
                 header("location: " . ROOT . "patients");
             } else {
                 header("location: " . ROOT . "mypatients");
             }
             die;
         } else {
             $tpl->insert("result", new \template("login/failed"));
         }
     }
     return $tpl->getOutput();
 }
Esempio n. 2
0
function load_template($config, $node)
{
    if ($node) {
        $template = new template($node['@src'], args::decode($node->attribute('args', '')), $node->attribute('xml'));
        foreach ($config->query('template', $node) as $child) {
            $template->insert($child['@name'], load_template($config, $child));
        }
        return $template;
    } else {
        return null;
    }
}
Esempio n. 3
0
 public function getOutput()
 {
     $tpl = new \template("mypatients/container");
     // user data
     $user = \dbConn::queryRow("SELECT userid, firstname, lastname, rfid, email, state \n                                    FROM :prefix:user WHERE userId = :0", $_SESSION['userId']);
     $tpl->insert("firstname", $user['firstname']);
     $tpl->insert("lastname", $user['lastname']);
     $tpl->insert("userid", $user['userid']);
     $tpl->insert("rfid", $user['rfid']);
     $tpl->insert("email", $user['email']);
     foreach (\dbConn::query("SELECT * FROM :prefix:user_state") as $r) {
         $tpl->insert("states", $r['name'] == $user['state'] ? "<option value=\"{$r['name']}\" selected>{$r['display']}</option>" : "<option value=\"{$r['name']}\">{$r['display']}</option>");
     }
     // insert patients
     $hasPatients = false;
     $visit = null;
     foreach (\dbConn::query("\n                                    SELECT firstname, lastname, patientId\n                                    FROM :prefix:visit AS v\n                                    INNER JOIN :prefix:patient AS p\n                                    ON v.patient = p.patientId\n                                    WHERE user = :0\n                                    ORDER BY firstname", $_SESSION['userId']) as $r) {
         $tpl->insert("patients", "<option value=\"{$r['patientId']}\">{$r['firstname']} {$r['lastname']}</option>");
         if (!$hasPatients) {
             $visit = \dbConn::queryRow("SELECT * FROM :prefix:visit WHERE user = :0 AND patient = :1", $_SESSION['userId'], $r['patientId']);
         }
         $hasPatients = true;
     }
     $visitTpl = new \template("visitors/edit.visit");
     // relation
     foreach (\dbConn::query("SELECT * FROM :prefix:relation ORDER BY name ASC") as $r) {
         $visitTpl->insert("relations", "<option value=\"{$r['name']}\"" . ($r['name'] == $visit['relation'] ? " selected" : "") . ">{$r['name']}</option>");
     }
     // description
     $visitTpl->insert("description", $visit['description']);
     // scent
     foreach (\dbConn::query("SELECT * FROM :prefix:scent ORDER BY name ASC") as $r) {
         $visitTpl->insert("scents", "<option value=\"{$r['name']}\"" . ($r['name'] == $visit['scent'] ? " selected" : "") . ">{$r['name']}</option>");
     }
     // images
     $imgCount = 0;
     foreach (\dbConn::query("SELECT * FROM :prefix:visit_media WHERE visitId = :0 AND type = :1", $visit['visitId'], 'Image') as $img) {
         $visitTpl->insert("image" . ($imgCount + 1), ROOT . "media/image/" . $img['path']);
         $imgCount++;
     }
     for ($i = $imgCount + 1; $i <= 3; $i++) {
         $visitTpl->insert("image" . $i, ROOT . "images/icons/image.png");
     }
     // audios
     $audioCount = 0;
     foreach (\dbConn::query("SELECT * FROM :prefix:visit_media WHERE visitId = :0 AND type = :1", $visit['visitId'], 'Audio') as $audio) {
         $visitTpl->insert("audio" . ($audioCount + 1), ROOT . "images/icons/audio.png");
         $audioCount++;
     }
     for ($i = $audioCount + 1; $i <= 3; $i++) {
         $visitTpl->insert("audio" . $i, ROOT . "images/icons/plus.png");
     }
     $tpl->insert("visit", $visitTpl->getOutput());
     return $tpl->getOutput();
 }
Esempio n. 4
0
function getHistory($limit)
{
    if (!isset($limit) || $limit == 0 || $limit == null || !is_numeric($limit)) {
        $limit = 9999999;
    }
    $changes = new template("admin/lastchanges.container");
    foreach (dbConn::query("SELECT\n                                action, \n                                nameBefore, \n                                nameAfter, \n                                emailBefore, \n                                emailAfter, \n                                production, \n                                fromDate,\n                                toDate,\n                                mvoe_plan.name AS plan, \n                                mvoe_worker_history.created\n                            FROM :prefix:worker_history \n                            INNER JOIN :prefix:shift ON :prefix:shift.shiftId = :prefix:worker_history.shift\n                            INNER JOIN :prefix:plan ON :prefix:shift.plan = :prefix:plan.name\n                            ORDER BY :prefix:worker_history.created DESC LIMIT 0, " . $limit) as $r) {
        $change = new template("admin/lastchanges.entry");
        switch ($r['action']) {
            case "insert":
                $change->insert("action", "<span style=\"color:green;\"><small>\n                                            <i class=\"fa fa-plus-square\"></i>\n                                           </small></span>&nbsp;&nbsp;Hinzugefügt");
                break;
            case "update":
                $change->insert("action", "<span style=\"color:orange;\"><small>\n                                            <i class=\"fa fa-minus-square\"></i>\n                                           </small></span>&nbsp;&nbsp;Bearbeitet");
                break;
            case "delete":
                $change->insert("action", "<span style=\"color:red;\">\n                                            <small><i class=\"fa fa-trash\"></i>\n                                           </small></span>&nbsp;&nbsp;Gelöscht");
                break;
            default:
                $change->insert("action", "Unbekannt");
                break;
        }
        $change->insert("shift", "<small>{$r['plan']}, {$r['production']}</small><br />" . substr($r['fromDate'], 0, 5) . " - " . substr($r['toDate'], 0, 5));
        if ($r['nameBefore'] == $r['nameAfter']) {
            $change->insert("user", $r['nameAfter']);
        } else {
            $change->insert("user", "<small><span style=\"text-decoration:line-through;\">{$r['nameBefore']}</span></small>\n            <br /><strong>{$r['nameAfter']}</strong>");
        }
        if ($r['emailBefore'] == $r['emailAfter']) {
            $change->insert("email", $r['emailAfter']);
        } else {
            $change->insert("email", "<small><span style=\"text-decoration:line-through;\">{$r['emailBefore']}</span></small>\n            <br /><strong>{$r['emailAfter']}</strong>");
        }
        $change->insert("date", (new DateTime($r['created']))->format("d.m.y H:i"));
        $changes->insert("content", $change->getOutput());
    }
    $changes->removeVariables();
    return $changes->getOutput();
}
Esempio n. 5
0
 public static function getOutput($par)
 {
     $nav = new template("navigation/container");
     $public = !isset($_SESSION['user']);
     foreach (dbConn::query("SELECT * FROM :prefix:navigation WHERE parent IS NULL AND public = :0 ORDER BY position", $public) as $r) {
         if ($r['admin'] && !$_SESSION['isAdmin']) {
             continue;
         }
         $link = new template("navigation/layer1");
         $link->insert("caption", htmlspecialchars($r['caption']));
         $link->insert("destination", ROOT . $r['destination'] . "/");
         $requestUri = $_SERVER['REQUEST_URI'];
         if (navigation::startsWith($_SERVER['REQUEST_URI'], ROOT)) {
             $requestUri = urldecode(substr($_SERVER['REQUEST_URI'], strlen(ROOT)));
         }
         // check active
         //$link->insert("active", $requestUri == $r['destination'] ? "active" : "");
         $link->insert("active", navigation::startsWith($requestUri, $r['destination']) ? "active" : "");
         foreach (dbConn::query("SELECT * FROM :prefix:navigation WHERE parent = :0 ORDER BY position", $r['linkId']) as $s) {
             $sublink = new template("navigation/layer2");
             $sublink->insert("caption", htmlspecialchars($s['caption']));
             $sublink->insert("destination", ROOT . $s['destination'] . "/");
             $requestUri = $_SERVER['REQUEST_URI'];
             if ($requestUri[strlen($requestUri) - 1] == "/") {
                 $requestUri = substr($requestUri, 0, strlen($requestUri) - 1);
             }
             if (navigation::startsWith($requestUri, ROOT)) {
                 $requestUri = substr($requestUri, strlen(ROOT), strlen($requestUri) - strlen(ROOT));
             }
             $sublink->insert("active", $requestUri == $s['destination'] ? "active" : "");
             $link->insert("links", $sublink->getOutput());
         }
         $nav->insert("links", $link->getOutput());
     }
     return $nav->getOutput();
 }
Esempio n. 6
0
 /**
  * Gets the html output and handles form inputs.
  *
  * @return string Html output.
  */
 public function getOutput()
 {
     switch ($this->viewpoint) {
         // ######################################################################################################
         case "overview":
             $tpl = new \template("patients/container");
             $query = "";
             if ($_SESSION['isAdmin']) {
                 $query = "SELECT \n                                patientId,\n                                firstname, \n                                lastname,\n                                room\n                            FROM :prefix:patient\n                            ORDER BY lastname ASC";
             } else {
                 $query = "SELECT \n                                patientId,\n                                firstname, \n                                lastname,\n                                room\n                            FROM :prefix:patient\n                            WHERE patientId IN (SELECT patientId FROM :prefix:visit WHERE user = "******")\n                            ORDER BY lastname ASC";
             }
             foreach (\dbConn::query($query) as $r) {
                 $p = new \template("patients/patient");
                 $p->insert("id", $r['patientId']);
                 $p->insert("firstname", $r['firstname']);
                 $p->insert("lastname", $r['lastname']);
                 $p->insert("room", $r['room']);
                 $p->insert("visitorcount", \dbConn::querySingle("SELECT COUNT(*) FROM :prefix:visit WHERE patient = :0", $r['patientId']));
                 $p->insert("destination", ROOT . "patients" . "/" . $r['patientId']);
                 $tpl->insert("patients", $p);
             }
             return $tpl->getOutput();
             break;
             // ######################################################################################################
         // ######################################################################################################
         case "edit":
             $result = null;
             $tpl = new \template("patients/edit");
             $tpl->insert("id", $_GET['par2']);
             if (isset($_POST['save'])) {
                 $error = "";
                 if (!$this->saveChanges($error)) {
                     $result = new \template("alerts/danger");
                     $result->insert("caption", "Fehler");
                     $result->insert("text", $error);
                     $tpl->insert("firstname", $_POST['firstname']);
                     $tpl->insert("lastname", $_POST['lastname']);
                     $tpl->insert("room", $_POST['room']);
                     $tpl->insert("birthday", (new \DateTime($_POST['birthday']))->format("d.m.Y"));
                 } else {
                     $result = new \template("alerts/success");
                     $result->insert("caption", "Erfolgreich");
                     $result->insert("text", "Änderungen wurden erfolgreich gespeichert.");
                 }
             }
             $data = \dbConn::queryRow("SELECT * FROM :prefix:patient WHERE patientId = :0", $_GET['par2']);
             if (isset($result)) {
                 $tpl->insert("result", $result);
                 if ($error == "") {
                     $tpl->insert("firstname", $data['firstname']);
                     $tpl->insert("lastname", $data['lastname']);
                     $tpl->insert("room", $data['room']);
                     $tpl->insert("birthday", (new \DateTime($data['birth']))->format("d.m.Y"));
                 }
             } else {
                 $tpl->insert("firstname", $data['firstname']);
                 $tpl->insert("lastname", $data['lastname']);
                 $tpl->insert("room", $data['room']);
                 $tpl->insert("birthday", (new \DateTime($data['birth']))->format("d.m.Y"));
             }
             foreach (\dbConn::query("\n                    SELECT firstname, lastname\n                    FROM :prefix:visit AS v\n                    INNER JOIN :prefix:user AS u\n                    ON v.user = u.userId\n                    WHERE v.patient = :0\n                ", $_GET['par2']) as $r) {
                 $tpl->insert("visitors", "<option>" . $r['firstname'] . " " . $r['lastname'] . "</option>");
             }
             return $tpl->getOutput();
             break;
             // ######################################################################################################
         // ######################################################################################################
         case "new":
             if (!$_SESSION['isAdmin']) {
                 return "<h1>Zugriff verweigert</h1>";
             }
             $tpl = new \template("patients/new");
             return $tpl->getOutput();
             break;
     }
 }
Esempio n. 7
0
<?php

require "../config.php";
function validateDate($date)
{
    $d = DateTime::createFromFormat('d.m.Y', $date);
    return $d && $d->format('d.m.Y') == $date;
}
if (!isset($_POST['name']) || strlen($_POST['name']) < 1) {
    die("Bitte geben Sie einen gültigen Namen ein.");
}
if (dbConn::querySingle("SELECT COUNT(*) FROM :prefix:plan WHERE name = :0", $_POST['name']) > 0) {
    die("Der eingegebene Name ist schon vergeben.");
}
if (!isset($_POST['public']) || !validateDate($_POST['public']) || !isset($_POST['editable']) || !validateDate($_POST['editable'])) {
    die("Bitte geben Sie ein gültiges Datum ein.");
}
dbConn::execute("INSERT INTO :prefix:plan (name, public, editable) VALUES (:0, :1, :2);", htmlspecialchars($_POST['name']), $_POST['public'], $_POST['editable']);
$tpl = new template("admin/nav.plan");
$tpl->insert("active", "");
$tpl->insert("name", htmlspecialchars($_POST['name']));
echo "SUCCESS" . $tpl->getOutput();
Esempio n. 8
0
                foreach (dbConn::query("SELECT * FROM :prefix:production_shift WHERE production = :0 AND shift = :1", $prod, $shiftId) as $r) {
                    $required = $r['required'];
                    $has = true;
                }
                $prodShift = new template("production_shift");
                $prodShift->insert("shiftId", $shiftId);
                $prodShift->insert("disabled", $has ? "" : "shift-disabled");
                $prodShift->insert("unique", seoUrl("{$plan}-{$prod}-" . substr(str_replace(":00-", " - ", $sh), 0, 13)));
                if ($has) {
                    // fill required number of workers, name
                    $prodShift->insert("required", $required);
                    $prodShift->insert("name", $prod);
                    // get workers of one shift in one production
                    foreach (dbConn::query("SELECT * FROM :prefix:worker WHERE production = :0 AND shift = :1", $prod, $shiftId) as $r) {
                        $worker = new template("worker");
                        $worker->insert("name", $r['name']);
                        $worker->insert("email", $r['email']);
                        $prodShift->insert("workers", $worker->getOutput());
                    }
                }
                $t->insert("shift_productions", $prodShift->getOutput());
            }
            $planTpl->insert("shifts", $t->getOutput());
        }
        $tabContent->insert("desktop", $planTpl->getOutput());
    }
    $tpl->insert("plansContent", $tabContent->getOutput());
}
// insert page request duration
$diff = microtime() - $start;
$diff = round($diff * 1000);
Esempio n. 9
0
<?php

require "../config.php";
require "../functions.php";
$tpl = new template("admin/index");
$tpl->insert("homeActive", isset($_GET['v']) ? "" : "active");
// plans in navigation
foreach (dbConn::query("SELECT * FROM :prefix:plan WHERE deleted = 0 ORDER BY created DESC") as $r) {
    $t = new template("admin/nav.plan");
    $t->insert("name", $r['name']);
    if (isset($_GET['v']) && $_GET['v'] == "plan" && isset($_GET['p']) && $_GET['p'] == $r['name']) {
        $t->insert("active", "active");
    } else {
        $t->insert("active", "");
    }
    $tpl->insert("navPlans", $t->getOutput());
}
$tpl->removeVariables();
echo $tpl->getOutput();
Esempio n. 10
0
         $tpl->insert("times", $sh->getOutput());
     }
     $tpl->removeVariables();
     echo $tpl->getOutput();
     break;
 case "history":
     echo getHistory(0);
     break;
 case "newplan":
     $tpl = new template("admin/plan.create");
     echo $tpl->getOutput();
     break;
 case "email":
     $tpl = new template("admin/mail.container");
     foreach (dbConn::query("SELECT * FROM :prefix:plan ORDER BY created DESC") as $r) {
         $tpl->insert("plans", template::create("admin/mail.plan", array("name" => $r['name'])));
     }
     foreach (dbConn::query("SELECT DISTINCT name, email FROM :prefix:worker ORDER BY name ASC") as $r) {
         $rec = new template("admin/mail.recipient");
         $rec->insert("name", $r['name']);
         $rec->insert("address", $r['email']);
         foreach (dbConn::query("SELECT DISTINCT name FROM :prefix:plan", $r['name'], $r['email']) as $s) {
             $rec->insert("plans", template::create("admin/mail.recipient.plan", array("name" => $s['name'], "checked" => dbConn::querySingle("SELECT COUNT(*) FROM :prefix:worker \n                                                      WHERE name = :0 AND email = :1 AND plan = :2", $r['name'], $r['email'], $s['name']) > 0 ? "checked" : "")));
         }
         $tpl->insert("recipients", $rec);
     }
     $tpl->removeVariables();
     echo $tpl->getOutput();
     break;
 default:
     echo "\n        <div class='alert alert-danger' role='alert'>\n          <span class='sr-only'>Fehler:</span>\n          Funktion nicht implementiert\n        </div>";
Esempio n. 11
0
 /**
  * Creates a new message box based on the default message template.
  *
  * @param   string $type      Name of the message template name.
  * @param   string $message   Body text of the message.
  * @return  string Html code of the message box.
  * @since   Version 1.0
  */
 public static function createMessage($type, $message)
 {
     $tpl = new template("core/msg.{$type}");
     $tpl->insert("message", $message);
     return $tpl->getOutput();
 }
Esempio n. 12
0
 /**
  * Generates the sidebar as html of this page.
  *
  * @return string Sidebar as html that matches the current page.
  * @since Version 1.5
  */
 public function getSidebar()
 {
     $parent = \dbConn::querySingle("SELECT caption FROM :prefix:content WHERE caption = :0", $_GET['par1']);
     $parentUrl = \dbConn::querySingle("SELECT url FROM :prefix:content WHERE caption = :0", $parent);
     $children = array();
     $sitemap = new \template("sitemap/sitemap");
     // title
     if ($this->parentId == null) {
         $sitemap->insert("title", \dbConn::querySingle("SELECT caption FROM :prefix:content WHERE url = :0", end($_GET)));
     } else {
         $sitemap->insert("title", \dbConn::querySingle("SELECT caption FROM :prefix:content WHERE contentId = :0", $this->parentId));
     }
     // children
     $hasChildren = false;
     if (\dbConn::querySingle("SELECT contentId FROM :prefix:content WHERE caption = :0", $parent)) {
         foreach (\dbConn::query("SELECT url, caption FROM :prefix:content WHERE parentId = :0", \dbConn::querySingle("SELECT contentId FROM :prefix:content WHERE caption = :0", $parent)) as $r) {
             $child = new \template("sitemap/sitemap.child");
             $child->insert("caption", $r['caption']);
             $child->insert("destination", ROOT . $parentUrl . "/" . $r['url'] . "/");
             if (isset($_GET['par2'])) {
                 $child->insert("active", $_GET['par2'] == $r['url'] ? "active" : "");
             }
             $sitemap->insert("children", $child->getOutput());
             $hasChildren = true;
         }
     }
     return $hasChildren ? $sitemap->getOutput() : "";
 }
<?php

session_start();
require "../../config.php";
if (!isset($_SESSION['user'])) {
    header("location: " . ROOT . "login");
    die;
}
if (!isset($_POST['userId'])) {
    die("missing argument userId");
}
$tpl = new template("visitors/add.patient");
foreach (\dbConn::query("SELECT * FROM :prefix:patient") as $r) {
    if (isset($_POST['remove'])) {
        if (in_array($r['patientId'], $_POST['remove'])) {
            continue;
        }
    }
    $tpl->insert("patients", "<option value=\"{$r['patientId']}\">{$r['firstname']} {$r['lastname']}</option>");
}
echo $tpl->getOutput();
  * SAVE CHANGES TO DATABASE
  */
 $t->commit();
 /*
  * SEND EMAIL TO SUBSCRIBERS
  */
 $emailRequired = false;
 $email = new template("email");
 $email->insert("plan", $_POST['plan']);
 foreach (dbConn::query("SELECT * FROM :prefix:email_pending") as $r) {
     $emailRequired = true;
     foreach (dbConn::query("SELECT\n                                historyId,\n                                action, \n                                nameBefore, \n                                nameAfter, \n                                emailBefore, \n                                emailAfter, \n                                production, \n                                fromDate,\n                                toDate,\n                                mvoe_plan.name AS plan, \n                                mvoe_worker_history.created\n                            FROM :prefix:worker_history \n                            INNER JOIN :prefix:shift ON :prefix:shift.shiftId = :prefix:worker_history.shift\n                            INNER JOIN :prefix:plan ON :prefix:shift.plan = :prefix:plan.name\n                            WHERE historyId = :0\n                            ORDER BY :prefix:worker_history.created DESC", $r['historyId']) as $r) {
         $change = new template("admin/lastchanges.entry");
         switch ($r['action']) {
             case "insert":
                 $change->insert("action", "<small><i class=\"fa fa-plus-square\"></i></small>  Hinzugefügt");
                 break;
             case "update":
                 $change->insert("action", "<small><i class=\"fa fa-minus-square\"></i></small>  Bearbeitet");
                 break;
             case "delete":
                 $change->insert("action", "<small><i class=\"fa fa-trash\"></i></small>  Gelöscht");
                 break;
             default:
                 $change->insert("action", "Unbekannt");
                 break;
         }
         $change->insert("shift", "<small>{$r['plan']}, {$r['production']}</small><br />" . substr($r['fromDate'], 0, 5) . " - " . substr($r['toDate'], 0, 5));
         if ($r['nameBefore'] == $r['nameAfter']) {
             $change->insert("user", $r['nameAfter']);
         } else {
Esempio n. 15
0
 /**
  * Creates a new template and directly fills in the given values.
  *
  * <code>
  * template::create("index", array(
  *      "var1" => "hello world"
  * ));
  * </code>
  *
  * @param string    $template   Name of the template.
  * @param array     $content    Content for the variables.
  * @static
  * @since Version 1.7
  */
 public static function create($template, $content)
 {
     $tpl = new template($template);
     foreach ($content as $key => $value) {
         $tpl->insert($key, $value);
     }
     return $tpl->getOutput();
 }
Esempio n. 16
0
 public function getOutput()
 {
     switch ($this->viewpoint) {
         case "overview":
             $tpl = new \template("visitors/container");
             foreach (\dbConn::query("SELECT * FROM :prefix:user ORDER BY lastname ASC") as $r) {
                 $v = new \template("visitors/visitor");
                 $v->insert("firstname", $r['firstname']);
                 $v->insert("id", $r['userId']);
                 $v->insert("lastname", $r['lastname']);
                 $v->insert("rfid", $r['rfid']);
                 $v->insert("patients", \dbConn::querySingle("SELECT COUNT(*) FROM :prefix:visit WHERE user = :0", $r['userId']));
                 $v->insert("lastvisit", \dbConn::querySingle("\n                                                                    SELECT DATE_FORMAT(MAX(h.created), '%d.%m.%y %H:%i')\n                                                                    FROM :prefix:visit AS v\n                                                                    INNER JOIN :prefix:visit_history AS h\n                                                                    ON v.visitId = h.visitId\n                                                                    WHERE v.user = :0\n                                                                ", $r['userId']));
                 $v->insert("destination", ROOT . "visitors/" . $r['userId']);
                 $tpl->insert("visitors", $v);
             }
             return $tpl->getOutput();
             break;
             // ######################################################################################################
         // ######################################################################################################
         case "new":
             $tpl = new \template("visitors/new");
             return $tpl;
             break;
             // ######################################################################################################
         // ######################################################################################################
         case "edit":
             $hasPatients = false;
             $visit = null;
             $tpl = new \template("visitors/edit.container");
             // user data
             $user = \dbConn::queryRow("SELECT userid, firstname, lastname, rfid, email, state \n                                            FROM :prefix:user WHERE userId = :0", $_GET['par2']);
             $tpl->insert("firstname", $user['firstname']);
             $tpl->insert("lastname", $user['lastname']);
             $tpl->insert("userid", $user['userid']);
             $tpl->insert("rfid", $user['rfid']);
             $tpl->insert("email", $user['email']);
             foreach (\dbConn::query("SELECT * FROM :prefix:user_state") as $r) {
                 $tpl->insert("states", $r['name'] == $user['state'] ? "<option value=\"{$r['name']}\" selected>{$r['display']}</option>" : "<option value=\"{$r['name']}\">{$r['display']}</option>");
             }
             // insert patients
             foreach (\dbConn::query("\n                                            SELECT firstname, lastname, patientId\n                                            FROM :prefix:visit AS v\n                                            INNER JOIN :prefix:patient AS p\n                                            ON v.patient = p.patientId\n                                            WHERE user = :0\n                                            ORDER BY firstname", $_GET['par2']) as $r) {
                 $tpl->insert("patients", "<option value=\"{$r['patientId']}\">{$r['firstname']} {$r['lastname']}</option>");
                 if (!$hasPatients) {
                     $visit = \dbConn::queryRow("SELECT * FROM :prefix:visit WHERE user = :0 AND patient = :1", $_GET['par2'], $r['patientId']);
                 }
                 $hasPatients = true;
             }
             $visitTpl = new \template("visitors/edit.visit");
             // relation
             foreach (\dbConn::query("SELECT * FROM :prefix:relation ORDER BY name ASC") as $r) {
                 $visitTpl->insert("relations", "<option value=\"{$r['name']}\"" . ($r['name'] == $visit['relation'] ? " selected" : "") . ">{$r['name']}</option>");
             }
             // description
             $visitTpl->insert("description", $visit['description']);
             // scent
             foreach (\dbConn::query("SELECT * FROM :prefix:scent ORDER BY name ASC") as $r) {
                 $visitTpl->insert("scents", "<option value=\"{$r['name']}\"" . ($r['name'] == $visit['scent'] ? " selected" : "") . ">{$r['name']}</option>");
             }
             // images
             $imgCount = 0;
             foreach (\dbConn::query("SELECT * FROM :prefix:visit_media WHERE visitId = :0 AND type = :1", $visit['visitId'], 'Image') as $img) {
                 $visitTpl->insert("image" . ($imgCount + 1), ROOT . "media/image/" . $img['path']);
                 $imgCount++;
             }
             for ($i = $imgCount + 1; $i <= 3; $i++) {
                 $visitTpl->insert("image" . $i, ROOT . "images/icons/image.png");
             }
             // audios
             $audioCount = 0;
             foreach (\dbConn::query("SELECT * FROM :prefix:visit_media WHERE visitId = :0 AND type = :1", $visit['visitId'], 'Audio') as $audio) {
                 $visitTpl->insert("audio" . ($audioCount + 1), ROOT . "images/icons/audio.png");
                 $audioCount++;
             }
             for ($i = $audioCount + 1; $i <= 3; $i++) {
                 $visitTpl->insert("audio" . $i, ROOT . "images/icons/plus.png");
             }
             $tpl->insert("visit", $visitTpl->getOutput());
             return $tpl->getOutput();
             break;
     }
 }
Esempio n. 17
0
        $module = "\\frontend\\" . $module;
        // class is not defined in file
        include_once "modules/" . $file . "/" . $file . ".php";
        if (!class_exists($module)) {
            throw new Exception("Die Modul-Klasse wurde nicht definiert.");
        }
        // create instance
        $obj = new $module();
        // set module obj for access from other codes
        controller::$reference = $obj;
        // class does not implement imodule interface
        if (!$obj instanceof imodule) {
            throw new Exception("Die Modul-Klasse hat das imodule-Interface nicht implementiert.");
        }
        // call getOutput() method and insert into index template
        $index->insert("title", $obj->getTitle() != "" ? $obj->getTitle() : ORGANISATION);
        $index->insert("content", $obj->getOutput());
        // logged in as
        $index->insert("loggedInAs", isset($_SESSION['user']) ? "Eingeloggt als " . $_SESSION['username'] : "");
    } else {
        header("location: " . ROOT . "error");
        die;
    }
} catch (Exception $ex) {
    $index->insert("content", $ex->getMessage());
}
// tell template to load all plugins (e.g. navigation bar)
$index->loadPlugins();
// load static content from static folder
$index->loadStaticContent();
// insert page request duration