Pridany relacni linky
[mirrors/SokoMan.git] / index.php
index db9921d1960afb4b9d6b7f14adb23b29ae01c7fa..98f6c15ea3d887abc7f159e19672fc6087ad688c 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -160,12 +160,16 @@ class Sklad_HTML extends HTML { //TODO: Split into few more methods
                $user_id = htmlspecialchars($user['id']);
                $user_gid = htmlspecialchars($user['gid']);
                $user_name = htmlspecialchars($user['name']);
+               $time = date('r');
                //$title = T($title); //TODO
 
                $html = $this->head("SōkoMan$title");
                $html .= <<<EOF
 <h1 style="display: inline;"><a href="$script/">SōkoMan</a><small>$instance$title</small></h1>
-<div style="float:right">Loged in as <b>$user_name</b> [UID: <b>$user_id</b>; GID: <b>$user_gid</b>]</div>
+<div style="float:right; text-align:right;">
+       Logged in as <b>$user_name</b> [UID: <b>$user_id</b>; GID: <b>$user_gid</b>]<br />
+       Page loaded at $time
+</div>
 
 <style type="text/css">
 * { font-family: arial; }
@@ -283,6 +287,26 @@ EOF;
                }
        }
 
+       function table_add_relations(&$table, $class, $suffix_relations='_relations') {
+               $relations = array( //TODO: Autodetect???
+                       'model' => array('model_id' => array('item')),
+                       'category' => array('category_id' => array('item')),
+                       'producer' => array('producer_id' => array('item')),
+                       'vendor' => array('vendor_id' => array('item')),
+                       'room' => array('room_id' => array('item')),
+                       'status' => array('status_id' => array('item')),
+               );
+               foreach($table as $id => $row) {
+                       foreach($row as $column => $value) {
+                               if(isset($relations[$class][$column])) {
+                                       foreach($relations[$class][$column] as $destination) {
+                                               @$table[$id][$class.$suffix_relations] .= $this->link($destination, "$destination/?where[$column]==$value").',';
+                                       }
+                               }
+                       }
+               }
+       }
+
        function table_collapse(&$table) {
                $collapse = array(
                        'item_id' => 'item_id',
@@ -318,9 +342,10 @@ EOF;
                $table = $table_sorted;
        }
 
-       function render_item_table($table) {
+       function render_item_table($table,$class=false) {
                $this->table_add_images($table);
                $this->table_add_barcodes($table);
+               if($class) $this->table_add_relations($table,$class);
                $this->table_collapse($table);
                $this->table_sort($table);
                return $this->table($table);
@@ -682,7 +707,7 @@ class Sklad_UI {
        }
 
        function render_items($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false) {
-               return $this->html->render_item_table($this->db->get_listing($class, $id, $limit, $offset, $where, $search, $history, false));
+               return $this->html->render_item_table($this->db->get_listing($class, $id, $limit, $offset, $where, $search, $history, false),$class);
        }
 
        function render_form_add($class) {
This page took 0.347932 seconds and 4 git commands to generate.