| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- class UI {
- public static function getTitle() {
- $title = 'SE';
- $host = $_SERVER['SERVER_NAME'];
- if (substr($host, 0, 5) == 'biuro') {
- $host = substr($host, 6);
- }
- $title = "{$host}-SE";
- return $title;
- }
- public static function gora() {
- UI::startHtml();
- }
- public static function startHtml() {
- Lib::loadClass('S');
- UI::loadTemplate('_layout_gora');
- }
- public static function dol() {
- UI::endHtml();
- }
- public static function endHtml() {
- $version = (file_exists(APP_PATH_ROOT . '/VERSION'))? file_get_contents(APP_PATH_ROOT . '/VERSION') : null;
- if ($version) {
- echo '<div style="border-top:1px solid #ddd;margin-top:10px;padding:0 30px;font-size:xx-small;color:#888;">version: '.$version.'</div>';
- }
- echo "\n</body></html>";
- }
- public static function menu() {
- if (!User::logged()) return;
- if (User::hasAccess('menu')) {
- Lib::loadClass('ProcesMenu');
- $procesMenu = ProcesMenu::getInstance();
- $procesMenu->show();
- if (!V::get('MENU_INIT', '', $_GET)) {
- Lib::loadClass('UserActivity');
- //echo UserActivity::showListInContainer();
- }
- }
- else {
- UI::loadTemplate('menuLevel6');
- }
- }
- public static function loadTemplate($tmplName, $data = array()) {
- if (is_array($data) && !empty($data)) {
- extract($data);
- }
- include APP_PATH_LIB . "/tmpl/{$tmplName}.php";
- }
- public static function hotKeyDBG($str) {
- if (User::hasAccess('dbg')) {
- echo '<span class="hidden-dbg">' . htmlspecialchars($str) . '</span>';
- }
- }
- public static function showMessagesForTable($tblName) {
- if (empty($tblName)) return;
- $msgsRoute = Router::getRoute('Msgs');
- $msgs = $msgsRoute->getActiveMessagesForTable($tblName);
- if (!empty($msgs)) {
- self::loadTemplate('msgsForTable', array('msgs' => $msgs));
- }
- }
- public static function alert($alertType, $msg) {
- ?>
- <div class="alert alert-<?php echo $alertType; ?>">
- <?php echo $msg; ?>
- </div>
- <?php
- }
- public static function setTitleJsTag($title) {
- ?>
- <script>
- document.title = '<?php echo $title; ?>';
- </script>
- <?php
- }
- /**
- * $params - Array
- * $params['caption'] (optional) -> <caption>...</caption>
- * $params['cols'] (optional) -> cols, if not set read from first row
- * $params['rows'] -> rows, if not set - empty table
- * $params['rows'] -> rows, if not set - empty table
- * $params['disable_lp'] -> disable lp. col
- */
- public static function table($params) {
- $cols = V::get('cols', array(), $params);
- $rows = V::get('rows', array(), $params);
- $caption = V::get('caption', '', $params);
- $showLp = (!V::get('disable_lp', false, $params));
- if (empty($cols) && !empty($rows)) {
- $firstRow = array();
- foreach ($rows as $row) {
- $firstRow = $row;
- break;
- }
- $cols = array_keys((array)$firstRow);
- }
- // if (empty($cols)) return;
- $hiddenCols = V::get('hidden_cols', array(), $params);
- $html_id = V::get('__html_id', '', $params);
- ?>
- <table class="table table-bordered table-hover" <?php echo ($html_id)? 'id="' . $html_id . '"' : ''; ?>>
- <?php if ($caption) : ?>
- <caption><?php echo $caption; ?></caption>
- <?php endif; ?>
- <thead>
- <tr>
- <?php if ($showLp) : ?>
- <th style="padding:2px">Lp.</th>
- <?php endif; ?>
- <?php foreach ($cols as $colName) : ?>
- <?php if (in_array($colName, $hiddenCols)) continue; ?>
- <th style="padding:2px"><?php echo $colName; ?></th>
- <?php endforeach; ?>
- </tr>
- </thead>
- <tbody>
- <?php $i = 0; foreach ($rows as $row) : $i++; ?>
- <tr <?php echo (!empty($row['__js_on_click']))? 'onClick="' . $row['__js_on_click'] . '"' : ''; ?>>
- <?php if ($showLp) : ?>
- <td style="padding:2px; color:#ccc"><?php echo $i; ?></td>
- <?php endif; ?>
- <?php foreach ($cols as $colName) : ?>
- <?php if (in_array($colName, $hiddenCols)) continue; ?>
- <td style="padding:2px"><?php echo V::get($colName, '', $row); ?></td>
- <?php endforeach; ?>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- <?php
- }
- public static function jsAjaxTable($params) {
- }
- public static function price($value) {
- // TODO: if not number type - string wwith wrong format - try to convert?
- return number_format($value, 2, ',', ' ');
- }
- }
|