<?php

/*
# -------------------------------------------------------------------------
# WS Register - Native Joomla Registration in a Module
# -------------------------------------------------------------------------
# author     WS-Theme.com
# copyright  Copyright (C) 2012 WS-Theme.com. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
# Websites:  http://www.ws-theme.com
# -------------------------------------------------------------------------
*/

// no direct access
defined('_JEXEC') or die('Restricted access'); 
JHtml::_('behavior.keepalive');
JHtml::_('behavior.formvalidation');
?>

<script src="/media/plg_captcha_recaptcha/js/recaptcha.min.js?b2802ea557ed706aee0213f83ec66152" type="text/javascript"></script>
<script src="https://www.google.com/recaptcha/api.js?onload=JoomlaInitReCaptcha2&render=explicit&hl=en-GB" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" type="text/javascript"></script>

<style>
    .specialist {
        width: 70%;
    }
    
    .star {
        font-size:17px;
        transform: scale(.5, 1);
        font-weight: bold;
    }
    .arrow {
        font-size:25px;
        font-weight: bold;
    }
    
    .hasTooltip {
        position: relative;
        display: inline-block;
    }
    
    .hasTooltip .tooltiptext {
  visibility: hidden;
  width: 200px;
  background-color: black;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;

  /* Position the tooltip */
  position: absolute;
  z-index: 1;
}

.hasTooltip:hover .tooltiptext {
  visibility: visible;
}

.modal-backdrop {
    /* bug fix - no overlay */    
    display: none;    
}

.modal-dialog {
    margin: 20% auto;
    z-index: 1100 !important;
}

#trial {
    width: 69% !important;
}

.control-label {
    color: black !important;
}

.link {
    cursor: pointer;
}

.login {
    font-size: 15px;
    text-transform: uppercase;
}

.btn-success {
    display: none;
}
</style>

<?php if ( $text_intro != '' ) : ?><div class="wsreg_intro"><?php echo $text_intro ; ?></div><?php endif; ?>
<?php
$user=JFactory::getUser();

if($user->id == 0):
?>

<!-- Trigger the modal with a link -->
<p class="login"><?=JText::_('COM_USERS_LINK_LABEL')?></p>

<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title"><?=JText::_('COM_USERS_LOGIN_HEADER')?></h4>
      </div>
      <div class="modal-body">
        <p class="text-white"><?=JText::_('COM_USERS_LOGIN_LABEL')?></p>
        <?=JModuleHelper::renderModule(JModuleHelper::getModule('login','Felhasználó - Bejelentkezés'))?>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>
