<?php
/*
 * @component UserPoints
 * @copyright Copyright (C) 2015-2022 Bernard Gilly - Adrien Roussel - Martin Brampton
 * @license : GNU/GPL
 * @Website : https://remository.com
 */

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

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use BlackSheepResearch\Component\UserPoints\Site\UserPoints;

// HTMLHelper::_('behavior.formvalidation');
?>
<script type="text/javascript">
	Joomla.submitbutton = function(task)
	{
		//if (task == 'cpanel' || document.formvalidator.isValid(document.id('couponcodes-form'))) {
			Joomla.submitform(task, document.getElementById('adminForm'));
		//}
		//else {
			//alert('<?php echo $this->escape(Text::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
		//}
	}
</script>
<div id="j-main-container">
<form action="index.php?option=com_userpoints" method="post" name="adminForm" id="adminForm" class="form-validate">
<!--<div id="filter-bar" class="btn-toolbar">-->
	<!--<table>
		<tr>
			<td align="left" width="100%">&nbsp;
				<?php //echo Text::_( 'Filter' ); ?>
				<input type="text" name="search" id="search" value="<?php //echo @$this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
				<button onclick="this.form.submit();"><?php echo Text::_( 'Go' ); ?></button>
				<button onclick="document.getElementById('search').value='';this.form.submit();"><?php echo Text::_( 'Reset' ); ?></button>
			</td>
			<td nowrap="nowrap" align="right">
				<select name="filter_category_id" class="inputbox" onchange="this.form.submit()">
					<option value=""><?php //echo Text::_('JOPTION_SELECT_CATEGORY');?></option>
					<?php //echo HTMLHelper::_('select.options', HTMLHelper::_('category.options', 'com_userpoints'), 'value', 'text', $this->lists['filter_category_id']);?>
				</select>
				<?php
				//echo $this->lists['filter_state'];
				?>
			</td>
		</tr>
	</table>-->
<!--</div>-->
	<div class="clearfix"> </div>
	<table class="table table-striped">
		<thead>
			<tr>
				<th width="2%" class="title">
					<?php echo Text::_( 'NUM' ); ?>
				</th>
				<th width="3%" class="title">
					<input type="checkbox" name="checkall-toggle" value="" title="<?php echo Text::_('JGLOBAL_CHECK_ALL'); ?>" onclick="Joomla.checkAll(this)" />
				</th>
				<th width="15%" class="title">
					<?php echo Text::_('AUP_NAME'); ?>
				</th>
				<th class="title" nowrap="nowrap">
					<?php echo Text::_( 'AUP_SUBJECT' ); ?>
				</th>
				<th width="8%" class="title" nowrap="nowrap">
					<?php echo Text::_( 'AUP_FORMAT' ); ?>
				</th>
				<th width="8%"class="title" >
					<?php echo Text::_('AUP_SEND_COPY_ADMIN'); ?>
				</th>
				<th width="5%" class="title" >
					<?php echo Text::_('AUP_PUBLISHED'); ?>
				</th>
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="7">
					<?php echo $this->pagination->getListFooter(); ?>
				</td>
			</tr>
		</tfoot>
		<tbody>
		<?php
			$i = $k = 0;

			foreach ($this->templateinvite as $row)
			{
				$link 	= 'index.php?option=com_userpoints&amp;task=edittemplateinvite&amp;cid[]='. $row->id. '';
				//$img 	= $row->published ? 'publish_x.png' : 'tick.png';
				$published 	= HTMLHelper::_('jgrid.published', $row->published, $i );
				$format = $row->emailformat ? Text::_( 'AUP_HTML' ) : Text::_( 'AUP_PLAIN-TEXT' );
				$bcc2admin = $row->bcc2admin ? Text::_( 'JYes' ) : Text::_( 'AUP_NO' );
			?>
			<tr class="<?php echo "row$k"; ?>">
				<td>
					<?php echo $i+1+$this->pagination->limitstart;?>
				</td>
				<td align="center">
					<?php
						echo HTMLHelper::_('grid.id', $i, $row->id );
					?>
				</td>
				<td>
				<?php
				if (UserPoints::getUser()->authorise('core.edit', 'com_userpoints')) {
				?>
					<a href="<?php echo $link; ?>">
				<?php } ?>
					<?php echo $row->template_name; ?>
				<?php
				if (UserPoints::getUser()->authorise('core.edit', 'com_userpoints')) {
				?>
					</a>
				<?php } ?>
				</td>
				<td>
					<?php echo $row->emailsubject; ?>
				</td>
				<td>
					<?php echo $format; ?>
				</td>
				<td>
					<?php echo $bcc2admin; ?>
				</td>
				<td>
					<?php echo $published; ?>
				</td>
			</tr>
			<?php
				$k = 1 - $k;
                                $i++;
				}
			?>
		</tbody>
	</table>
	<input type="hidden" name="option" value="com_userpoints" />
	<input type="hidden" name="task" value="templateinvite" />
	<input type="hidden" name="table" value="alpha_userpoints_template_invite" />
	<input type="hidden" name="redirect" value="templateinvite" />
	<input type="hidden" name="boxchecked" value="0" />
</form>
</div>