<?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>';
	//}
?>

<?php echo LayoutHelper::render('joomla.content.link_box_start', $this->item); ?>
<?php echo LayoutHelper::render('joomla.content.intro_image', $this->item); ?>
	<div class="item-content">
		<?php echo LayoutHelper::render('joomla.content.blog_style_naked_item_title', $this->item); ?>
		<div class="d-flex align-items-end justify-content-between">
			<? if (isset($additionalFields['adress']) and !empty($additionalFields['adress'])) :?>
				<div class="adress"><?php echo $additionalFields['adress']; ?></div>
			<?php endif;?>
			<? if (isset($additionalFields['rezhim-raboty']) and !empty($additionalFields['rezhim-raboty'])) :?>
				<div class="rezhim-raboty"><?php echo $additionalFields['rezhim-raboty']; ?></div>
			<?php endif;?>
		</div>
	</div>
<?php echo LayoutHelper::render('joomla.content.link_box_end', $this->item); ?>