<div class="registration">
    <form id="member-registration" action="<?php echo JRoute::_('index.php?option=com_users&task=registration.register'); ?>" method="post" class="form-validate form-horizontal well" enctype="multipart/form-data">
        <legend><b><?=JText::_('COM_USERS_PROFILE_BASIC_LABEL')?></b><span></span></legend>
        
        <div class="form-group">
            <span class="spacer"><span class="before"></span><span class="text"><label id="jform_spacer_default-lbl" class="control-label col-sm-1"><strong class="red">*</strong> <strong><?=JText::_('COM_USERS_PROFILE_REQUIRED_LABEL')?></strong></label></span><span class="after"></span></span>
        </div>
        
        <div class="form-group">
            <label class="hasTooltip control-label col-sm-1" for="jform_firstname"><strong><?=JText::_('COM_USERS_PROFILE_FIRSTNAME_LABEL')?><span class="star">&#160;*</span><!--<span class="tooltiptext">Enter your first name</span>--></strong></label>
            <div class="col-md-10">
                <input placeholder="<?=JText::_('COM_USERS_PROFILE_FIRSTNAME_DESC')?>" type="text" class="<?php echo $wsreg_inputclass ; ?> form-control" value="" id="jform_firstname" name="jform[firstname]" />
                <span id="fname_error"></span>
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-sm-1" for="jform_lastname"><strong><?=JText::_('COM_USERS_PROFILE_LASTNAME_LABEL')?><span class="star">&#160;*</span></strong></label>
            <div class="col-md-10">
                <input placeholder="<?=JText::_('COM_USERS_PROFILE_LASTNAME_DESC')?>" type="text" class="<?php echo $wsreg_inputclass ; ?> form-control" value="" id="jform_lastname" name="jform[lastname]" />
                <span id="lname_error"></span>
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-sm-1" for="jform_email1"><strong>Email<span class="star">&#160;*</span></strong></label>
            <div class="col-md-10">
                <input placeholder="<?=JText::_('COM_USERS_PROFILE_EMAIL_DESC')?>" type="text" class="validate-email <?php echo $wsreg_inputclass ; ?> form-control" value="" id="jform_email1" name="jform[email1]" />
                <span id="email_error"></span>
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-sm-1" for="jform_email2"><strong><?=JText::_('COM_USERS_PROFILE_CONFIRMEMAIL_LABEL')?><span class="star">&#160;*</span></strong></label>
            <div class="col-md-10">
                <input placeholder="<?=JText::_('COM_USERS_PROFILE_CONFIRMEMAIL_DESC')?>" type="text" class="validate-email <?php echo $wsreg_inputclass ; ?> form-control" value="" id="jform_email2" name="jform[email2]" />
                <span id="email_error2"></span>
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-sm-1" for="jform_password1"><strong><?=JText::_('COM_USERS_PROFILE_PASSWORD_LABEL')?><span class="star">&#160;*</span></strong></label>
            <div class="col-md-10">
                <input placeholder="<?=JText::_('COM_USERS_PROFILE_PASSWORD_DESC')?>" type="password" class="validate-password <?php echo $wsreg_inputclass ; ?> form-control" autocomplete="off" value="" id="jform_password1" name="jform[password1]" />
                <span id="pw_error"></span>
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-sm-1" for="jform_password2"><strong><?=JText::_('COM_USERS_PROFILE_CONFIRMPASSWORD_LABEL')?><span class="star">&#160;*</span></strong></label>
            <div class="col-md-10">
                <input placeholder="<?=JText::_('COM_USERS_PROFILE_CONFIRMPASSWORD_DESC')?>" type="password" class="validate-password <?php echo $wsreg_inputclass ; ?> form-control" autocomplete="off" value="" id="jform_password2" name="jform[password2]" />
                <span id="pw_error2"></span>
            </div>
        </div>
        
        <legend><?=JText::_('COM_USERS_PROFILE_DETAILS_LABEL')?><span></span></legend>
        
        <div class="form-group">
            <label class="control-label col-sm-1" for="jform_phone"><strong><?=JText::_('COM_USERS_PROFILE_PHONE_LABEL')?><span class="star">&#160;*</span></strong></label>
            <div class="col-md-10">
                <input placeholder="<?=JText::_('COM_USERS_PROFILE_PHONE_DESC')?>" type="tel" class="validate-phone <?php echo $wsreg_inputclass ; ?> form-control" size="30" value="" id="jform_phone" name="jform[phone]" />
                <span id="phone_error"></span>
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-sm-1" for="jform_profession"><strong><?=JText::_('COM_USERS_PROFILE_PROFESSION_LABEL')?><span class="star">&#160;*</span></strong></label>
            <div class="col-md-10">
                <select data-val="" id="jform_profession" name="jform[profession]" class="form-control">
                    <option value="" selected="selected"><?=JText::_('COM_USERS_PROFILE_PROFESSION_DESC')?></option>
                    <?php
                    $tomb=parse_ini_file($_SERVER['DOCUMENT_ROOT'].'/language/'.JFactory::getLanguage()->getTag().'/'.JFactory::getLanguage()->getTag().'.prof.ini');
                    foreach ($tomb as $k=>$v) echo '<option value="'.$v.'">'.$v.'</option>';
                    ?>
                </select>
                <span id="prof_error"></span>
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-sm-1" for="jform_country"><strong><?=JText::_('COM_USERS_PROFILE_COUNTRY_LABEL')?><span class="star">&#160;*</span></strong></label>
            <div class="col-md-10">
                <select data-val="" id="jform_country" name="jform[country]" class="form-control">
                    <option value="" selected="selected"><?=JText::_('COM_USERS_PROFILE_PROFESSION_DESC')?></option>
                    <?php
                    $tomb=parse_ini_file($_SERVER['DOCUMENT_ROOT'].'/language/'.JFactory::getLanguage()->getTag().'/'.JFactory::getLanguage()->getTag().'.countries.ini');
                    foreach ($tomb as $k=>$v) echo '<option value="'.$v.'">'.$v.'</option>';
                    ?>
                </select>
                <span id="ctr_error"></span>
            </div>
        </div>
        <br/>
        
        <div align="center"><h5><?=JText::_('COM_USERS_PROFILE_SPECIALIST_DESC')?><span class="star">&#160;*</span></h5>
            <div class="specialist">
                <select data-val="" id="jform_interested" name="jform[interested]" class="form-control" aria-required="true">
                    <option value="" selected="selected"><?=JText::_('COM_USERS_PROFILE_PROFESSION_DESC')?></option>
                    <option><?=JText::_('COM_USERS_PROFILE_YES_DESC')?></option>
                    <option><?=JText::_('COM_USERS_PROFILE_NO_DESC')?></option>
                </select>
                <span id="intr_error"></span>
            </div>
        </div>
        <br/>
        
        <div class="form-group">
            <label class="control-label col-sm-1" for="jform_gdpr0"><strong></strong></label>
            <div class="col-md-10">
                <input required type="checkbox" id="jform_gdpr0" name="jform[gdpr][]" value="1" />&nbsp; <?=JText::_('COM_USERS_PROFILE_PRIVACYPOLICY_LABEL')?><span class="star">&#160;*</span>
                <span id="gdpr_error"></span>
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-sm-1" for="jform_captcha"><strong></strong></label>
            <div class="col-md-10">
                <div id="jform_captcha" class="g-recaptcha  required" data-sitekey="6LfL02MUAAAAAH8X6adVdUk7N1klV8np168RfDmK" data-theme="light" data-size="normal"></div>
            </div>
        </div>

        <div class="wsreg_buttonarea" align="center">
            <button id="trial" type="submit" class="sppb-btn sppb-btn-square sppb-btn-lg btn-block custom-bilikek-button-by-dori-to-piss-off-zsolti"><?=JText::_('COM_USERS_PROFILE_TRIAL_LABEL')?>&nbsp;<span class="arrow">&#10230;</span></button>
            <input type="hidden" name="option" value="com_users" />
            <input type="hidden" name="task" value="registration.register" />
            <?php echo JHtml::_('form.token');?>
        </div>
        
        <input type="hidden" name="jform[name]" id="jform_name" value="formatName" class="inputbox" />
    </form>
