From: Thomas Mudrunka Date: Fri, 21 Oct 2011 12:32:51 +0000 (+0200) Subject: Pridany relacni linky X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=d697501165a454ff6934ad17315ae8ccca621275;p=mirrors%2FSokoMan.git Pridany relacni linky --- diff --git a/index.php b/index.php index 11bb1ef..98f6c15 100755 --- 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) { diff --git a/locale/cs/messages.inc.php b/locale/cs/messages.inc.php index b6e9690..0ff6568 100644 --- a/locale/cs/messages.inc.php +++ b/locale/cs/messages.inc.php @@ -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]',