<?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\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;

$row = $this->row;
$listrank = $this->listrank;
$medalsexist = $this->medalsexist;

// Load the tooltip behavior.
// HTMLHelper::_('behavior.tooltip');
// HTMLHelper::_('behavior.formvalidation');
// HTMLHelper::_('formbehavior.chosen', 'select');

?>
<script type="text/javascript">
	Joomla.submitbutton = function(task)
	{
		//if (task == 'cpanel' || task == 'cancelrule' || document.formvalidator.isValid(document.id('statistic-form'))) {
			Joomla.submitform(task, document.getElementById('statistic-form'));
		//}
		//else {
			//alert('<?php echo $this->escape(Text::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
		//}
	}
</script>
<div id="j-main-container">
<div class="span2">

</div>

<div class="form-horizontal span10">
<form action="index.php?option=com_userpoints" method="post" name="statistic-form" id="statistic-form" class="form-validate">
	<?php echo HTMLHelper::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>
		<?php echo HTMLHelper::_('bootstrap.addTab', 'myTab', 'details', Text::_('AUP_DETAILS', true)); ?>		
		<fieldset class="adminform">
			<div class="control-group">
				<div class="control-label">
					<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_NAME'); ?>">
						<?php echo Text::_( 'AUP_NAME' ); ?>:
					</span>
				</div>
				<div class="controls">
					<?php 
						echo "<font color='green'>" . Text::_($row->name) . "</font>";
					?>
				</div>
			</div>
			<div class="control-group">
				<div class="control-label">
					<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_USERNAME'); ?>">
						<?php echo Text::_( 'AUP_USERNAME' ); ?>:
					</span>
				</div>
				<div class="controls">
					<?php 
						echo "<font color='green'>" . Text::_($row->username) . "</font>"; 
					?>
				</div>
			</div>
			<div class="control-group">
				<div class="control-label">
					<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_REFERREID'); ?>">
						<?php echo Text::_( 'AUP_REFERREID' ); ?>:
					</span>
				</div>
				<div class="controls">
					<?php 
						echo "<font color='green'>" . Text::_($row->referreid) . "</font>"; 
					?>				
				</div>
			</div>
			<div class="control-group">
				<div class="control-label">
					<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_POINTS'); ?>">
						<?php echo Text::_( 'AUP_POINTS' ); ?>:
					</span>
				</div>
				<div class="controls">
					<?php echo $this->getFormattedPointsAdm( $row->points ); ?><br /><br />
					<a href="index.php?option=com_userpoints&task=showdetails&cid=<?php echo $row->referreid; ?>&name=<?php echo $row->name; ?>"><?php echo Text::_('AUP_SHOW_DETAIL_ACTIVITIES'); ?></a>
				</div>
			</div>
			<div class="control-group">
				<div class="control-label">
					<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_EXCLUDESPECIFICUSERSDESCRIPTION'); ?>">
						<?php echo Text::_( 'AUP_ENABLED' ); ?>:
					</span>
				</div>
				<div class="controls">
					<fieldset id="jform_published" class="radio btn-group">
						<?php echo HTMLHelper::_('select.booleanlist', 'published', '', $row->published); ?>
					</fieldset>
				</div>
			</div>
			<div class="control-group">
				<div class="control-label">
					<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_RANK'); ?>">
						<?php echo Text::_( 'AUP_RANK' ); ?>:
					</span>
				</div>
				<div class="controls">
					<?php echo $listrank; ?>
				</div>
			</div>
			<?php 
				if ( $row->leveldate != '1000-01-01' ) {
			?>
			<div class="control-group">
				<div class="control-label">
					<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_DATE'); ?>">
						<?php echo Text::_( 'AUP_DATE' ); ?>:
					</span>
				</div>
				<div class="controls">
				<?php
					echo $this->presentDate('date',  $row->leveldate,  Text::_('DATE_FORMAT_LC') );
				?>
				</div>
			</div>
			<?php } ?>
			
		</fieldset>
		<div class="clr"></div>
		<?php echo HTMLHelper::_('bootstrap.endTab'); ?>
	