</div>

<?php endif;?>
<?php if ( $text_outro != '' ) : ?><div class="wsreg_outro"><?php echo $text_outro ; ?></div><?php endif; ?>

<script>
    $(document).ready(function() {
        $("#trial").click(function(){
            if ( $("#jform_firstname").val().length == 0 ) {
                $("#fname_error").html("Please enter your first name");
                return false;
            } else if ( $("#jform_lastname").val().length == 0 ) {
                $("#lname_error").html("Please enter your last name");
                return false;
            } else if ( $("#jform_email1").val().length == 0 ) {
                $("#email_error").html("Please enter your email");
                return false;
            } else if ( $("#jform_email2").val().length == 0 ) {
                $("#email_error2").html("Please confirm your email");
                return false;
            } else if ( $("#jform_password1").val().length == 0 ) {
                $("#pw_error").html("Please enter your password");
                return false;
            } else if ( $("#jform_password2").val().length == 0 ) {
                $("#pw_error2").html("Please confirm your password");
                return false;
            } else if ( $("#jform_phone").val().length == 0 ) {
                $("#phone_error").html("Please enter your phone number");
                return false;
            } else if ( $("#jform_profession").val().length == 0 ) {
                $("#prof_error").html("Please select a profession");
                return false;
            } else if ( $("#jform_country").val().length == 0 ) {
                $("#ctr_error").html("Please select a country");
                return false;
            } else if ( $("#jform_interested").val().length == 0 ) {
                $("#intr_error").html("Please select");
                return false;
            } else if ( $('#jform_gdpr0').is(':checked') == false) {
                $("#gdpr_error").html("Please accept the privacy policy");
                return false;
            }
        });
    });
</script>