<!--Cabecalho -->
<?php $this->load->view('commons/cabecalho'); ?>
<!--Header -->
<?php $this->load->view('commons/header'); ?>
<br><br>
<style>
    @media only screen and (min-width: 768px){
        #form-r{
            margin-top: 10px;

        }
        #bote{

            margin-top: 20px;
        }

    }
</style>
<div class="container"> 

    <div class="row">
        <?php echo $this->session->flashdata('erro'); ?> 
        <?php echo $this->session->flashdata('sucesso'); ?> 
    </div>
    <h5>PROMOÇÃO RELÂMPAGO, ENVIE AGORA!!</h5>
    <div class="row">

        <form method="post" action="<?= base_url('cursos_gratis') ?>">

            <div class="col m12 s12">
                <div class="input-field col m9 s12">
                    <i class="material-icons prefix">search</i>  
                    <input id="curso-p" type="text" class="validate curso-p" name="nome" required="">
                    <label for="curso-p">Digite uma palavra</label>

                </div>

                <button class="btn waves-effect waves-light btn-curso btn-end col m2 s12" id="bote" type="submit" style="padding-left: 20px; padding-right: 20px;">Pesquisar</button>
            </div>

        </form>
    </div>

    <div class="opcao-d">    
        <div class="row">
            <div class="col s12">
                <?php echo $this->session->flashdata('matriculado-l-erro'); ?>
                <?php echo $this->session->flashdata('sucesso-escolha'); ?>

            </div>

        </div>
    </div>

    <div class="col s12">
        <?php echo $pagination ?>
    </div>
    <?php foreach ($curso as $c) { ?>
        <div class="row">
            <div class="col m12 s12">
                <?= "<b>GRÁTIS</b> CURSO " . $c->nome . " 8 HORAS" ?>

                <?php if (empty($_SESSION['aluno'])) { ?>
                    <br>
                    <a href="login_site" class="waves-effect waves-light btn btn-curso btn-matricular-curso " >USAR OU ENVIAR PARA AMIG@S</a>
                    <hr>
                    <?php
                } else {
                    ?>
                    <br>
                    <button  class="btn btn-curso btn-matricular-curso" data-id="<?= $c->id_curso ?>">USAR OU ENVIAR PARA AMIG@S</button>
                    <hr>
                <?php } ?>
            </div>
        </div>
    <?php }
    ?>
    <div class="col s12">
        <?php echo $pagination ?>
    </div>   
</div>

<!--Opcao -->
<br><br>
<!-- Modal Trigger -->


<!-- Modal Structure -->
<div id="cadastro_email" class="modal">


    <div class="row">
        <form method="post" action="<?= base_url('cursos_gratis_matricula') ?>">

            <div class="col m12 s12">
                <div class="input-field col m9 s12">

                    <input id="curso-p" type="text" class="validate curso-p" name="email" required="">
                    <input type="hidden" name="id_curso" id="id_curso">
                    <label for="curso-p">Informe o Email do AMIG@</label>

                </div>

                <button class="btn waves-effect waves-light btn-curso btn-end col m2 s12" id="bote" type="submit" style="padding-left: 20px; padding-right: 20px;">Enviar</button>
            </div>

        </form>
    </div>
</div>

<script>
    $('body').delegate('.btn-matricular-curso', 'click', function () {
        var id = $(this).attr("data-id");
        $("#id_curso").val(id);
        $("#cadastro_email").modal("open");

    });
</script>

<?php if (isset($_SESSION['aluno']) == FALSE) { ?> 
    <?php $this->load->view('commons/opcao'); ?>
<?php } ?>
<?php $this->load->view('commons/rodape'); ?>
