Beispiel #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();
 }
Beispiel #2
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();
 }
Beispiel #3
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();
}
Beispiel #4
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();
 }
Beispiel #5
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;
     }
 }
<?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();
function print_orders($sourceid)
{
    /*
    name:
    print_orders($sourceid)
    returns:
    0 - no error
    1 - no orders to be printed
    2 - template parsing error
    3 - error setting orders printed
    other - mysql error number
    */
    $sourceid = $_SESSION['sourceid'];
    debug_msg(__FILE__, __LINE__, "BEGIN PRINTING");
    $query = "SELECT * FROM `orders` WHERE `sourceid`='{$sourceid}' AND `printed` IS NULL AND `suspend`='0' ORDER BY dest_id ASC, priority ASC, associated_id ASC, id ASC";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return mysql_errno();
    }
    if (!mysql_num_rows($res)) {
        return ERR_ORDER_NOT_FOUND;
    }
    $newassociated_id = "";
    $tablenum = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'sources', "name", $sourceid);
    $tpl_print = new template();
    $output['orders'] = '';
    $msg = "";
    while ($arr = mysql_fetch_array($res)) {
        $oldassociated_id = $newassociated_id;
        $newassociated_id = $arr['associated_id'];
        if (isset($priority)) {
            $oldpriority = $priority;
        } else {
            $oldpriority = 0;
        }
        $priority = $arr['priority'];
        if ($oldassociated_id != "") {
            $olddestid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $oldassociated_id));
            $olddest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $olddestid);
            $olddestname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $olddestid);
        } else {
            $olddestid = 0;
        }
        $destid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $newassociated_id));
        $dest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $destid);
        $destname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $destid);
        $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid);
        if ($destid != $olddestid || $priority != $oldpriority) {
            if ($destid != $olddestid && $olddestid != "") {
                $tpl_print->assign("date", printer_print_date());
                $tpl_print->assign("gonow", printer_print_gonow($oldpriority, $dest_language));
                $tpl_print->assign("page_cut", printer_print_cut());
                // strips the last newline that has been put
                $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1);
                if (table_is_takeaway($sourceid)) {
                    $print_tpl_file = 'ticket_takeaway';
                } else {
                    $print_tpl_file = 'ticket';
                }
                if ($err = $tpl_print->set_print_template_file($olddestid, $print_tpl_file)) {
                    return $err;
                }
                if ($err = $tpl_print->parse()) {
                    $msg = "Error in " . __FUNCTION__ . " - ";
                    $msg .= 'error: ' . $err . "\n";
                    echo nl2br($msg) . "\n";
                    error_msg(__FILE__, __LINE__, $msg);
                    return ERR_PARSING_TEMPLATE;
                }
                $tpl_print->restore_curly();
                $msg = $tpl_print->getOutput();
                $tpl_print->reset_vars();
                $output['orders'] = '';
                $msg = str_replace("'", "", $msg);
                if ($outerr = print_line($olddestid, $msg)) {
                    return $outerr;
                }
            } elseif ($priority != $oldpriority && $oldpriority != "") {
                $tpl_print->assign("date", printer_print_date());
                $tpl_print->assign("gonow", printer_print_gonow($oldpriority, $dest_language));
                $tpl_print->assign("page_cut", printer_print_cut());
                // strips the last newline that has been put
                $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1);
                if (table_is_takeaway($sourceid)) {
                    $print_tpl_file = 'ticket_takeaway';
                } else {
                    $print_tpl_file = 'ticket';
                }
                if ($err = $tpl_print->set_print_template_file($destid, $print_tpl_file)) {
                    return $err;
                }
                if ($err = $tpl_print->parse()) {
                    $msg = "Error in " . __FUNCTION__ . " - ";
                    $msg .= 'error: ' . $err . "\n";
                    error_msg(__FILE__, __LINE__, $msg);
                    echo nl2br($msg) . "\n";
                    return ERR_PARSING_TEMPLATE;
                }
                $tpl_print->restore_curly();
                $msg = $tpl_print->getOutput();
                $tpl_print->reset_vars();
                $output['orders'] = '';
                $msg = str_replace("'", "", $msg);
                if ($outerr = print_line($destid, $msg)) {
                    return $outerr;
                }
            }
            if (table_is_takeaway($sourceid)) {
                $takeaway_data = takeaway_get_customer_data($sourceid);
                $output['takeaway'] = ucfirst(lang_get($dest_language, 'PRINTS_TAKEAWAY')) . " - ";
                $output['takeaway'] .= $takeaway_data['takeaway_hour'] . ":" . $takeaway_data['takeaway_minute'] . "\n";
                $output['takeaway'] .= $takeaway_data['takeaway_surname'] . "\n";
                $tpl_print->assign("takeaway", $output['takeaway']);
            }
            $output['table'] = ucfirst(lang_get($dest_language, 'PRINTS_TABLE')) . ": " . $tablenum;
            $tpl_print->assign("table", $output['table']);
            $user = new user($_SESSION['userid']);
            $output['waiter'] = ucfirst(lang_get($dest_language, 'PRINTS_WAITER')) . ": " . $user->data['name'];
            $tpl_print->assign("waiter", $output['waiter']);
            $output['priority'] = ucfirst(lang_get($dest_language, 'PRINTS_PRIORITY')) . ": " . $priority . "\n";
            $tpl_print->assign("priority", $output['priority']);
            $output['people'] = ucfirst(lang_get($dest_language, 'PRINTS_PEOPLE')) . ": " . table_people_number($sourceid) . "\n";
            $tpl_print->assign("people", $output['people']);
            $table = new table($sourceid);
            $table->fetch_data(true);
            if ($cust_id = $table->data['customer']) {
                $cust = new customer($cust_id);
                $output['customer'] = ucfirst(lang_get($dest_language, 'CUSTOMER')) . ": " . $cust->data['surname'] . ' ' . $cust->data['name'];
                $tpl_print->assign("customer_name", $output['customer']);
                $output['customer'] = $cust->data['address'];
                $tpl_print->assign("customer_address", $output['customer']);
                $output['customer'] = $cust->data['zip'];
                $tpl_print->assign("customer_zip_code", $output['customer']);
                $output['customer'] = $cust->data['city'];
                $tpl_print->assign("customer_city", $output['customer']);
                $output['customer'] = ucfirst(lang_get($dest_language, 'VAT_ACCOUNT')) . ": " . $cust->data['vat_account'];
                $tpl_print->assign("customer_vat_account", $output['customer']);
            }
        }
        $output['orders'] .= printer_print_row($arr, $destid);
        $printed_orders[] = $arr['id'];
        if ($newassociated_id != $oldassociated_id) {
            // if we're in this function, it means that we changed associated_id id
            // and also that mods have been printed on the same sheet
            if (CONF_PRINT_BARCODES && $arr['dishid'] != MOD_ID) {
                $output['orders'] .= print_barcode($newassociated_id);
            }
        }
        if (CONF_PRINT_BARCODES && $arr['dishid'] != MOD_ID) {
            $output['orders'] .= print_barcode($newassociated_id);
        }
        $tpl_print->assign("orders", $output['orders']);
    }
    $destid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $newassociated_id));
    $dest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $destid);
    $destname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $destid);
    $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid);
    if (CONF_PRINT_BARCODES) {
        $tpl_print->assign("barcode", print_barcode($newassociated_id));
    }
    $tpl_print->assign("date", printer_print_date());
    $tpl_print->assign("gonow", printer_print_gonow($priority, $dest_language));
    $tpl_print->assign("page_cut", printer_print_cut());
    // strips the last newline that has been put
    $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1);
    if (table_is_takeaway($sourceid)) {
        $print_tpl_file = 'ticket_takeaway';
    } else {
        $print_tpl_file = 'ticket';
    }
    if ($err = $tpl_print->set_print_template_file($destid, $print_tpl_file)) {
        return $err;
    }
    if ($err = $tpl_print->parse()) {
        $err_msg = "Error in " . __FUNCTION__ . " - ";
        $err_msg .= 'error: ' . $err . "\n";
        error_msg(__FILE__, __LINE__, $err_msg);
        echo nl2br($err_msg) . "\n";
        return ERR_PARSING_TEMPLATE;
    }
    $tpl_print->restore_curly();
    $msg = $tpl_print->getOutput();
    $tpl_print->reset_vars();
    $output['orders'] = '';
    $msg = str_replace("'", "", $msg);
    if ($outerr = print_line($destid, $msg)) {
        return $outerr;
    }
    foreach ($printed_orders as $val) {
        if ($err = print_set_printed($val)) {
            return $err;
        }
    }
    // there was an error setting orders as printed
    if ($err) {
        return ERR_ORDER_NOT_SET_AS_PRINTED;
    }
    return 0;
}
Beispiel #8
0
                    $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);
