<!--Cabecalho -->
<?php $this->load->view('commons/cabecalho'); ?>
<script>
    function resizeIframe(obj) {
        obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
    }
    $(document).ready(function () {
    <?php if (empty($documentacao['documento'])) { ?>
    $('select[name="tipo"]').prop('disabled', false);
    <?php } else { ?>
    $('select[name="tipo"]').prop('disabled', true);
    <?php } ?>    
    });

</script>
<!--Header -->
<?php $this->load->view('commons/header'); ?>
<style>
    select {
        border: 1px solid gray;
    }
</style>
<br>

<div class="row conteudo-acessar">

    <h4 style="font-size: 30pt;" class="text-mobile"><b>Meus Dados</b></h4>
    <?php echo $this->session->flashdata('erro-email'); ?>
    <?php echo $this->session->flashdata('sucesso-dados'); ?>
    <?php echo $erro_conf ?>
    <?php echo $this->session->flashdata('sucesso-upload'); ?>
    <?php echo $this->session->flashdata('sucesso-documento'); ?>
    <?php echo $this->session->flashdata('erro-documento'); ?>
    <?php echo $this->session->flashdata('sucesso-senha'); ?>
    <?php echo $this->session->flashdata('erro-senha'); ?>
    <?php echo $this->session->flashdata('erro-assinatura'); ?>
    <?php echo $this->session->flashdata('falha'); ?>
    <?php echo $this->session->flashdata('falhageral'); ?>
    <?php echo $this->session->flashdata('maximatentativa'); ?>
    <?php if (isset($error_upload)): ?>
        <?php echo $error_upload ?>
    <?php endif; ?>
    <div class="col s12">
        <ul class="tabs">
            <li class="tab col s2"><a class="active" href="#meusdados">Endereço</a></li>
            <li class="tab col s2"style="margin-left: -4%;"><a href="#nome">Nome</a></li>
            <li class="tab col s2"style="margin-left: -4%;"><a href="#email">E-mail</a></li>
            <li class="tab col s2"style="margin-left: -4%;"><a href="#documentos">Documentos (CPF e RG)</a></li>
            <li class="tab col s2"style="margin-left: -4%;"><a href="#senha">Senha</a></li>
            <li class="tab col s3"style="margin-left: -4%;"><a href="#notificacoes">Preferência de Notificações</a></li>
        </ul>
    </div>
    <div  id="meusdados" class="col s12">
        <br>
        <form action="<?= base_url('dados') ?>" method="POST" autocomplete="off">
            <div class="row">
                <div class="input-field col s12 m4">
                    <i class="material-icons prefix">loupe</i>  
                    <input class="ceps cep-conf" id="cep" type="tel" name="cep" required="" pattern="\d{5}-\d{3}" placeholder="CEP"  value="<?php echo $aluno['cep'] ?>">
                    <label for="nome">CEP</label>
                </div>
                <div class="input-field col s12 m8">
                    <i class="material-icons prefix">location_on</i>  
                    <input id="endereco" type="text" name="endereco" required="" placeholder="Endereço"  value="<?php echo $aluno['endereco'] ?>">
                    <label for="endereco">Endereço</label>
                </div>
            </div>
            <div class="row">
                <div class="input-field col  s12 m4">
                    <i class="material-icons prefix">looks_one</i>
                    <input id="numero" type="text"  required="" name="numero" pattern="[a-zA-Z0-9]+" maxlength="10" placeholder="Número"  value="<?php echo $aluno['numero'] ?>">
                    <label for="numero">Número</label>
                </div>
                <div class="input-field col s12 m8">
                    <i class="material-icons prefix">home</i>  
                    <input id="complemento" type="text" name="complemento"  placeholder="Complemento"  value="<?php echo $aluno['complemento'] ?>">
                    <label for="complemento">Complemento</label>
                </div>
            </div>
            <div class="row">
                <div class="input-field col s12 m4">
                    <i class="material-icons prefix">equalizer</i>  
                    <input id="bairro" type="text" name="bairro" required="" placeholder="Bairro"  value="<?php echo $aluno['bairro'] ?>">
                    <label for="bairro">Bairro</label>
                </div>
                <div class="input-field col s12 m4">
                    <i class="material-icons prefix">location_city</i>  
                    <input id="cidade" type="text" name="cidade" required="" placeholder="Cidade"  value="<?php echo $aluno['cidade'] ?>">
                    <label for="cidade">Cidade</label>
                </div>
                <div class="input-field col s12 m4">
                    <i class="material-icons prefix">language</i>  
                    <input id="uf" type="text" name="estado" required="" minlength="2"  maxlength="2" placeholder="Estado"  value="<?php echo $aluno['estado'] ?>">


                    <label for="estado">Estado</label>
                </div>
            </div>
            <div class="row">
                <div class="input-field col s5 m2">
                    <i class="material-icons prefix">phone</i>
                    <input id="ddd_celular" type="tel" class="only-number" required="" name="ddd_celular" maxlength="2" minlength="2"  pattern="[0-9]+$" placeholder="DDD"  value="<?php echo $aluno['ddd'] ?>">
                    <label for="ddd_celular">DDD</label>
                </div>
                <div class="input-field col s7 m2">
                    <i class="material-icons prefix">phone_iphone</i>
                    <input type="tel" class="only-number" required="" name="celular" maxlength="9" minlength="9"  pattern="[0-9]+$" placeholder="Celular"  value="<?php echo $aluno['telefone'] ?>">
                    <label for="celular">Celular</label>
                </div>
            </div>
            <button class="btn waves-effect waves-light btn-curso btn-end" type="submit" name="action" style="">&nbsp;&nbsp;Enviar&nbsp;&nbsp;</button>
        </form>
    </div>
    <div  id="nome" class="col s12">
        <br>

        <div class="row">
            
            <?php 
            
            ?>
            <?php if ($_SESSION['aluno']['situacao'] > 0) { ?>
            <div class="input-field col s12 m12">
                <i class="material-icons prefix">account_circle</i>  
                <input class="nome" type="text" name="nome-aluno" required="" placeholder="Nome Completo"  disabled="" value="<?php echo $aluno['nome'] ?>">
                <label for="nome">Nome Completo</label>
            </div>
            <?php } else { ?>
            <form method="POST" action="<?= base_url('ConfirmaDados/alterarnome')?>">
                <div class="input-field col s12 m4" >
                    <i class="material-icons prefix">account_circle</i>  
                    <input class="nome" type="text" name="nome-aluno" required="" placeholder="Nome Completo"  value="<?php echo $aluno['nome'] ?>">
                    <label for="nome">Nome Completo</label>
                </div>
                <button class="btn waves-effect waves-light" style="margin-top: 1.2%;">ALTERAR NOME</button>
            </form>
            <?php } ?>
            
            <?php if ($_SESSION['aluno']['situacao'] != 0) { ?>
                <?php if ($controle->dataDiferenca() > 30) { ?> 
                    <a class="modal-trigger btn waves-effect waves-light btn-curso btn-end" data-target="reconsultar_cpf" modal-trigger style="margin-top: 25px;">Alterar Nome</a>
                <?php } ?>
            <?php } ?>
            <h5>Outros Cadastros nesse site</h5> 
            <?php 
            $this->db->where('nome', $aluno['nome']);
            $this->db->where('email != "' .$aluno['email'] . '" ');
            $aluno = $this->db->get('aluno')->result();
            if (!empty($aluno)) {
            ?>
            <?php foreach ($aluno as $alunos) { ?>
                <div class="col s12 m4">
                    <div class="card">
                        <div class="card-content">
                            <p>Nome: <?= $alunos->nome ?></p>
                            <p>Login: <?= $alunos->email ?></p>
                        </div>
                    </div>
                </div>
            <?php } ?>
            <?php } ?>
        </div>

    </div>
    <div  id="email" class="col s12">
        <br>
        <form action="<?= base_url('altera_email') ?>" method="POST" autocomplete="off">
            <div class="row">
                <div class="input-field col s12 m4">
                    <i class="material-icons prefix">mail</i>  
                    <input class="email" type="email" onkeyup="maiuscula(this)" disabled="" name="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" placeholder="Email Atual" value="<?php echo $aluno['email'] ?>">
                    <label for="email">Email Atual</label>
                </div>
                <div class="input-field col s12 m4">
                    <i class="material-icons prefix">mail</i>  
                    <input class="email" type="email" required="" onkeyup="maiuscula(this)" name="email_novo" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" placeholder="Novo E-mail">
                    <label for="email">Novo Email</label>
                </div>
                <button class="btn waves-effect waves-light btn-curso btn-end" type="submit" style="margin-top: 25px;">Enviar</button>
            </div>
        </form>
    </div>
    <div  id="documentos" class="col s12">
        <br>

        <form method="POST" action="<?php echo base_url('documentacao') ?>">
            <div class="row">
                <div class="col s12 m2">
                    <?php if ($documentacao['tipo_doc'] == 1) { ?>
                        <select required aria-required="true" name="tipo" class="browser-default">
                            <option value="1" selected>RG</option>
                            <option value="2">CPF</option>
                            <option value="3">CNH</option>
                        </select>
                    <?php } elseif ($documentacao['tipo_doc'] == 2) { ?>
                        <select required aria-required="true" name="tipo" class="browser-default">
                            <option value="1">RG</option>
                            <option value="2" selected>CPF</option>
                            <option value="3">CNH</option>
                        </select>    
                    <?php } elseif ($documentacao['tipo_doc'] == 3) { ?>    
                        <select required aria-required="true" name="tipo" class="browser-default">
                            <option value="1">RG</option>
                            <option value="2">CPF</option>
                            <option value="3" selected>CNH</option>
                        </select> 
                    <?php } elseif ($documentacao['tipo_doc'] != 1 && $documentacao['tipo_doc'] != 2 && $documentacao['tipo_doc'] != 3) { ?>
                        <select required aria-required="true" name="tipo" class="browser-default">
                            <option value="1">RG</option>
                            <option value="2">CPF</option>
                            <option value="3">CNH</option>
                        </select>    
                    <?php } ?>   
                </div>
                <div class="input-field col s12 m3">
                    <?php if (empty($documentacao['documento'])) { ?>
                    <input type="tel" class="only-number" required="" name="documento" pattern="[0-9]+$" maxlength="20" placeholder="Número (Somente números)"  value="<?= $documentacao['documento'] ?>">
                    <?php } else { ?>
                    <input type="tel" disabled="" class="only-number" required="" name="documento" pattern="[0-9]+$" maxlength="20" placeholder="Número (Somente números)"  value="<?= $documentacao['documento'] ?>">
                    <?php } ?>
                    <label for="documento">Número (Somente números)</label>
                </div>
                <?php if (empty($documentacao['documento'])) { ?>
                <button class="btn waves-effect waves-light btn-curso btn-end " type="submit" style="margin-top: 25px;">Enviar</button>
                <?php } else { ?>
                <button class="btn waves-effect waves-light btn-curso btn-end btn-select-tipo" disabled="" type="submit" style="margin-top: 25px;">Enviar</button>
                <?php } ?>
            </div>
        </form>
    </div>
    <div  id="senha" class="col s12">
        <br>
        <form method="POST" action="<?php echo base_url('alterasenha') ?>">
            <div class="row">
                <div class="input-field col s12 m4">
                    <input class="novasenha" type="password" name="senha-aluno" required="" placeholder="Digite a nova senha"  value="">
                    <label for="senha-aluno">Digite a nova senha</label>
                </div>
                <div class="input-field col s12 m4">
                    <input class="novasenha" type="password" name="senha-aluno-conf" required="" placeholder="Repita a nova senha"  value="">
                    <label for="senha-aluno-conf">Repita a nova senha</label>
                </div>
                <button class="btn waves-effect waves-light btn-curso btn-end" type="submit"  style="margin-top: 25px;">&nbsp;&nbsp;Enviar&nbsp;&nbsp;</button>
 
            </div>
 
        </form>
    </div>
    <div  id="notificacoes" class="col s12">
        <br>
        <iframe src="<?= $controle->iris(); ?>" onload="resizeIframe(this)" frameborder="0" style="min-height: 430px; height: 0px;" width="100%"></iframe>
    </div>
</div>
<br><br>

<?php $this->load->view('commons/rodape'); ?>