<?php echo HTMLHelper::_('bootstrap.addTab', 'myTab', 'profile', Text::_('AUP_PROFILE', true)); ?>

		<fieldset class="adminform">
		<div class="span6">
		<div class="control-group">
			<div class="control-label">
				<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_PROFILE_VIEWS'); ?>">
					<?php echo Text::_( 'AUP_PROFILE_VIEWS' ); ?>:
				</span>
			</div>
			<div class="controls">
				<?php 
					echo "<span class='badge badge-success'>" . $row->profileviews . "</span>"; 
					if ( $row->profileviews )
					{
					?>
					<a class="btn btn-mini" href="index.php?option=com_userpoints&task=resetprofilviews&id=<?php echo $row->id; ?>"><i class="icon-arrow-left"></i> <?php echo Text::_( 'AUP_RESET' ); ?> <i class="icon-cancel"></i></a>							
					<?php
					}
				?>
			</div>
		</div>
		<?php if ( $row->referraluser ) {?>
		<div class="control-group">
			<div class="control-label">
				<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_REFERRALUSER'); ?>">
					<?php echo Text::_( 'AUP_REFERRALUSER' ); ?>:
				</span>
			</div>
			<div class="controls">
				<?php 
					echo "<span class='label label-success'>" . $row->referraluser . "</span> ";
					if ( $row->referralusername ) 
					{
						echo "(" . $row->referralusername . ")"; 
					}

					?>
					<a class="btn btn-mini" href="index.php?option=com_userpoints&task=resetreferraluser&id=<?php echo $row->id; ?>"><i class="icon-arrow-left"></i> <?php echo Text::_( 'AUP_RESET' ); ?> <i class="icon-cancel"></i></a>							
			</div>
		</div>
		<?php } ?>
		<div class="control-group">
			<div class="control-label">
				<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_REFERREES'); ?>">
					<?php echo Text::_( 'AUP_REFERREES' ); ?>:
				</span>
			</div>
			<div class="controls">
				<?php 
					echo "<span class='badge badge-success'>" . $row->referrees . "</span>"; 
					if ( $row->referrees )
					{
					?>
					<a class="btn btn-mini" href="index.php?option=com_userpoints&task=resetreferrees&id=<?php echo $row->id; ?>"><i class="icon-arrow-left"></i> <?php echo Text::_( 'AUP_RESET' ); ?> <i class="icon-cancel"></i></a>							
					<?php
					}
				?>
			</div>
		</div>

		</div>
		</fieldset>
	<input type="hidden" name="option" value="com_userpoints" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
	<input type="hidden" name="userid" value="<?php echo $row->userid; ?>" />
	<input type="hidden" name="referreid" value="<?php echo $row->referreid; ?>" />
	<!--<input type="hidden" name="referraluser" value="<?php echo $row->referraluser; ?>" />-->	
	<input type="hidden" name="oldrank" value="<?php echo $row->levelrank; ?>" />	
	<input type="hidden" name="upnid" value="<?php echo $row->upnid; ?>" />
	<input type="hidden" name="referrees" value="<?php echo $row->referrees; ?>" />
	<input type="hidden" name="blocked" value="<?php echo $row->blocked; ?>" />	
	<input type="hidden" name="avatar" value="<?php echo $row->avatar; ?>" />
	
	<input type="hidden" name="profileviews" value="<?php echo $row->profileviews; ?>" />
	<input type="hidden" name="shareinfos" value="<?php echo $row->shareinfos; ?>" />	
	<input type="hidden" name="redirect" value="statistics" />
	<input type="hidden" name="boxchecked" value="0" />
	<?php echo HTMLHelper::_('form.token'); ?>
