<?php

// Página
$direct = 'pergunta';

// Checa se o usuário possui acesso na página
Util::verificaAcesso('cms-' . $direct, 'inserir', '?i=cms-' . $direct);

// Mensagem de Retorno
require_once $GLOBALS['baseDir'] . 'includes/mensagens.php';

echo Form::open($GLOBALS['baseUrl'] . '?i=cms-' . $direct . '-processo&t=inserir', array('name' => 'form', 'id' => 'form', 'class' => 'form bg clearfix'));

    echo '<div class="wrapper">';
        echo '<div class="col-md-2">';
            echo '<p>Pergunta: *</p>';
            echo Form::text('', 'pergunta', '', 255, array('class' => 'dois'));
        echo '</div>';

        echo '<div class="col-md-2">';
            echo '<p>Categoria: </p>';
            echo Form::select('', 'categoria', Categoria::arraySelect(), false, array('class' => 'dois select hide-search'));
        echo '</div>';
    echo '</div>';
    
    echo '<div class="wrapper">';
        echo '<div class="col-md-2">';
            echo '<p>Resposta 1: *</p>';
            echo Form::text('', 'resposta_1', '', 255, array('class' => 'tres'));
        echo '</div>';
        echo '<div class="col-md-2">';
            echo '<p>Roteiro 1: *</p>';
            echo Form::select('', 'peso_1', Qrcode::arraySelect(), false, array('class' => 'dois select hide-search'));
        echo '</div>';
    echo '</div>';
    echo '<div class="wrapper">';
        echo '<div class="col-md-2">';
            echo '<p>Resposta 2: *</p>';
            echo Form::text('', 'resposta_2', '',255, array('class' => 'dois'));
        echo '</div>';
        echo '<div class="col-md-2">';
            echo '<p>Roteiro 2: *</p>';
            echo Form::select('', 'peso_2', Qrcode::arraySelect(), false, array('class' => 'dois select hide-search'));
        echo '</div>';
    echo '</div>';
    echo '<div class="wrapper">';
        echo '<div class="col-md-2">';
            echo '<p>Resposta 3: *</p>';
            echo Form::text('', 'resposta_3', '', 255, array('class' => 'dois'));
        echo '</div>';
        echo '<div class="col-md-2">';
            echo '<p>Roteiro 3: *</p>';
            echo Form::select('', 'peso_3', Qrcode::arraySelect(), false, array('class' => 'dois select hide-search'));
        echo '</div>';
    echo '</div>';

    echo Form::button('Salvar', array('class' => 'salvar'));
    echo Form::button('Voltar', array('class' => 'voltar', 'onclick' => "window.location='?i=cms-$direct';"));

echo Form::close();
?>

<script>
$('#busca').css('display', 'none');

$(".salvar").click(function () {
    var validacao = validaCampos('pergunta,categoria');

    if (validacao == true) {
        $(this).html('Enviando..');
        $(this).prop('disabled', true);
        $("#form").submit();
    }
});
</script>
