<?php
/**
 * ------------------------------------------------------------------------
 * JA Property Template
 * ------------------------------------------------------------------------
 * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
 * @license - Copyrighted Commercial Software
 * Author: J.O.O.M Solutions Co., Ltd
 * Websites:  http://www.joomlart.com -  http://www.joomlancers.com
 * This file may not be redistributed in whole or significant part.
 * ------------------------------------------------------------------------
 */

defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Contact\Site\Helper\RouteHelper;

jimport('joomla.html.html.bootstrap');

$cparams = JComponentHelper::getParams('com_media');
$tparams = $this->item->params;
$htag    = $tparams->get('show_page_heading') ? 'h2' : 'h1';

if(version_compare(JVERSION, '4', 'ge')) {
	$this->contact = $this->item;
	$canDo   = ContentHelper::getActions('com_contact', 'category', $this->item->catid);
	$canEdit = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by === Factory::getUser()->id);
} 
?>

<?php if(version_compare(JVERSION, '4', 'ge')) {
		$presentation_style = 'plain';
	} else {
		$presentation_style = $tparams->get('presentation_style');
	};
?>

<div class="container">
	<div class="contact view-agent <?php echo $this->pageclass_sfx; ?>" itemscope itemtype="https://schema.org/Person">
		<!-- Page heading -->
		<?php if ($this->params->get('show_page_heading')) : ?>
			<h1>
				<?php echo $this->escape($this->params->get('page_heading')); ?>
			</h1>
		<?php endif; ?>
		<!-- End page heading -->
		
		<?php $accordionStarted = false; ?>
		<?php $tabSetStarted = false; ?>

		<!-- Slider type -->
		<?php if ($presentation_style === 'sliders') : ?>
			<div class="alert alert-warning">
	    	<?php echo Text::_('TPL_CHANGE_LAYOUT') ;?>
	    </div>
		<?php endif; ?>
		<!-- //Sliders type -->


		<!-- Tabs type -->
		<?php if ($presentation_style === 'tabs') : ?>
			<div class="alert alert-warning">
				<?php echo Text::_('TPL_CHANGE_LAYOUT') ;?>
			</div>
		<?php endif; ?>
		<!-- //Tabs type -->
		
		<!-- Plain type -->
		<?php if ($presentation_style === 'plain') : ?>
			<div class="row">
				<div class="col-sm-4">
					<div class="contact-info">
						

						<?php if ($this->params->get('show_info', 1)) : ?>
					    <?php if ($this->contact->image && $tparams->get('show_image')) : ?>
					      <div class="contact-thumbnail">
					        <?php echo HTMLHelper::_('image', $this->contact->image, $this->contact->name, array('itemprop' => 'image')); ?>
					      </div>
					    <?php endif; ?>

					    <!-- Show Contact name -->
							<?php if ($this->contact->name && $this->params->get('show_name')) : ?>
								<h2>
									<?php if ($this->item->published == 0) : ?>
										<span class="label label-warning"><?php echo Text::_('JUNPUBLISHED'); ?></span>
									<?php endif; ?>
									<span class="contact-name" itemprop="name"><?php echo $this->contact->name; ?></span>
								</h2>
							<?php endif;  ?>
							<!-- End Show Contact name -->

					    <?php if ($this->contact->con_position && $tparams->get('show_position')) : ?>
					      <div class="contact-position">
					          <?php echo $this->contact->con_position; ?>
					      </div>
					    <?php endif; ?>

					    <?php if ($this->contact->misc && $tparams->get('show_misc')) : ?>
					    <div class="contact-miscinfo">
					      <dl class="dl-horizontal">
					        <dt>
					          <span class="<?php echo $tparams->get('marker_class'); ?>">
					          <?php echo $tparams->get('marker_misc'); ?>
					          </span>
					        </dt>
					        <dd>
					          <span class="contact-misc">
					            <?php echo $this->contact->misc; ?>
					          </span>
					        </dd>
					      </dl>
					    </div>
					  	<?php endif; ?>  <!-- // Contact misc -->

					    <?php echo $this->loadTemplate('address'); ?>

					    <?php if ($tparams->get('allow_vcard')) : ?>
					      <?php echo Text::_('COM_CONTACT_DOWNLOAD_INFORMATION_AS'); ?>
					      <a href="<?php echo Route::_('index.php?option=com_contact&amp;view=contact&amp;id=' . $this->contact->id . '&amp;format=vcf'); ?>">
					      <?php echo Text::_('COM_CONTACT_VCARD'); ?></a>
					    <?php endif; ?>


						<?php endif; ?><!-- // Show info -->

						<?php if ($tparams->get('show_links')) : ?>
					    <?php echo $this->loadTemplate('links'); ?>
					  <?php endif; ?>

					  <?php if ($tparams->get('show_profile') && $this->contact->user_id && PluginHelper::isEnabled('user', 'profile')) : ?>
					  	<?php echo '<h3>' . Text::_('COM_CONTACT_PROFILE') . '</h3>'; ?>
					  	<?php echo $this->loadTemplate('profile'); ?>
					  <?php endif; ?> <!-- // Show profile -->

					  <?php if ($tparams->get('show_user_custom_fields') && $this->contactUser) : ?>
					    <?php echo $this->loadTemplate('user_custom_fields'); ?>
					  <?php endif; ?>

					  <?php if ($tparams->get('show_email_form') && ($this->contact->email_to || $this->contact->user_id)) : ?>
							<?php echo '<h3>' . Text::_('COM_CONTACT_EMAIL_FORM') . '</h3>'; ?>

							<?php echo $this->loadTemplate('form'); ?>
						<?php endif; ?> <!-- // Show email form -->
					</div>
				</div>

				<div class="col-sm-8">
					<div class="contact-article">
						<h3><?php echo $this->contact->name.''.Text::_('TPL_PROPERTY_LISTING'); ?></h3>
						<?php if ($tparams->get('show_articles') && $this->contact->user_id && $this->contact->articles) : ?>
					  	<?php echo $this->loadTemplate('articles'); ?>
					  <?php endif; ?> <!-- // Show articles -->
					</div>
				</div>
			</div>
			

		<?php endif; ?>
		<!-- //Plain type -->

		<?php if ($accordionStarted) : ?>
	    <?php echo HTMLHelper::_('bootstrap.endAccordion'); ?>
	  <?php elseif ($tabSetStarted) : ?>
	    <?php echo HTMLHelper::_('bootstrap.endTabSet'); ?>
	  <?php endif; ?>

		<?php if (!empty($this->item->event)) echo $this->item->event->afterDisplayContent; ?>
	</div>
</div>