<?php
/**
 * @package     SP Soccer
 * @author      JoomShaper http://www.joomshaper.com
 * @copyright   Copyright (C) 2010 - 2016 JoomShaper. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die('Restricted access');

// Get Columns
$columns = $this->params->get('columns', 2);

if(count($this->items)) {
	$menu 	= JFactory::getApplication()->getMenu();
	$itemId = '';
	if(is_object($menu->getActive())) {
		$active = $menu->getActive();
		$itemId = '&Itemid=' . $active->id;
	}
}

?>

<div id="spsoccer" class="spsoccer view-spsoccer-tournaments">
	<!-- Column -->
	<?php foreach(array_chunk($this->items, $columns) as $this->items) { ?>
		<div class="spsoccer-row">
			<?php foreach ($this->items as $this->item) { ?>
				<!-- START:: SP Soccer Tournaments -->
				<div class="spsoccer-col-lg-<?php echo round(12/$columns); ?> spsoccer-col-md-6 spsoccer-col-sm-12">
					<div class="spsoccer-row">
						<div class="spsoccer-tournament-name">
							<div class="tournament-image spsoccer-col-sm-6">
								<a href="<?php echo $this->item->url; ?>">
									<img class="spsoccer-img spsoccer-img-responsive" src="<?php echo $this->item->image; ?>" alt="<?php echo $this->item->title; ?>">
								</a>
							</div>
								<div class="tournament-details spsoccer-col-sm-6">
									<a href="<?php echo $this->item->url; ?>">
										<h3><?php echo $this->item->title; ?></h3>
									</a>
									<h4>
										<span class="title">year: </span>
										<span><?php echo $this->item->year; ?></span>
									</h4>
									<h4>
										<span class="title">Region: </span>
										<span><?php echo $this->item->region; ?></span>
									</h4>
									<h4>
										<span class="title">Number of teams: </span>
										<span><?php echo $this->item->teams; ?></span>
									</h4>
									<div class="details">
										<p><?php echo JHtml::_('string.truncate', strip_tags($this->item->description), $this->params->get('desciption_limit', 100)); ?></p>
									</div>
									<?php //print_r($this->item); ?>
							</div>
						</div>
					</div>
				</div>
				<!-- END:: SP Soccer Tournaments -->
			<?php };?>
		</div>
	<?php } ?>
	<!-- /Column -->

	<!-- START:: Pagination -->
	<?php if ($this->params->get('show_pagination', 1)) { ?>
		<?php if ($this->pagination->get('pages.total') >1) { ?>
			<div class="soccer-pagination">
				<?php echo $this->pagination->getPagesLinks(); ?>
			</div>
		<?php } ?>
	<?php } ?>
	<!-- END:: Pagination -->
</div>