$tpl->insert("creationTime", $diff > 0 ? $diff : "unknown");
$tpl->removeVariables();
Beispiel #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();
function bill_print()
{
    /*
    name:
    bill_print()
    returns:
    0 - no error
    1 - Printer not found for output tyoe
    2 - No order selected
    3 - Printing error
    other - mysql error number
    */
    // type: 	0: reserved
    //			1: bill
    //			2. invoice
    //			3. receipt
    //	we have to translate them to the mgmt_type values in order to be correctely
    //	written and read in the log
    //	mgmt_type:	3: invoice
    //				4: bill
    //				5: receipt
    global $tpl;
    global $output_page;
    $output['orders'] = '';
    $output_page = '';
    //connect to printer by client IP
    $clientip = "";
    if (isset($clientip)) {
        unset($clientip);
    }
    $clientip = getenv('REMOTE_ADDR');
    //end:connect to printer by client IP
    if ($_SESSION['bill_printed']) {
        return 0;
    }
    $_SESSION['bill_printed'] = 1;
    $type = $_SESSION['type'];
    $keep_separated = bill_check_keep_separated();
    $type = receipt_type_waiter2mgmt($type);
    // CRYPTO
    if (!bill_check_empty()) {
        $receipt_id = receipt_insert($_SESSION['account'], $type);
    }
    $printing_enabled = $arr['print_bill'];
    $tpl_print = new template();
    switch ($_SESSION['type']) {
        case 1:
            $query = "SELECT * FROM `dests` WHERE `bill`='1' AND `deleted`='0'";
            $template_type = 'bill';
            break;
        case 2:
            $query = "SELECT * FROM `dests` WHERE `invoice`='1' AND `deleted`='0'";
            $template_type = 'invoice';
            break;
        case 3:
            $query = "SELECT * FROM `dests` WHERE `receipt`='1' AND `deleted`='0'";
            $template_type = 'receipt';
            break;
        default:
            $query = "SELECT * FROM `dests` WHERE `bill`='1' AND `deleted`='0'";
            $template_type = 'bill';
    }
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return ERR_MYSQL;
    }
    //connect to printer by client IP
    while ($row = mysql_fetch_array($res)) {
        if ($row['dest_ip'] == '') {
            if ($row['dest'] != '') {
                $destid = $row['id'];
                $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid);
            } else {
                return ERR_PRINTER_NOT_FOUND_FOR_SELECTED_TYPE;
            }
        } elseif ($row['dest'] != '' && $row['dest_ip'] != '') {
            $ippart = explode("|", $row['dest_ip']);
            if (in_array($clientip, $ippart)) {
                $destid = $row['id'];
                break;
            }
            $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid);
        } else {
            return ERR_PRINTER_NOT_FOUND_FOR_SELECTED_TYPE;
        }
    }
    if ($err = $tpl_print->set_print_template_file($destid, $template_type)) {
        return $err;
    }
    // reset the counter and the message to be sent to the printer
    $total = 0;
    $msg = "";
    $tablenum = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'sources', "name", $_SESSION['sourceid']);
    $output['table'] = ucfirst(lang_get($dest_language, 'PRINTS_TABLE')) . " {$tablenum} \n";
    $tpl_print->assign("table", $output['table']);
    // writes the table num to video
    $output_page .= ucfirst(phr('TABLE_NUMBER')) . ": {$tablenum}     ";
    $table = new table($_SESSION['sourceid']);
    $table->fetch_data(true);
    if ($cust_id = $table->data['customer']) {
        $cust = new customer($cust_id);
        $output['customer'] = ucfirst(lang_get($dest_language, 'CUSTOMER')) . ": " . $cust->data['surname'] . ' ' . $cust->data['name'];
        $tpl_print->assign("customer_name", $output['customer']);
        $output['customer'] = $cust->data['address'];
        $tpl_print->assign("customer_address", $output['customer']);
        $output['customer'] = $cust->data['zip'];
        $tpl_print->assign("customer_zip_code", $output['customer']);
        $output['customer'] = $cust->data['city'];
        $tpl_print->assign("customer_city", $output['customer']);
        $output['customer'] = ucfirst(lang_get($dest_language, 'VAT_ACCOUNT')) . ": " . $cust->data['vat_account'];
        $tpl_print->assign("customer_vat_account", $output['customer']);
    }
    if (bill_check_empty()) {
        return ERR_NO_ORDER_SELECTED;
    }
    //mizuko : swap qty with name
    $output_page .= "<table bgcolor=\"" . COLOR_TABLE_GENERAL . "\">\r\n\t<thead>\r\n\t<tr>\r\n\t<th scope=col>" . ucfirst(phr('NAME')) . "</th>\r\n\t<th scope=col>" . ucfirst(phr('QUANTITY_ABBR')) . "</th>\r\n\t<th scope=col>" . ucfirst(phr('PRICE')) . "</th>\r\n\t</tr>\r\n\t</thead>\r\n\t<tbody>";
    $class = COLOR_ORDER_PRINTED;
    ksort($_SESSION['separated']);
    // the next for prints the list and the chosen dishes
    for (reset($_SESSION['separated']); list($key, $value) = each($_SESSION['separated']);) {
        $output['orders'] .= bill_print_row($key, $value, $destid);
    }
    $tpl_print->assign("orders", $output['orders']);
    if ($_SESSION['discount']['type'] == "amount" || $_SESSION['discount']['type'] == "percent") {
        $output['discount'] = bill_print_discount($receipt_id, $destid);
        $tpl_print->assign("discount", $output['discount']);
    }
    $total = bill_calc_vat();
    $total_discounted = bill_calc_discount($total);
    // updates the receipt value, has to be before print totals!
    receipt_update_amounts($_SESSION['account'], $total_discounted, $receipt_id);
    $output['total'] = bill_print_total($receipt_id, $destid);
    $tpl_print->assign("total", $output['total']);
    if (SHOW_CHANGE == 1) {
        $output['change'] = bill_print_change($total_discounted['total']);
        $tpl_print->assign("change", $output['change']);
    }
    //mizuko
    $user = new user($_SESSION['userid']);
    $output['waiter'] = ucfirst(lang_get($dest_language, 'PRINTS_WAITER')) . ": " . $user->data['name'];
    $tpl_print->assign("waiter", $output['waiter']);
    $tpl_print->assign("date", printer_print_date());
    //end mizuko
    $output_page .= "\r\n\t</tbody>\r\n\t</table>";
    $output['receipt_id'] = bill_print_receipt_id($receipt_id, $destid);
    $tpl_print->assign("receipt_id", $output['receipt_id']);
    $output['taxes'] = bill_print_taxes($receipt_id, $destid);
    $tpl_print->assign("taxes", $output['taxes']);
    if ($err = $tpl_print->parse()) {
        $msg = "Error in " . __FUNCTION__ . " - ";
        $msg .= 'error: ' . $err . "\n";
        error_msg(__FILE__, __LINE__, $msg);
        echo nl2br($msg) . "\n";
        return ERR_PARSING_TEMPLATE;
    }
    $tpl_print->restore_curly();
    $msg = $tpl_print->getOutput();
    $msg = str_replace("'", "", $msg);
    if ($printing_enabled) {
        if ($err = print_line($arr['id'], $msg)) {
            // the process is stopped so we delete the created receipt
            receipt_delete($_SESSION['account'], $receipt_id);
            return $err;
        }
    }
    ksort($_SESSION['separated']);
    // sets the log
    for (reset($_SESSION['separated']); list($key, $value) = each($_SESSION['separated']);) {
        if ($err_logger = bill_logger($key, $receipt_id)) {
            debug_msg(__FILE__, __LINE__, __FUNCTION__ . ' - receipt_id: ' . $receipt_id . ' - logger return code: ' . $err_logger);
        } else {
            debug_msg(__FILE__, __LINE__, __FUNCTION__ . ' - receipt_id: ' . $receipt_id . ' - logged');
        }
    }
    return 0;
}
        $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>";
        break;
}
Beispiel #12
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();
 }
Beispiel #13
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() : "";
 }
                 $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("hidden", "hidden");
         $email->insert("content", $change->getOutput());
         dbConn::execute("DELETE FROM :prefix:email_pending WHERE historyId = :0", $r['historyId']);
     }
 }
 if ($emailRequired) {
     $emailError = "";
     $arr = array();
     foreach (dbConn::query("SELECT email FROM :prefix:email_subscriber \n                                        WHERE plan = :0", $_POST['plan']) as $r) {
         $arr[] = $r['email'];
     }
     if (count($arr) > 0 && trim($arr[0]) != "") {
         emailSettings::send($arr, "Änderungen am Schichtplan " . $_POST['plan'], $email->getOutput(), $emailError);
         if ($emailError != "") {
             throw new Exception($emailError);
         }
     }
Beispiel #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();
 }
Beispiel #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;
     }
 }
Beispiel #17
0
        // 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
$diff = microtime() - $start;
$index->insert("request_duration", round($diff * 1000));
$index->insert("home", $_GET['par1'] == 'home' ? "active" : "");
// remove unreplaced variables in template engine
$index->removeVariables();
// print page
echo COMPRESS_ENABLED ? $index->getCompressedOutput() : $index->getOutput();