--- ./templates.php.orig	2014-07-17 15:49:50.000000000 +0200
+++ ./templates.php	2014-08-16 21:30:14.000000000 +0200
@@ -24,6 +24,7 @@
 require_once dirname(__FILE__).'/include/screens.inc.php';
 require_once dirname(__FILE__).'/include/forms.inc.php';
 require_once dirname(__FILE__).'/include/ident.inc.php';
+require_once 'gv.php';
 
 if (isset($_REQUEST['go']) && $_REQUEST['go'] == 'export' && isset($_REQUEST['templates'])) {
 	$exportData = true;
@@ -453,6 +454,82 @@
 		'output' => array('templateid', 'name')
 	));
 
+	if (isset($data['dbTemplate']['name'])) {
+		$gvGraphCfg = array(
+			'bgcolor' => 'transparent',
+			'nodesep' => '0.1',
+			'rankdir' => 'RL');
+
+		$gvNodeCfg = array(
+			'fontname' => 'verdana',
+			'fontsize' => '7',
+			'height'   => '0',
+			'shape'    => 'none');
+
+		$gvEdgeCfg = array(
+			'dir'       => 'back',
+			'arrowsize' => '0.5');
+
+		$gvRootNodeCfg = array('fontname' => 'verdana bold');
+
+		$gvSimpleGraph = gv::strictdigraph(_('Template simple inheritance'));
+		gvConfigHandle($gvSimpleGraph, $gvGraphCfg);
+		gvAddParentTemplates($gvSimpleGraph, $templateId, $gvNodeCfg, $gvEdgeCfg, false);
+		gvAddChildTemplates($gvSimpleGraph, $templateId, $gvNodeCfg, $gvEdgeCfg, false);
+		$gvSimpleRootNode = gv::findnode($gvSimpleGraph, $data['dbTemplate']['name']);
+		gvConfigHandle($gvSimpleRootNode, $gvRootNodeCfg);
+		gv::layout($gvSimpleGraph, 'dot');
+
+		$gvDeepParentGraph = gv::strictdigraph(_('Template deep parrent inheritance'));
+		gvConfigHandle($gvDeepParentGraph, $gvGraphCfg);
+		gvAddParentTemplates($gvDeepParentGraph, $templateId, $gvNodeCfg, $gvEdgeCfg, true);
+		gvAddChildTemplates($gvDeepParentGraph, $templateId, $gvNodeCfg, $gvEdgeCfg, false);
+		$gvDeepParentRootNode = gv::findnode($gvDeepParentGraph, $data['dbTemplate']['name']);
+		gvConfigHandle($gvDeepParentRootNode, $gvRootNodeCfg);
+		gv::layout($gvDeepParentGraph, 'dot');
+
+		$gvDeepChildGraph = gv::strictdigraph(_('Template deep child inheritance'));
+		gvConfigHandle($gvDeepChildGraph, $gvGraphCfg);
+		gvAddParentTemplates($gvDeepChildGraph, $templateId, $gvNodeCfg, $gvEdgeCfg, false);
+		gvAddChildTemplates($gvDeepChildGraph, $templateId, $gvNodeCfg, $gvEdgeCfg, true);
+		$gvDeepChildRootNode = gv::findnode($gvDeepChildGraph, $data['dbTemplate']['name']);
+		gvConfigHandle($gvDeepChildRootNode, $gvRootNodeCfg);
+		gv::layout($gvDeepChildGraph, 'dot');
+
+		$gvDeepGraph = gv::strictdigraph(_('Template deep inheritance'));
+		gvConfigHandle($gvDeepGraph, $gvGraphCfg);
+		gvAddParentTemplates($gvDeepGraph, $templateId, $gvNodeCfg, $gvEdgeCfg, true);
+		gvAddChildTemplates($gvDeepGraph, $templateId, $gvNodeCfg, $gvEdgeCfg, true);
+		$gvDeepRootNode = gv::findnode($gvSimpleGraph, $data['dbTemplate']['name']);
+		gvConfigHandle($gvDeepRootNode, $gvRootNodeCfg);
+		gv::layout($gvDeepGraph, 'dot');
+
+		/*
+	 	* fixme: poor work-around because:
+	 	*        string gv::renderresult (graph_handle ing ,string format);
+	 	*        didn't work for any reason
+	 	*/
+		ob_start();
+		gv::renderresult($gvSimpleGraph, 'png', null);
+		$data['inheritanceSimpleImage'] = base64_encode(ob_get_contents());
+		ob_end_clean();
+
+		ob_start();
+		gv::renderresult($gvDeepParentGraph, 'png', null);
+		$data['inheritanceDeepParentImage'] = base64_encode(ob_get_contents());
+		ob_end_clean();
+
+		ob_start();
+		gv::renderresult($gvDeepChildGraph, 'png', null);
+		$data['inheritanceDeepChildImage'] = base64_encode(ob_get_contents());
+		ob_end_clean();
+
+		ob_start();
+		gv::renderresult($gvDeepGraph, 'png', null);
+		$data['inheritanceDeepImage'] = base64_encode(ob_get_contents());
+		ob_end_clean();
+	}
+
 	CArrayHelper::sort($data['linkedTemplates'], array('name'));
 
 	$templateForm = new CView('configuration.template.edit', $data);
