Pridany relacni linky
authorThomas Mudrunka <tomas@mudrunka.cz>
Fri, 21 Oct 2011 12:32:51 +0000 (14:32 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Fri, 21 Oct 2011 12:32:51 +0000 (14:32 +0200)
index.php
locale/cs/messages.inc.php

index 11bb1ef4faf53c7cbb22a2949581efda04d3bd80..98f6c15ea3d887abc7f159e19672fc6087ad688c 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -287,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',
@@ -322,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);
@@ -686,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) {
index b6e96905e1dad4510d95d65a40c2c66245081c8f..0ff65683d9c6a855e93e94099ae1252451514b4c 100644 (file)
@@ -43,6 +43,14 @@ $LOCALE_MESSAGES = array(
                'status_name' => 'Stav',
                'category_name' => 'Kategorie',
 
+               'model_relations' => 'Souvisejici s timto modelem',
+               'category_relations' => 'V teto kategorii',
+               'producer_relations' => 'Od tohoto vyrobce',
+               'vendor_relations' => 'Od tohoto prodejce',
+               'room_relations' => 'V tomto skladu',
+               'status_relations' => 'V tomto stavu',
+               '_relations' => ' jinde',
+
                'item' => '[položka]',
                'producer' => '[výrobce]',
                'room' => '[sklad]',
This page took 0.146521 seconds and 4 git commands to generate.