<% if (params[:controller]=="emo_months") && (params[:action]=="new") %> <% if params[:emo_month].present? && params[:emo_month][:person_id].is_valid_id? %> <% current_person_id = params[:emo_month][:person_id] %> <% else %> <% current_person_id = params[:filterperson_id] %> <% end %> <% if current_person_id.is_valid_id? %> <% current_person = Person.find(current_person_id) %> <% end %> <% if params[:emo_month].present? && params[:emo_month][:competenza].is_valid_date? %> <% current_competenza = params[:emo_month][:competenza].to_date %> <% elsif @emo_month.competenza.is_valid_date? %> <% current_competenza = @emo_month.competenza %> <% else %> <% current_competenza = ApplicationController.helpers.daterange_current #params[:filterdate] %> <% end %> <% elsif (params[:controller]=="emo_months") && (["edit","show"].include?(params[:action])) %> <% current_emo_function_id = @emo_month.emo_function_id %> <% if current_emo_function_id.is_valid_id? %> <% current_emo_function = EmoFunction.find(current_emo_function_id) %> <% current_person_id = current_emo_function.person_id %> <% if current_person_id.is_valid_id? %> <% current_person = Person.find(current_person_id) %> <% end %> <% end %> <% if params[:emo_month].present? && params[:emo_month][:competenza].is_valid_date? %> <% current_competenza = params[:emo_month][:competenza].to_date %> <% elsif @emo_month.competenza.is_valid_date? %> <% current_competenza = @emo_month.competenza %> <% else %> <% current_competenza = ApplicationController.helpers.daterange_current #params[:filterdate] %> <% end %> <% end %> <% if current_person.present? && current_competenza.is_valid_date? %>

Riepilogo <%= EmoMonth.label %> di <%= current_person.full_person_name %> per <%= daterange_name(current_competenza) %>

<% emo_functions = EmoFunction.search({filterperson_id: current_person.id, filterdate: current_competenza}) %> <% if emo_functions %>
<% emo_month_totals = EmoMonth.new %> <% emo_month_totals[:ore_effettive] = 0.0 %> <% emo_month_totals[:ore_bp] = 0.0 %> <% emo_month_totals[:monthly_hours] = 0.0 %> <% emo_month_totals[:rimborsi_vari] = 0.0 %> <% emo_month_totals[:rimborso_bp] = 0.0 %> <% emo_month_totals[:rimborso_km] = 0.0 %> <% emo_month_totals[:busta_paga] = 0.0 %> <% emo_month_totals[:totalemese_importo] = 0.0 %> <% emo_month_totals[:compenso_importo] = 0.0 %> <% emo_month_totals[:importo_versato] = 0.0 %> <% emo_month_totals[:importo_scalato] = 0.0 %> <% emo_month_totals[:importo_dapagare] = 0.0 %> <% emo_functions.each do |emo_function| %> <% emo_month = EmoMonth.search({filteremofunction_id: emo_function.id, filterdate: current_competenza}).take %> <% if emo_month.blank? %> <% emo_month = EmoMonth.new %> <% end %> <% emo_month_totals[:ore_effettive] += (emo_month[:ore_effettive] || 0.0) %> <% emo_month_totals[:ore_bp] += (emo_month[:ore_bp] || 0.0) %> <% emo_month_totals[:monthly_hours] += (emo_month[:monthly_hours] || 0.0) %> <% emo_month_totals[:rimborsi_vari] += (emo_month[:rimborsi_vari] || 0.0) %> <% emo_month_totals[:rimborso_bp] += (emo_month[:rimborso_bp] || 0.0) %> <% emo_month_totals[:rimborso_km] += (emo_month[:rimborso_km] || 0.0) %> <% emo_month_totals[:busta_paga] += (emo_month[:busta_paga] || 0.0) %> <% emo_month_totals[:totalemese_importo] += (emo_month[:totalemese_importo] || 0.0) %> <% emo_month_totals[:compenso_importo] += (emo_month[:compenso_importo] || 0.0) %> <% emo_month_totals[:importo_versato] += (emo_month[:importo_versato] || 0.0) %> <% emo_month_totals[:importo_scalato] += (emo_month[:importo_scalato] || 0.0) %> <% emo_month_totals[:importo_dapagare] += (emo_month[:importo_dapagare] || 0.0) %> <% end %>
<%= EmoMonth.human_attribute_name(:emo_sector_id) %> <%= EmoMonth.human_attribute_name(:emo_function_id) %> <%= EmoMonth.human_attribute_name(:ore_effettive) %> <%= EmoMonth.human_attribute_name(:ore_bp) %> <%= EmoMonth.human_attribute_name(:monthly_hours) %> <%= EmoMonth.human_attribute_name(:rimborsi_vari).gsub('/'," / ") %> <%= EmoMonth.human_attribute_name(:rimborso_bp) %> <%= EmoMonth.human_attribute_name(:rimborso_km) %> <%= EmoMonth.human_attribute_name(:busta_paga).gsub('/'," / ") %> <%= EmoMonth.human_attribute_name(:totalemese_importo) %> <%= EmoMonth.human_attribute_name(:compenso_importo) %> <%= EmoMonth.human_attribute_name(:importo_versato) %> <%= EmoMonth.human_attribute_name(:importo_scalato) %> <%= EmoMonth.human_attribute_name(:importo_dapagare).gsub('/'," / ") %>
<%= notetext(emo_function.emo_sector.descrizione) %> <%= notetext(emo_function.descrizione) %><%= money_format_zero(emo_month[:ore_effettive]) %> <%= money_format_zero(emo_month[:ore_bp]) %> <%= money_format_zero(emo_month[:monthly_hours]) %> <%= money_format_zero(emo_month[:rimborsi_vari]) %> <%= money_format_zero(emo_month[:rimborso_bp]) %> <%= money_format_zero(emo_month[:rimborso_km]) %> <%= money_format_zero(emo_month[:busta_paga]) %> <%= money_format_zero(emo_month[:totalemese_importo]) %> <%= money_format_zero(emo_month[:compenso_importo]) %> <%= money_format_zero(emo_month[:importo_versato]) %> <%= money_format_zero(emo_month[:importo_scalato]) %> <%= money_format_zero(emo_month[:importo_dapagare]) %>
totali: <%= money_format_zero(emo_month_totals[:ore_effettive]) %> <%= money_format_zero(emo_month_totals[:ore_bp]) %> <%= money_format_zero(emo_month_totals[:monthly_hours]) %> <%= money_format_zero(emo_month_totals[:rimborsi_vari]) %> <%= money_format_zero(emo_month_totals[:rimborso_bp]) %> <%= money_format_zero(emo_month_totals[:rimborso_km]) %> <%= money_format_zero(emo_month_totals[:busta_paga]) %> <%= money_format_zero(emo_month_totals[:totalemese_importo]) %> <%= money_format_zero(emo_month_totals[:compenso_importo]) %> <%= money_format_zero(emo_month_totals[:importo_versato]) %> <%= money_format_zero(emo_month_totals[:importo_scalato]) %> <%= money_format_zero(emo_month_totals[:importo_dapagare]) %>
<% else %> Non ci sono funzioni assegnate a questa persona. <% end %>
<% end %>