<?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;

extract($displayData);

JHtml::addIncludePath(JPATH_ADVANCEDUSER_SITE . '/helpers/html');

// Register utility helper
JLoader::register('VPAdvancedUserHelperUtility', JPATH_ADVANCEDUSER_SITE . '/helpers/utility.php');

// Register frontend helper
JLoader::register('VPAdvancedUserFrontendHelper', JPATH_ADVANCEDUSER_SITE . '/helpers/vpadvanceduser.php');

JHtml::_('jquery.framework');
JHtml::_('behavior.keepalive');
JHtml::_('bootstrap.tooltip');
JHtml::_('vpadvanceduser.loadjs');

JHtml::_('vpadvanceduser.stylesheet', 'com_vpadvanceduser/icons.css', array(), true);
JHtml::_('vpadvanceduser.stylesheet', 'com_vpadvanceduser/general.css', array(), true);
?>
<div class="vp-wrapper">
	<button type="button" id="btn-vp-social-acceptance" class="vp-hide hide" data-target="#vp-social-acceptance-modal" data-vapumodal aria-hidden="true">Social Acceptance Trigger</button>
</div>
<div id="vp-social-acceptance-modal" class="vp-wrapper vpau-modal" aria-hidden="true" role="dialog">
	<div class="vpau-modal-dialog">
		<div class="vpau-modal-inner">
			<div class="vpau-modal-header">
				<button type="button" class="vpau-modal-close" title="<?php echo JText::_('JLIB_HTML_BEHAVIOR_CLOSE') ?>">
					<span aria-hidden="true">&times;</span>
				</button>
				<h3 id="vp-social-acceptance-title"><?php echo JText::_('JREGISTER') ?></h3>
			</div>
			<div class="vpau-modal-body">
				<div class="vpau-system-message"></div>
				<form action="#" id="vp-social-acceptance-form" class="vp-validate-registration">
					<?php foreach ($form->getFieldsets() as $fieldset): ?>
						<?php $fields = $form->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(in_array($field->fieldname, $ignoredFields)) continue; ?>

								<?php if ($field->hidden) : ?>
									<?php echo $field->input; ?>
								<?php else : ?>
									<?php
									$label = $field->label;
									$input = $field->input;
									// Ensure unique ID for the elements
									if($field->id && strpos($field->id, $id_prefix) === false)
									{
										if(strpos($field->id, 'jform') === false)
										{
											$new_id = $id_prefix . $field->id;
										}
										elseif(strpos($field->id, 'jform_vpadvanceduserdata_') === 0)
										{
											$new_id = str_replace('jform_vpadvanceduserdata_', $id_prefix, $field->id);
										}
										else
										{
											$new_id = str_replace('jform_', $id_prefix, $field->id);
										}
										
										$label = str_replace('for="' . $field->id, 'for="' . $new_id, $label);
										$input = str_replace('id="' . $field->id, 'id="' . $new_id, $input);
										$input = str_replace('for="' . $field->id, 'for="' . $new_id, $input);
									} ?>
									<div class="vp-form-group">
										<?php echo $label; ?>
										<?php echo $input; ?>
									</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::_('JSUBMIT');?></button>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>