 <?php 
 $curso = $this->obj;

 $url = BASE_URL.'cursos/ver/'.$curso->id.'-'.Pampa_Util_String::url($curso->shortname);
 $urlInscricao = BASE_URL.'cursos/inscricao/'.$curso->id.'-'.Pampa_Util_String::url($curso->shortname);

  $dataInicio = $curso->startdate;// strtotime(date('d/m/Y',$curso->startdate));
  $dataHj = strtotime(date("Y-m-d"));

  ?>
  <div id="conteudo">

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-10">
                <br>
                <br>
                <article class="noticia detalhe">

                    <div class="row navegacao hidden-xs">
                        <div class="col-sm-12">
                            <a class="btn btn-grey inverse" href="javascript:history.back();" role="button"><img style="top: -1px; position: relative;" src="assets/images/seta-left.svg" alt="">&nbsp;VOLTAR</a>
                        </div>
                    </div>

                    <div class="row alinhamento-vertical">

                        <div class="col-sm-6">
                            <header>

                                <h1><?=$curso->fullname?></h1>
                            </header>



                        </div>

                        <div class="col-sm-6">

                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-12">
                            <h3>Formulário de inscrição</h3>
                            
                            <form action="<?=BASE_URL?>cursos/formulario/id/<?=$this->obj->id?>" method="POST" role="form"  enctype="multipart/form-data"> 
                                <input type="hidden" name="obj[user_id]" value="<?=$_SESSION[NOME_SESSAO]['usuario']->id?>">
                                <input type="hidden" name="obj[curso_id]" value="<?=$this->obj->id?>">
                                <?php 
                                foreach ($this->campos as $campo) {
                                    $valor = '';
                                    foreach ($this->preenchidos as $preenchido) {
                                        if($preenchido->campo_id == $campo->id){
                                          $valor = $preenchido->valor;  
                                          break;
                                        }
                                    }
                                    if($campo->tipo == 'file'){
                                        ?>
                                         <div class="row">
                                            <div class="col-sm-6">
                                                <div class="form-group">
                                                    <label for="" style="text-transform: capitalize;"><?= $campo->label?></label>
                                                    <input type="file" required="" name="arquivo_<?=$campo->id?>">
                                                    
                                                    <?=(!empty($valor) ? '<p class="help-block"><a target="_blank" href="'.BASE_URL.'uploads/inscricoes/'.$valor.'">Ver arquivo atual</a><p>' : '')?>
                                                </div>
                                            </div>
                                        </div>
                                        <?php
                                    }else if($campo->tipo == 'checkbox'){
                                        ?>
                                         <div class="row">
                                            <div class="col-sm-6">
                                                <div class="form-group">
                                                    <label for=""  style="text-transform: capitalize;"> <input type="checkbox" name="campos[<?=$campo->id?>]" <?=($valor=='1' ? 'checked="checked"' : '')?> value="1" class="" style="display: inline-block;" id=""> <?= $campo->label?> </label>
                                                    
                                                </div>
                                            </div>
                                        </div>
                                        <?php
                                    }else {

                                        ?>
                                        <div class="row">
                                            <div class="col-sm-6">
                                                <div class="form-group">
                                                    <label for="" style="text-transform: capitalize;"><?= $campo->label?></label>
                                                    <input type="text"  required="" name="campos[<?=$campo->id?>]" value="<?=$valor?>" class="form-control" id="" >
                                                </div>
                                            </div>
                                        </div>
                                        <?php 
                                    }
                                }
                                ?>
                                <div class="row">
                                 <div class="col-sm-12">
                                    <button type="submit" class="btn btn-orange" style="margin:0;">Enviar</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>

            </article>

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

</div>