<?= $this->doctype('XHTML1_STRICT'); ?>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <script type="text/javascript" src="/resources/jquery/jquery.js"></script>
  <link rel="Stylesheet" href="/resources/css/login.css" type="text/css"/>
  <style type="text/css">
  </style>
    <?= $this->headTitle() ?>
</head>
<body>
<div class="geral">
  <div class="logo"></div>
  <div class="login">
    <div class="key"></div>
    <div class="form">
      <div>Preencha corretamente o usuário para gerar uma nova senha.</div>
      <div class="<?= ($this->msg ? $this->class : '') ?>" style="padding-bottom: 5px"><?= $this->msg; ?></div>
      <form enctype="application/x-www-form-urlencoded" class="formDefault" id="formDefault" action="" method="post">
        <input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response"/>
        <div class="input">
          <label>Usuário de Acesso ao Agronet</label>
          <input type="text" name="usuario" id="usuario" value="" size="35">
        </div>
        <div class="input">
          <button type="submit" name="recuperar" id="recuperar" value="recuperar">Enviar e-mail</button>
        </div>
      </form>
      <div>
        <a href="/login">Retornar a página de login.</a>
      </div>
    </div>
  </div>
</div>
<div class="producted">
  <div class="nome">
    <a href="https://www.agrobrasilseguros.com.br/"
       target="_blank"
       style="text-decoration: none;">AgroBrasil Operadora de Seguro Agrícola
    </a>
  </div>
</div>
<script>
  $(document).ready(function () {
    $('#usuario').focus();
    if ($('.msg_erro').length > 0) {
      setTimeout(() => {
        $('.msg_erro').html('');
        $('.msg_erro').removeClass('msg_erro');
      }, 5000);
    }

    <? if ($this->ambienteProducao): ?>
      let form = document.getElementById('formDefault');

      form.addEventListener('submit', (e) => {
        e.preventDefault();
        grecaptcha.enterprise.ready(() => {
          grecaptcha.enterprise.execute(
            '<?=RECAPTCHA_SITE_KEY?>',
            {action: 'submit'}
          ).then((token) => {
            document.getElementById('g-recaptcha-response').value = token;
            form.submit();
          })
        })
      })
    <? endif; ?>
  });
</script>
<? if ($this->ambienteProducao): ?>
  <script src='https://www.google.com/recaptcha/enterprise.js?render=<?= RECAPTCHA_SITE_KEY ?>' async refer></script>
<? endif; ?>
</body>
</html>
