app/views/alumns/show.html.erb
<%= render "layouts/navbar" %>
<br>
<br>
<% if flash[:success]%>
<div class="alert alert-success" role = "alert"><%= flash[:success]%></div>
<% end %>
<% if flash[:notice]%>
<div class="alert alert-warning" role = "alert"><%= flash[:notice]%></div>
<% end %>
<section class="content-section" id="alumns-desc">
<div class="container">
<div class="pull-right">
<%if is_principal? %>
<%= link_to '<span class="fa fa-edit"></span> Editar'.html_safe, edit_alumn_path(@alumn), class:"btn btn-sm btn-default" %>
<%= link_to '<span class="fa fa-times"></span> Excluir'.html_safe, "", method: :delete, class:'btn btn-sm btn-danger', data: { confirm: 'Tem certeza? Essa alteração não pode ser desfeita.' }, name:"delete" %>
<%= link_to '<span class="fa fa-address-card"></span> Advertir'.html_safe, new_alumn_strike_path(@alumn), class:'btn btn-sm btn-warning' %>
<%= link_to '<span class="fa fa-address-card"></span> Suspender'.html_safe, new_alumn_suspension_path(@alumn), class:'btn btn-sm btn-danger' %>
<%end%>
<%if @alumn.strikes.any?%>
<%= link_to '<span class="fa fa-edit"></span"></span> Visualizar Advertências'.html_safe, alumn_strikes_path(@alumn), class:"btn btn-sm btn-crown-of-thorns" %>
<%end%>
<%if @alumn.suspensions.any?%>
<%= link_to '<span class="fa fa-edit"></span"></span> Visualizar Suspensões'.html_safe, alumn_suspensions_path(@alumn), class:"btn btn-sm btn-jacarta" %>
<%end%>
</div>
<div class="row item">
<div class="col-sm-12 col-md-4">
<% if @alumn.image_file_name == nil %>
<%= image_tag("avatar_250x300.png", alt: "", class: "img-responsive" ) %>
<% else %>
<%= image_tag(@alumn.image.url(:original), alt: "", class: "img-responsive") %>
<%end%>
</div>
<div class="col-sm-12 col-md-8 text-capitalize descript">
<h3>Nome: <%= @alumn.name %></h3>
<h4>Telefone: <%= @alumn.phone %></h4>
<h4>Sexo: <%= @alumn.gender %></h4>
<h4>Endereço: <%= @alumn.address %></h4>
<h4>Data de Nascimento:
<% if(!@alumn.birth_date.nil?)%>
<%= @alumn.birth_date.strftime("%d/%m/%Y") %>
<%end%>
</h4>
<h4>Turma: <%= @alumn.classroom.name_classroom %></h4>
<h4><%=link_to "Responsável: #{@alumn.parent.name}",parent_path(@alumn.parent), class: "btn btn-default" %></h4>
<h4><%= link_to "Ver relatório", alumn_report_path(@alumn), class: "btn btn-primary", name: "report_link" %></h4>
</div>
</div>
<ul class="nav nav-tabs">
<li class="active" role="presentation"><a href="#faltas" aria-controls="faltas" role="tab" data-toggle="tab">Faltas</a></li>
<li role="presentation"><a href="#boletim"aria-controls="boletim" role="tab" data-toggle="tab">Boletim</a></li>
</ul>
<div>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="faltas">
<ul>
<% @alumn.school_misses.all.reverse.each do |miss| %>
<% if (@current_user.is_a?(Principal)) %>
<br>
<li class="text-danger"><%= miss.date.strftime('%d/%m/%Y') %>
</li>
<% else %>
<br>
<li class="text-danger"><%= miss.date.strftime('%d/%m/%Y') %></li>
<% end %>
<% end %>
</ul>
</div>
<div role="tabpanel" class="tab-pane" id="boletim">
<div class="col-sm-12 col-md-8 text-capitalize descript">
<ul>
<h4>Primeiro Bimestre</h4>
<% @alumn.classroom.subjects.each do |subject| %>
<li class="text-danger"><%= subject.name_subject%>
<% subject.grades.where(alumn_id: @alumn.id).each do |grade| %>
<%= grade.grade_01%></li>
<%end%>
<%end%>
</ul>
</div>
<div class="col-sm-12 col-md-8 text-capitalize descript">
<ul>
<h4>Segundo Bimestre</h4>
<% @alumn.classroom.subjects.each do |subject| %>
<li class="text-danger"><%= subject.name_subject%>
<% subject.grades.where(alumn_id: @alumn.id).each do |grade| %>
<%= grade.grade_02%></li>
<%end%>
<%end%>
</ul>
</div>
<div class="col-sm-12 col-md-8 text-capitalize descript">
<ul>
<h4>Terceiro Bimestre</h4>
<% @alumn.classroom.subjects.each do |subject| %>
<li class="text-danger"><%= subject.name_subject%>
<% subject.grades.where(alumn_id: @alumn.id).each do |grade| %>
<%= grade.grade_03%></li>
<%end%>
<%end%>
</ul>
</div>
<div class="col-sm-12 col-md-8 text-capitalize descript">
<ul>
<h4>Quarto Bimestre</h4>
<% @alumn.classroom.subjects.each do |subject| %>
<li class="text-danger"><%= subject.name_subject%>
<% subject.grades.where(alumn_id: @alumn.id).each do |grade| %>
<%= grade.grade_04%></li>
<%end%>
<%end%>
</ul>
</div>
<div class="col-sm-12 col-md-8 text-capitalize descript">
<ul>
<h4>Nota Final</h4>
<% @alumn.classroom.subjects.each do |subject| %>
<li class="text-danger"><%= subject.name_subject%>
<% subject.grades.where(alumn_id: @alumn.id).each do |grade| %>
<%= grade.grade_final%></li>
<%end%>
<%end%>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</section>