<?php

/**
 * @package        Joomla
 * @subpackage     Edocman
 * @author         Tuan Pham Ngoc
 * @copyright      Copyright (C) 2012 - 2023 Ossolution Team
 * @license        GNU/GPL, see LICENSE.php
 */
defined( '_JEXEC' ) or die ;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
HTMLHelper::_('formbehavior.chosen', 'select');

$config = EDocmanHelper::loadConfig();
?>
<form action="index.php?option=com_edocman&view=ratings" method="post" name="adminForm" id="adminForm">
	<div id="j-main-container">
		<div id="filter-bar" class="btn-toolbar">
			<div class="btn-group pull-right">
				<?php
				if(count($this->items))
				{
					echo $this->pagination->getLimitBox();
				}
				?>
			</div>
		</div>
		<div class="clearfix"></div>
		<?php
		if(count($this->items))
		{
		?>
			<table class="adminlist table table-striped">
				<thead>
					<tr>
						<th width="20">
							<input type="checkbox" name="toggle" value="" onclick="Joomla.checkAll(this)" />
						</th>
						<th class="title" style="text-align: left;">
							<?php echo HTMLHelper::_('grid.sort',  Text::_('EDOCMAN_DOCUMENT'), 'b.title', $this->state->filter_order_Dir, $this->state->filter_order ); ?>
						</th>
						<th class="title">
							<?php echo HTMLHelper::_('grid.sort',  Text::_('EDOCMAN_USER'), 'c.name', $this->state->filter_order_Dir, $this->state->filter_order ); ?>
						</th>
						<th class="center title" width="15%">
							<?php echo HTMLHelper::_('grid.sort',  Text::_('EDOCMAN_RATE'), 'tbl.rate', $this->state->filter_order_Dir, $this->state->filter_order ); ?>
						</th>			
						<th class="center title" width="15%">
							<?php echo HTMLHelper::_('grid.sort',  Text::_('EDOCMAN_RATED_ON'), 'tbl.rated_on', $this->state->filter_order_Dir, $this->state->filter_order ); ?>
						</th>													
					</tr>
				</thead>
				<tfoot>
					<tr>
						<td colspan="5">
							<?php echo $this->pagination->getListFooter(); ?>
						</td>
					</tr>
				</tfoot>
				<tbody>
				<?php
				$k = 0;
				for ($i=0, $n=count( $this->items ); $i < $n; $i++)
				{
					$row = &$this->items[$i];
					$link 	= Route::_( 'index.php?option=com_edocman&task=document.edit&id='. $row->document_id);
					$checked 	= HTMLHelper::_('grid.id',   $i, $row->id );
					?>
					<tr class="<?php echo "row$k"; ?>">
						<td>
							<?php echo $checked; ?>
						</td>
						<td>
							<a href="<?php echo $link; ?>">
								<?php echo $row->title; ?>
							</a>
						</td>
						<td>
							<?php
							echo $row->user_name;
							?>
						</td>
						<td class="left" style="padding-left:50px;">
							<?php
							for($j=1;$j<= (int)$row->rate;$j++)
							{
								?>
								<i class="icon icon-star" style="color:orange;"></i>
								<?php
							}
							?>
							(<?php echo $row->rate;?>)
						</td>	
						<td class="center">
							<?php echo HTMLHelper::_('date', $row->rated_on, $config->get('date_format')); ?>
						</td>											
					</tr>
					<?php
					$k = 1 - $k;
				}
				?>
				</tbody>
			</table>
		<?php
		}
		else
		{
			echo Text::_('EDOCMAN_NO_DATA_FOUND');
		}
		?>
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="filter_order" value="<?php echo $this->state->filter_order; ?>" />
		<input type="hidden" name="filter_order_Dir" value="<?php echo $this->state->filter_order_Dir; ?>" />	
		<?php echo HTMLHelper::_( 'form.token' ); ?>
	</div>
</form>