</form>
		<div class="clr"></div>
		<?php echo HTMLHelper::_('bootstrap.endTab'); ?>

	<?php if ( $medalsexist ) { ?>
		<?php echo HTMLHelper::_('bootstrap.addTab', 'myTab', 'addnewmedal', Text::_('AUP_AWARDED_NEW_MEDAL', true)); ?>
		<?php if ( $this->medalslistuser ) { ?>	
			<legend><?php echo Text::_( 'AUP_MEDALS' ); ?></legend>
			<table class="table table-bordered table-striped tabel-hover">
			<tbody>
			<?php foreach ( $this->medalslistuser as $medaluser ) { ?>
			<tr>
				<td width="15%">
					<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_NAME'); ?>">
						<i class="icon-calendar visible-desktop"></i> <?php echo $medaluser->medaldate; ?>
					</span>
				</td>
				<td width="20%">
					<?php 
						echo $medaluser->rank;
					?>
				</td>
				<td>
					<?php 
						$linkdelete = '<a  class="btn btn-small btn-danger pull-right" href="index.php?option=com_userpoints&amp;task=removemedaluser&amp;cid='.$medaluser->id.'&amp;rid='.$row->id.'"><i class="icon-delete"></i> '.Text::_( 'AUP_DELETE' ).'</a>';
						echo $medaluser->reason;
						echo $linkdelete;
					?>
				</td>
			</tr>
			<?php } ?>
			</tbody>
			</table>
		<?php } ?>
<p>&nbsp;</p>
<p>&nbsp;</p>	
		<form action="index.php?option=com_userpoints" method="post" name="adminForm2" id="adminForm2">
		<div class="form-horizontal span12">
				<table class="admintable" width="100%">
				<tbody>
				<div class="control-group">
					<div class="control-label">
						<span class="editlinktip hasTip" title="<?php echo Text::_('AUP_MEDAL'); ?>">
							<?php echo Text::_( 'AUP_MEDAL' ); ?>
						</span>				
					</div>
					<div class="controls">
					  <?php echo $this->listmedals; ?>
				  </div>
				</div>
				<div class="control-group">
					<div class="control-label">
						<span class="editlinktip hasTip" title="<?php echo Text::_( 'AUP_OPTIONAL' ). ' - ' . Text::_( 'AUP_DESCRIPTION_MEDAL_BY_DEFAULT' ) ; ?>">
							<?php echo Text::_( 'AUP_DESCRIPTION' ) .  ' <i>(' . Text::_( 'AUP_OPTIONAL' ) . ')</i>'; ?>
						</span>				
					</div>
					<div class="controls">
					  <input type="text" id="reason" name="reason" class="inputbox" value="" size="60" />
				  </div>
				</div>		
				<div class="control-group">
					<div class="control-label">&nbsp;
					</div>
					<div class="controls">
					  <input type="submit" name="Submit" class="btn btn-primary" value="<?php echo  Text::_('AUP_AWARDED_NEW_MEDAL'); ?>" />
				  </div>
				</div>		
				</tbody>
				</table>			
			<input type="hidden" name="option" value="com_userpoints" />
			<input type="hidden" name="task" value="awardedmedal" />
			<input type="hidden" name="rid" value="<?php echo $row->id; ?>" />
			<input type="hidden" name="userid" value="<?php echo $row->userid; ?>" />
			<input type="hidden" name="referreid" value="<?php echo $row->referreid; ?>" />
			<input type="hidden" name="referraluser" value="<?php echo $row->referraluser; ?>" />	
			<input type="hidden" name="redirect" value="edituser" />
			<input type="hidden" name="cid[]" value="<?php echo $row->id; ?>" />
			<input type="hidden" name="boxchecked" value="0" />
			</div>
		</form>
		<?php echo HTMLHelper::_('bootstrap.endTab'); ?>
	<?php } // end if medal exist ?>
	<?php echo HTMLHelper::_('bootstrap.addTab', 'myTab', 'latestactivity', Text::_('AUP_LASTACTIVITY', true)); ?>	
			<div class="">
				<?php echo $this->loadTemplate('activity'); ?>
			</div>
	<?php echo HTMLHelper::_('bootstrap.endTab'); ?>
</div>
<?php echo HTMLHelper::_('bootstrap.endTabSet'); ?>
<div class="clr"></div>
</div>