<?php

/**
 * @package     Joomla.Site
 * @subpackage  com_content
 *
 * @copyright   (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Associations;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Content\Administrator\Extension\ContentComponent;
use Joomla\Component\Content\Site\Helper\RouteHelper;

// Create a shortcut for params.
$params = $this->item->params;
$canEdit = $this->item->params->get('access-edit');
$info    = $params->get('info_block_position', 0);

// Check if associations are implemented. If they are, define the parameter.
$assocParam = (Associations::isEnabled() && $params->get('show_associations'));

$currentDate   = Factory::getDate()->format('Y-m-d H:i:s');
$isUnpublished = ($this->item->state == ContentComponent::CONDITION_UNPUBLISHED || $this->item->publish_up > $currentDate)
    || ($this->item->publish_down < $currentDate && $this->item->publish_down !== null);

$additionalFields = array();
foreach($this->item->jcfields as $field) {
	$additionalFields[$field->name] = $field->value;
	
	//if($field->name == 'allwork') {
		//$allworks = json_decode($field->rawvalue, true);
	//};
}
?>
<?php 
	//foreach($allworks as $allwork) {
		//echo '<div class="tab_title" data-target="#'.$allwork['Алиас вкдадки'].'">'.$allwork['Название вкладки'].'</div>';
	//}
?>
<div class="item-content item-content-portfolio">
	<?php echo LayoutHelper::render('joomla.content.intro_image_portfolio_link', $this->item); ?>
	<div class="item-portfolio-box">
		<?php echo LayoutHelper::render('joomla.content.blog_style_naked_item_title', $this->item); ?>
		<div class="field-items field-portfolio">
			<? if (isset($additionalFields['lokatsiya']) and !empty($additionalFields['lokatsiya'])) :?>
				<div class="field-icon lokatsiya"><?php echo $additionalFields['lokatsiya']; ?></div>
			<?php endif;?>
			<? if (isset($additionalFields['material']) and !empty($additionalFields['material'])) :?>
				<div class="field-icon material"><span>Пленка:</span> <?php echo $additionalFields['material']; ?></div>
			<?php endif;?>
			<? if (isset($additionalFields['ploshchad']) and !empty($additionalFields['ploshchad'])) :?>
				<div class="field-icon ploshchad"><span>Площадь:</span> <?php echo $additionalFields['ploshchad']; ?>м<sup>2</sup></div>
			<?php endif;?>
			<? if (isset($additionalFields['srok']) and !empty($additionalFields['srok'])) :?>
				<div class="field-icon srok"><span>Срок:</span> <?php echo $additionalFields['srok']; ?></div>
			<?php endif;?>
		</div>
	</div>
	</a>
	<?php if ($params->get('show_intro')) : ?>
		<?php echo $this->item->introtext; ?>
    <?php endif; ?>
    <?php // Content is generated by content plugin event "onContentAfterDisplay" ?>
    <?php echo $this->item->event->afterDisplayContent; ?>
</div>
