<?php
$this->breadcrumbs = array(
    // 'Rights' => Rights::getBaseUrl(),
	'Rights',
    Rights::getAuthItemTypeNamePlural($model->type) => Rights::getAuthItemRoute($model->type),
    $model->name,
);
?>
<div class="page-header">
    <h1><?php
	echo Rights::t('core', 'Update :name', array(
	    ':name' => $model->name,
	    ':type' => Rights::getAuthItemTypeName($model->type),
	));
	?>
    </h1>
</div>
<?php $this->renderPartial('_form', array('model' => $formModel)); ?>
<div class="col-md-12">
    <div class="relations widget-box">
	<div class="widget-header">
	    <h3><?php echo Rights::t('core', 'Relations'); ?></h3>
	</div>
	<div class="widget-body">
	    <div class="widget-main">
		<?php if ($model->name !== Rights::module()->superuserName): ?>
    		<div class="parents widget-box">
    		    <div class="widget-header header-color-blue">
    			<h4 class="smaller"><?php echo Rights::t('core', 'Parents'); ?></h4>
    		    </div>
    		    <div class="widget-body">
    			<div class="widget-main">
				<?php
				$this->widget('ext.widgets.FGridView', array(
				    'dataProvider' => $parentDataProvider,
				    'template' => '{items}',
				    'hideHeader' => true,
				    'emptyText' => Rights::t('core', 'This item has no parents.'),
				    'htmlOptions' => array('class' => 'grid-view parent-table mini'),
				    'columns' => array(
					array(
					    'name' => 'name',
					    'header' => Rights::t('core', 'Name'),
					    'type' => 'raw',
					    'htmlOptions' => array('class' => 'name-column'),
					    'value' => '$data->getNameLink()',
					),
					array(
					    'name' => 'type',
					    'header' => Rights::t('core', 'Type'),
					    'type' => 'raw',
					    'htmlOptions' => array('class' => 'type-column'),
					    'value' => '$data->getTypeText()',
					),
					array(
					    'header' => '&nbsp;',
					    'type' => 'raw',
					    'htmlOptions' => array('class' => 'actions-column'),
					    'value' => '',
					),
				    )
				));
				?>
    			</div>
    		    </div>
    		</div>
    		<div class="children widget-box">
    		    <div class="widget-header header-color-blue">
    			<h4 class="smaller"><?php echo Rights::t('core', 'Children'); ?></h4>
    		    </div>
    		    <div class="widget-body">
    			<div class="widget-main">
				<?php
				$this->widget('ext.widgets.FGridView', array(
				    'dataProvider' => $childDataProvider,
				    'template' => '{items}',
				    'hideHeader' => true,
				    'emptyText' => Rights::t('core', 'This item has no children.'),
				    'htmlOptions' => array('class' => 'grid-view parent-table mini'),
				    'columns' => array(
					array(
					    'name' => 'name',
					    'header' => Rights::t('core', 'Name'),
					    'type' => 'raw',
					    'htmlOptions' => array('class' => 'name-column'),
					    'value' => '$data->getNameLink()',
					),
					array(
					    'name' => 'type',
					    'header' => Rights::t('core', 'Type'),
					    'type' => 'raw',
					    'htmlOptions' => array('class' => 'type-column'),
					    'value' => '$data->getTypeText()',
					),
					array(
					    'header' => '&nbsp;',
					    'type' => 'raw',
					    'htmlOptions' => array('class' => 'actions-column'),
					    'value' => '$data->getRemoveChildLink()',
					),
				    )
				));
				?>
    			</div>
    		    </div>
    		</div>
    		<div class="addChild widget-box">
    		    <div class="widget-header header-color-blue">
    			<h4 class="smaller"><?php echo Rights::t('core', 'Add Child'); ?></h4>
    		    </div>
    		    <div class="widget-body">
    			<div class="widget-main">
				<?php if ($childFormModel !== null): ?>
				    <?php
				    $this->renderPartial('_childForm', array(
					'model' => $childFormModel,
					'itemnameSelectOptions' => $childSelectOptions,
				    ));
				    ?>
				<?php else: ?>
				    <p class="info"><?php echo Rights::t('core', 'No children available to be added to this item.'); ?>
				    <?php endif; ?>
    			</div>
    		    </div>
    		</div>
		<?php else: ?>
    		<p class="info">
			<?php echo Rights::t('core', 'No relations need to be set for the superuser role.'); ?><br />
			<?php echo Rights::t('core', 'Super users are always granted access implicitly.'); ?>
    		</p>
		<?php endif; ?>
	    </div>
	</div>
    </div>
</div>