@@ -492,8 +569,9 @@
 		_('Screens'),
 		_('Discovery'),
 		_('Web'),
-		_('Linked templates'),
-		_('Linked to')
+		//_('Linked templates'),
+		//_('Linked to'),
+		_('Inheritance')
 	));
 
 	// get templates
@@ -560,15 +638,58 @@
 		$httpTests = array(new CLink(_('Web'), 'httpconf.php?groupid='.$_REQUEST['groupid'].'&hostid='.$template['templateid']),
 			' ('.$template['httpTests'].')');
 
+		$gvGraphCfg = array(
+			'bgcolor' => 'transparent',
+			'nodesep' => '0.1',
+			'rankdir' => 'RL',
+			'ranksep' => '0.2');
+
+		$gvRootNodeCfg = array(
+			'fillcolor' => 'transparent',
+			'fontname'  => 'verdana',
+			'fontsize'  => '7',
+			'height'    => '0',
+			'margin'    => '0.04',
+			'shape'     => 'none');
+
+		$gvNodeCfg = array(
+			'fillcolor' => 'transparent',
+			'fontname'  => 'verdana',
+			'fontsize'  => '7',
+			'height'    => '0',
+			'margin'    => '0.04',
+			'shape'     => 'none');
+
+		$gvEdgeCfg = array(
+			'arrowsize' => '0.2',
+			'dir'       => 'back',
+			'penwidth'  => '0.5');
+
+		$gvGraph = gv::strictdigraph($template['name']);
+		gvConfigHandle($gvGraph, $gvGraphCfg);
+
+		$gvRootNode = gv::node($gvGraph, $template['name']);
+		gvConfigHandle($gvRootNode, $gvRootNodeCfg);
+		gvConfigHandle($gvRootNode, 'href', 'templates.php?form=update&templateid='.$template['templateid'].url_param('groupid'));
+
 		order_result($template['parentTemplates'], 'name');
 
 		$i = 0;
 		$linkedTemplatesOutput = array();
 
 		foreach ($template['parentTemplates'] as $linkedTemplate) {
+			$gvNode = gv::node($gvGraph, $linkedTemplate['name']);
+			gvConfigHandle($gvNode, $gvNodeCfg);
+			gvConfigHandle($gvNode, 'fontcolor', '#777777');
+
+			$gvEdge = gv::edge($gvGraph, $template['name'], $linkedTemplate['name']);
+			gvConfigHandle($gvEdge, $gvEdgeCfg);
+			gvConfigHandle($gvEdge, 'headport', 'e');
+
 			$i++;
 
 			if ($i > $config['max_in_table']) {
+				gvConfigHandle($gvNode, 'label', '...');
 				$linkedTemplatesOutput[] = '...';
 				$linkedTemplatesOutput[] = '//empty element for array_pop';
 				break;
@@ -576,6 +697,8 @@
 
 			$url = 'templates.php?form=update&templateid='.$linkedTemplate['templateid'].url_param('groupid');
 
+			gvConfigHandle($gvNode, 'href', $url);
+
 			$linkedTemplatesOutput[] = new CLink($linkedTemplate['name'], $url, 'unknown');
 			$linkedTemplatesOutput[] = ', ';
 		}
@@ -598,7 +721,17 @@
 		order_result($linkedToObjects, 'name');
 
 		foreach ($linkedToObjects as $linkedToHost) {
+			$gvNode = gv::node($gvGraph, $linkedToHost['name']);
+			gvConfigHandle($gvNode, $gvNodeCfg);
+			gvConfigHandle($gvNode, 'fontcolor', '#777777');
+
+			$gvEdge = gv::edge($gvGraph, $linkedToHost['name'], $template['name']);
+			gvConfigHandle($gvEdge, $gvEdgeCfg);
+			gvConfigHandle($gvEdge, 'tailport', 'w');
+
 			if (++$i > $config['max_in_table']) {
+				gvConfigHandle($gvNode, 'fontcolor', '');
+				gvConfigHandle($gvNode, 'label', '...');
 				$linkedToOutput[] = '...';
 				$linkedToOutput[] = '//empty element for array_pop';
 				break;
@@ -606,6 +739,7 @@
 
 			switch ($linkedToHost['status']) {
 				case HOST_STATUS_NOT_MONITORED:
+					gvConfigHandle($gvNode, 'fontcolor', '#DC0000');
 					$style = 'on';
 					$url = 'hosts.php?form=update&hostid='.$linkedToHost['objectid'].'&groupid='.$_REQUEST['groupid'];
 					break;
@@ -616,15 +750,39 @@
 					break;
 
 				default:
+					gvConfigHandle($gvNode, 'fontcolor', '#3C3089');
 					$style = null;
 					$url = 'hosts.php?form=update&hostid='.$linkedToHost['objectid'].'&groupid='.$_REQUEST['groupid'];
 			}
 
+			gvConfigHandle($gvNode, 'href', $url);
+
 			$linkedToOutput[] = new CLink($linkedToHost['name'], $url, $style);
 			$linkedToOutput[] = ', ';
 		}
 		array_pop($linkedToOutput);
 
+		gv::layout($gvGraph, 'dot');
+
+		/*
+	 	* fixme: poor work-around because:
+	 	*        string gv::renderresult (graph_handle ing ,string format);
+	 	*        didn't work for any reason
+	 	*/
+		ob_start();
+		gv::renderresult($gvGraph, 'png', null);
+		$gvImg = new Cimg('data:image/png;base64,'.base64_encode(ob_get_contents()), $template['name']);
+		ob_end_clean();
+
+		$gvImg->setMap($template['name']);
+
+		ob_start();
+		gv::renderresult($gvGraph, 'cmapx', null);
+		$gvImgMap = new CGvMap(ob_get_contents());
+		ob_end_clean();
+
+		gv::rm($gvGraph);
+
 		$table->addRow(array(
 			new CCheckBox('templates['.$template['templateid'].']', null, null, $template['templateid']),
 			$displayNodes ? get_node_name_by_elid($template['templateid'], true) : null,
@@ -636,8 +794,9 @@
 			$screens,
 			$discoveries,
 			$httpTests,
-			$linkedTemplatesOutput ? new CCol($linkedTemplatesOutput, 'wraptext') : '-',
-			$linkedToOutput ? new CCol($linkedToOutput, 'wraptext') : '-'
+			//$linkedTemplatesOutput ? new CCol($linkedTemplatesOutput, 'wraptext') : '-',
+			//$linkedToOutput ? new CCol($linkedToOutput, 'wraptext') : '-',
+			new CDiv(array($gvImg, $gvImgMap), 'center')
 		));
 	}
 
--- ./include/views/js/configuration.template.edit.js.php.orig	2014-08-16 22:11:25.000000000 +0200
+++ ./include/views/js/configuration.template.edit.js.php	2014-08-16 22:35:52.000000000 +0200
@@ -0,0 +1,46 @@
+<script type="text/javascript">
+	jQuery(document).ready(function() {
+		'use strict';
+
+		var tmplInheritFields = jQuery('#tmpllist:input');
+
+		jQuery('div.jqueryinputset input[name=tmpl_inherit_view]').click(function() {
+			switch (jQuery(this).val()) {
+				case '<?php echo "simple"; ?>':
+					tmplInheritFields.prop('disabled', true);
+					jQuery('#tmplInheritSimpleImage').show();
+					jQuery('#tmplInheritParentImage').hide();
+					jQuery('#tmplInheritChildImage').hide();
+					jQuery('#tmplInheritDeepImage').hide();
+					break;
+				case '<?php echo "parent"; ?>':
+					tmplInheritFields.prop('disabled', true);
+					jQuery('#tmplInheritSimpleImage').hide();
+					jQuery('#tmplInheritParentImage').show();
+					jQuery('#tmplInheritChildImage').hide();
+					jQuery('#tmplInheritDeepImage').hide();
+					// fixme: dirty hack to enforce table-row over item-list
+					jQuery('#tmplInheritParentImage').css('display', 'table-row');
+					break;
+				case '<?php echo "child"; ?>':
+					tmplInheritFields.prop('disabled', true);
+					jQuery('#tmplInheritSimpleImage').hide();
+					jQuery('#tmplInheritParentImage').hide();
+					jQuery('#tmplInheritChildImage').show();
+					jQuery('#tmplInheritDeepImage').hide();
+					// fixme: dirty hack to enforce table-row over item-list
+					jQuery('#tmplInheritChildImage').css('display', 'table-row');
+					break;
+				case '<?php echo "deep"; ?>':
+					tmplInheritFields.prop('disabled', true);
+					jQuery('#tmplInheritSimpleImage').hide();
+					jQuery('#tmplInheritParentImage').hide();
+					jQuery('#tmplInheritChildImage').hide();
+					jQuery('#tmplInheritDeepImage').show();
+					// fixme: dirty hack to enforce table-row over item-list
+					jQuery('#tmplInheritDeepImage').css('display', 'table-row');
+					break;
+			}
+		});
+	});
+</script>
--- ./include/views/configuration.host.edit.php.orig	2014-07-17 15:49:46.000000000 +0200
+++ ./include/views/configuration.host.edit.php	2014-08-16 23:12:48.000000000 +0200
@@ -706,6 +706,11 @@
 	$tmplList->addRow(_('Linked templates'), new CDiv($linkedTemplateTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
 }
 
+if (isset($data['inheritanceImage'])) {
+	$templateInheritanceImg = new Cimg('data:image/png;base64,'.$data['inheritanceImage'], _('Template inheritance'));
+	$tmplList->addRow(_('Template inheritance'), $templateInheritanceImg);
+}
+
 $divTabs->addTab('templateTab', _('Templates'), $tmplList);
 
 /*
--- ./include/views/configuration.template.edit.php.orig	2014-07-17 15:49:46.000000000 +0200
+++ ./include/views/configuration.template.edit.php	2014-08-17 00:00:56.000000000 +0200
@@ -19,6 +19,8 @@
 **/
 
 
+require_once dirname(__FILE__).'/js/configuration.template.edit.js.php';
+
 $divTabs = new CTabView();
 if (!isset($_REQUEST['form_refresh'])) {
 	$divTabs->setSelected(0);
@@ -435,6 +437,33 @@
 
 $tmplList->addRow(_('Link new templates'), new CDiv($newTemplateTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
 
+if (isset($data['inheritanceSimpleImage'])) {
+	$macroViewRadioButton = array(
+		new CRadioButton('tmpl_inherit_view', 'simple', null, 'tmpl_inherit_view_radio_simple', true),
+		new CLabel(_('Simple'), 'tmpl_inherit_view_radio_simple'),
+		new CRadioButton('tmpl_inherit_view', 'parent', null, 'tmpl_inherit_view_radio_parent', false),
+		new CLabel(_('Follow parents'), 'tmpl_inherit_view_radio_parent'),
+		new CRadioButton('tmpl_inherit_view', 'child', null, 'tmpl_inherit_view_radio_child', false),
+		new CLabel(_('Follow childs'), 'tmpl_inherit_view_radio_child'),
+		new CRadioButton('tmpl_inherit_view', 'deep', null, 'tmpl_inherit_view_radio_deep', false),
+		new CLabel(_('Follow parents and childs'), 'tmpl_inherit_view_radio_deep')
+	);
+
+	$buttonRow = new CRow();
+	$buttonRow->addItem($macroViewRadioButton);
+	$tmplList->addRow(_('Template inheritance'), new CDiv($buttonRow, 'jqueryinputset'));
+
+	$templInheritSimpleImg = new Cimg('data:image/png;base64,'.$data['inheritanceSimpleImage'], _('Template simple inheritance'));
+	$templInheritParentImg = new Cimg('data:image/png;base64,'.$data['inheritanceDeepParentImage'], _('Template deep parent inheritance'));
+	$templInheritChildImg = new Cimg('data:image/png;base64,'.$data['inheritanceDeepChildImage'], _('Template deep child inheritance'));
+	$templInheritDeepImg = new Cimg('data:image/png;base64,'.$data['inheritanceDeepImage'], _('Template deep inheritance'));
+
+	$tmplList->addRow(null, $templInheritSimpleImg, false, 'tmplInheritSimpleImage');
+	$tmplList->addRow(null, $templInheritParentImg, true, 'tmplInheritParentImage');
+	$tmplList->addRow(null, $templInheritChildImg, true, 'tmplInheritChildImage');
+	$tmplList->addRow(null, $templInheritDeepImg, true, 'tmplInheritDeepImage');
+}
+
 $divTabs->addTab('tmplTab', _('Linked templates'), $tmplList);
 // } TEMPLATES
 
--- ./include/hosts.inc.php.orig	2014-07-17 15:49:47.000000000 +0200
+++ ./include/hosts.inc.php	2014-08-16 21:00:54.000000000 +0200
@@ -812,3 +812,63 @@
 
 	return 0;
 }
+
+function gvConfigHandle($gv, $arg1, $arg2 = null) {
+	if (is_array($arg1)) {
+		$config = $arg1;
+		foreach ($config as $attribute => $value) {
+			gv::setv($gv, $attribute, $value);
+		}
+	}
+	else {
+		$attribute = $arg1;
+		$value = $arg2;
+		gv::setv($gv, $attribute, $value);
+	}
+}
+
+function gvAddParentTemplates($gv, $templateId, $nodeDef = array(), $edgeDef = array(), $deep = false) {
+	$linkedTemplates = API::Template()->get(array(
+		'templateids' => $templateId,
+		'selectParentTemplates' => array('templateid', 'name'),
+		'output' => array('templateid', 'name')
+	));
+
+	foreach ($linkedTemplates as $template) {
+		$headNode = gv::node($gv, $template['name']);
+		gvConfigHandle($headNode, $nodeDef);
+		foreach ($template['parentTemplates'] as $parentTemplate) {
+			$gvEdge = gv::edge($headNode, $parentTemplate['name']);
+			gvConfigHandle($gvEdge, $edgeDef);
+			gvConfigHandle($gvEdge, 'headport', 'e');
+
+			gvAddParentTemplates($gv, $parentTemplate['templateid'], $nodeDef, $edgeDef, $deep);
+			if ($deep) {
+				gvAddChildTemplates($gv, $parentTemplate['templateid'], $nodeDef, $edgeDef);
+			}
+		}
+	}
+}
+
+function gvAddChildTemplates($gv, $hostId, $nodeDef = array(), $edgeDef = array(), $deep = false) {
+	$linkedToTemplates = API::Template()->get(array(
+		'templateids' => $hostId,
+		'selectTemplates' => array('templateid', 'name'),
+		'output' => array('templateid', 'name')
+	));
+
+	foreach ($linkedToTemplates as $template) {
+		$tailNode = gv::node($gv, $template['name']);
+		gvConfigHandle($tailNode, $nodeDef);
+		foreach ($template['templates'] as $childTemplate) {
+			$gvEdge = gv::edge($childTemplate['name'], $tailNode);
+			gvConfigHandle($gvEdge, $edgeDef);
+			gvConfigHandle($gvEdge, 'tailport', 'w');
+
+			gvAddChildTemplates($gv, $childTemplate['templateid'], $nodeDef, $edgeDef, $deep);
+			if ($deep) {
+				gvAddParentTemplates($gv, $childTemplate['templateid'], $nodeDef, $edgeDef);
+			}
+		}
+	}
+}
--- ./include/classes/class.cgvmap.php.orig	2014-08-16 21:08:42.000000000 +0200
+++ ./include/classes/class.cgvmap.php	2014-08-16 21:00:54.000000000 +0200
@@ -0,0 +1,30 @@
+<?php
+/*
+** Zabbix
+** Copyright (C) 2001-2014 Zabbix SIA
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+**/
+
+
+class CGvMap extends CTag {
+
+	public function __construct($items = null) {
+		parent::__construct('div', 'yes');
+		$this->encStrategy = self::ENC_NONE;
+		$this->addItem($items);
+		return $this;
+	}
+}
--- ./include/classes/class.ctag.php.orig	2014-07-17 15:49:47.000000000 +0200
+++ ./include/classes/class.ctag.php	2014-08-16 21:00:54.000000000 +0200
@@ -32,6 +32,11 @@
 	const ENC_NOAMP = 2;
 
 	/**
+	 * Encodes no symbols.
+	 */
+	const ENC_NONE = 3;
+
+	/**
 	 * The HTML encoding strategy to use for the contents of the tag.
 	 *
 	 * @var int
@@ -284,6 +289,9 @@
 		if ($strategy == self::ENC_NOAMP) {
 			$value = str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $value);
 		}
+		elseif ($strategy == self::ENC_NONE) {
+			return $value;
+		}
 		else {
 			$value = CHtml::encode($value);
 		}
--- ./hosts.php.orig	2014-07-17 15:49:50.000000000 +0200
+++ ./hosts.php	2014-08-16 22:59:28.000000000 +0200
@@ -21,6 +21,7 @@
 
 require_once dirname(__FILE__).'/include/config.inc.php';
 require_once dirname(__FILE__).'/include/forms.inc.php';
+require_once 'gv.php';
 
 if (isset($_REQUEST['go']) && $_REQUEST['go'] == 'export' && isset($_REQUEST['hosts'])) {
 	$page['file'] = 'zbx_export_hosts.xml';
@@ -738,6 +739,56 @@
 		$data['dbHost'] = $dbHost;
 	}
 
+	if (isset($data['dbHost']['name'])) {
+		$gvGraphCfg = array(
+			'bgcolor' => 'transparent',
+			'nodesep' => '0.1',
+			'rankdir' => 'RL');
+
+		$gvNodeCfg = array(
+			'fontname' => 'verdana',
+			'fontsize' => '7',
+			'height'   => '0',
+			'shape'    => 'none');
+
+		$gvEdgeCfg = array(
+			'arrowsize' => '0.5',
+			'dir'       => 'back',
+			'headport'  => 'e');
+
+		$gvRootNodeCfg = array(
+			'fontname' => 'verdana',
+			'fontsize' => '7',
+			'height'   => '0',
+			'shape'    => 'none');
+
+		$gvGraph = gv::strictdigraph(_('Template inheritance'));
+		gvConfigHandle($gvGraph, $gvGraphCfg);
+
+		$gvRootNode = gv::node($gvGraph, $data['dbHost']['name']);
+		gvConfigHandle($gvRootNode, $gvRootNodeCfg);
+
+		foreach ($data['dbHost']['parentTemplates'] as $parentTemplate) {
+			$gvEdge = gv::edge($gvRootNode, $parentTemplate['name']);
+			gvConfigHandle($gvEdge, $gvEdgeCfg);
+			gvAddParentTemplates($gvGraph, $parentTemplate['templateid'], $gvNodeCfg, $gvEdgeCfg);
+		}
+
+		gv::layout($gvGraph, 'dot');
+
+		/*
+		* fixme: poor work-around because:
+		*        string gv::renderresult (graph_handle ing ,string format);
+		*        didn't work for any reason
+		*/
+		ob_start();
+		gv::renderresult($gvGraph, 'png', null);
+		$data['inheritanceImage'] = base64_encode(ob_get_contents());
+		ob_end_clean();
+
+		gv::rm($gvGraph);
+	}
+
 	$hostForm = new CView('configuration.host.edit', $data);
 	$hostsWidget->addItem($hostForm->render());
 
@@ -812,7 +863,8 @@
 		_('Discovery'),
 		_('Web'),
 		_('Interface'),
-		_('Templates'),
+		//_('Templates'),
+		_('Inheritance'),
 		make_sorting_header(_('Status'), 'status'),
 		_('Availability')
 	));
@@ -956,6 +1008,38 @@
 
 		$status = new CLink($statusCaption, $statusUrl, $statusClass, $statusScript);
 
+		$gvGraphCfg = array(
+			'bgcolor' => 'transparent',
+			'nodesep' => '0.1',
+			'rankdir' => 'RL',
+			'ranksep' => '0.2');
+
+		$gvRootNodeCfg = array(
+			'height'    => '0.04',
+			'shape'     => 'point');
+
+		$gvNodeCfg = array(
+			'fillcolor' => 'transparent',
+			'fontcolor' => '#777777',
+			'fontname'  => 'verdana',
+			'fontsize'  => '7',
+			'height'    => '0',
+			'margin'    => '0.04',
+			'shape'     => 'none');
+
+		$gvEdgeCfg = array(
+			'arrowsize' => '0.2',
+			'dir'       => 'back',
+			'headport'  => 'e',
+			'penwidth'  => '0.5');
+
+		$gvGraph = gv::strictdigraph($host['name']);
+		gvConfigHandle($gvGraph, $gvGraphCfg);
+
+		$gvRootNode = gv::node($gvGraph, $host['name']);
+		gvConfigHandle($gvRootNode, $gvRootNodeCfg);
+		gvConfigHandle($gvRootNode, 'href', 'hosts.php?form=update&hostid='.$host['hostid'].url_param('groupid'));
+
 		if (empty($host['parentTemplates'])) {
 			$hostTemplates = '-';
 		}
@@ -964,16 +1048,33 @@
 			order_result($host['parentTemplates'], 'name');
 
 			foreach ($host['parentTemplates'] as $template) {
+				$gvNode = gv::node($gvGraph, $template['name']);
+				gvConfigHandle($gvNode, $gvNodeCfg);
+
+				$gvEdge = gv::edge($gvGraph, $host['name'], $template['name']);
+				gvConfigHandle($gvEdge, $gvEdgeCfg);
+				gvConfigHandle($gvEdge, 'arrowtail', 'none');
+
+				$url = 'templates.php?form=update&templateid='.$template['templateid'];
 				$caption = array();
-				$caption[] = new CLink(CHtml::encode($template['name']), 'templates.php?form=update&templateid='.$template['templateid'], 'unknown');
+				$caption[] = new CLink(CHtml::encode($template['name']), $url, 'unknown');
+				gvConfigHandle($gvNode, 'href', $url);
 
 				if (!empty($templates[$template['templateid']]['parentTemplates'])) {
 					order_result($templates[$template['templateid']]['parentTemplates'], 'name');
 
 					$caption[] = ' (';
 					foreach ($templates[$template['templateid']]['parentTemplates'] as $tpl) {
-						$caption[] = new CLink(CHtml::encode($tpl['name']),'templates.php?form=update&templateid='.$tpl['templateid'], 'unknown');
+						$gvNode = gv::node($gvGraph, $tpl['name']);
+						gvConfigHandle($gvNode, $gvNodeCfg);
+
+						$gvEdge = gv::edge($gvGraph, $template['name'], $tpl['name']);
+						gvConfigHandle($gvEdge, $gvEdgeCfg);
+
+						$url = 'templates.php?form=update&templateid='.$tpl['templateid'];
+						$caption[] = new CLink(CHtml::encode($tpl['name']), $url, 'unknown');
 						$caption[] = ', ';
+						gvConfigHandle($gvNode, 'href', $url);
 					}
 					array_pop($caption);
 
@@ -989,6 +1090,27 @@
 			}
 		}
 
+		gv::layout($gvGraph, 'dot');
+
+		/*
+	 	* fixme: poor work-around because:
+	 	*        string gv::renderresult (graph_handle ing ,string format);
+	 	*        didn't work for any reason
+	 	*/
+		ob_start();
+		gv::renderresult($gvGraph, 'png', null);
+		$gvImg = new Cimg('data:image/png;base64,'.base64_encode(ob_get_contents()), $host['name']);
+		ob_end_clean();
+
+		$gvImg->setMap($host['name']);
+
+		ob_start();
+		gv::renderresult($gvGraph, 'cmapx', null);
+		$gvImgMap = new CGvMap(ob_get_contents());
+		ob_end_clean();
+
+		gv::rm($gvGraph);
+
 		$table->addRow(array(
 			new CCheckBox('hosts['.$host['hostid'].']', null, null, $host['hostid']),
 			$displayNodes ? get_node_name_by_elid($host['hostid'], true) : null,
@@ -1000,7 +1122,8 @@
 			$discoveries,
 			$httpTests,
 			$hostInterface,
-			new CCol($hostTemplates, 'wraptext'),
+			//new CCol($hostTemplates, 'wraptext'),
+			new CDiv(array($gvImg, $gvImgMap), 'right'),
 			$status,
 			getAvailabilityTable($host)
 		));
