<?php
/**
 * @package    VP Advanced User
 * @author     Abhishek Das <info@virtueplanet.com>
 * @copyright  Copyright (C) 2012-2019 VirtuePlanet Services LLP. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 * @link       https://www.virtueplanet.com
 */

defined('_JEXEC') or die;

$class      = $this->reg_inprocess ? '' : ' vp-hide';
$cancel_url = JRoute::_('index.php?option=com_vpadvanceduser&task=user.cancelregistration&' . JSession::getFormToken() . '=1');
$return     = $this->form->getValue('return', '', $this->myparams->get('login_redirect_url', $this->myparams->get('login_redirect_menuitem')));
$return     = !empty($this->data->return) ? $this->data->return : $return;
?>
<div id="vp-registration-content" class="vp-tab-content<?php echo $class ?>">
	<?php if($this->reg_inprocess) : ?>
		<p><?php echo JText::_('COM_VPADVANCEDUSER_MSG_COMPLETE_REGISTRATION') ?></p>
	<?php else : ?>
		<?php if($this->myparams->get('enable_social_login') && $this->myparams->get('show_in_registration')) : ?>
			<?php echo JLayoutHelper::render('social_buttons', array('show' => true, 'size' => 'standard', 'params' => $this->myparams, 'action' => 'REGISTER', 'return' => VPAdvancedUserHelperUtility::encode($return)), null, array('component' => 'com_vpadvanceduser')); ?>
			<div class="vp-or-container">
				<hr class="vp-or-hr" />
				<div class="vp-or"><?php echo JText::_('COM_VPADVANCEDUSER_OR') ?></div>
			</div>
		<?php endif ?>
	<?php endif ?>
	<form action="<?php echo JRoute::_('index.php?option=com_vpadvanceduser'); ?>" method="post" class="vp-validate-registration" enctype="multipart/form-data">
		<?php foreach ($this->regform->getFieldsets() as $fieldset): ?>
			<?php $fields = $this->regform->getFieldset($fieldset->name);?>
			<?php if (count($fields)):?>
				<fieldset>
				<?php if (isset($fieldset->label) && $fieldset->name != 'default') : ?>
					<legend><?php echo JText::_($fieldset->label);?></legend>
				<?php endif;?>
				<?php foreach ($fields as $field) : ?>
					<?php if ($field->hidden): ?>
						<?php echo $field->input;?>
					<?php else:?>
						<div class="vp-form-group">
							<?php echo $field->label; ?>
							<?php echo $field->input;?>
							<?php if($field->id == 'jform_password1' && $this->myparams->get('show_password_strength', 1)) : ?>
								<div class="vp-strength-container" aria-hidden="true">
									<div class="vp-weight-text vp-clearfix">
										<span class="vp-weight-label"><?php echo JText::_('COM_VPADVANCEDUSER_STRENGTH_LABEL') ?></span>
										<span class="is-short"><?php echo JText::_('COM_VPADVANCEDUSER_STRENGTH_TOO_SHORT') ?></span>
										<span class="is-weak"><?php echo JText::_('COM_VPADVANCEDUSER_STRENGTH_WEAK') ?></span>
										<span class="is-good"><?php echo JText::_('COM_VPADVANCEDUSER_STRENGTH_GOOD') ?></span>
										<span class="is-strong"><?php echo JText::_('COM_VPADVANCEDUSER_STRENGTH_STRONG') ?></span>
										<span class="is-verystrong"><?php echo JText::_('COM_VPADVANCEDUSER_STRENGTH_VERY_STRONG') ?></span>
									</div>
									<div class="vp-strength-meter"><span></span></div>
								</div>
							<?php endif ?>
						</div>
					<?php endif;?>
				<?php endforeach;?>
				</fieldset>
			<?php endif;?>
		<?php endforeach;?>
		<div class="vp-form-submission add-margin-top">
			<button type="submit" class="vp-btn vp-btn-primary vp-btn-lg validate"><?php echo JText::_('JREGISTER');?></button>
			<?php if($this->reg_inprocess) : ?>
				<a class="vp-btn vp-btn-lg" href="<?php echo $cancel_url ?>" title="<?php echo JText::_('JCANCEL');?>"><?php echo JText::_('JCANCEL');?></a>
			<?php endif ?>
		</div>
		<input type="hidden" name="option" value="com_vpadvanceduser" />
		<input type="hidden" name="task" value="user.signup" />
		<?php if(!empty($return)) : ?>
			<input type="hidden" name="return" value="<?php echo VPAdvancedUserHelperUtility::encode($return) ?>" />
		<?php endif; ?>
		<?php echo JHtml::_('form.token'); ?>
	</form>
</div>