<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title" id="reset-label">Solicitar redefinição de senha</h4>
</div>
<div class="modal-body">
    <div id="reset-msg"></div>
    <form id="reset-form">
        <div class="form-group">
            <label>Email:</label>
            <input type="email" class="form-control" name="email" required>
        </div>
    </form>
</div>
<div class="modal-footer">
    <button type="submit" class="btn btn-success" form="reset-form" id="reset-btn">Solicitar</button>
</div>

<script>
$('#reset-form').submit(function(evt) {
    evt.preventDefault();
    
    var $frm = $(this);
    var $btn = $('#reset-btn');
    var $msg = $('#reset-msg');
    
    $btn.prop('disabled', true);
    $msg.removeAttr('class').text('');
    
    $.post('<?= (Base::instance()->alias("softsat_locacao_redefinir")) ?>', $frm.serialize(), function(resp) {
        if(resp.error) {
            $msg.text(resp.message).attr('class', 'alert alert-danger');
            return;
        }
        
        $('#reset').modal('hide');
        //$frm.find('input').val('');
    }, 'json').fail(function() {
        alert('Falha na requisição, contate o administrador');
    }).always(function() {
        $btn.prop('disabled', false);
    });
    
    return false;
});
</script>