<% if @fp_nilDate %> <% currentperiod = daterange_current() %> <% list_of_months = [] %> <% 1.downto(-12) do |m| %> <% list_of_months << currentperiod.next_month(m) %> <% end %> <% else %> <% currentperiod = @fp_valueDate %> <% list_of_months = [currentperiod] %> <% end %> <% if pundit_user.has_house_policyscope?(HouseQec) %> <% user_has_house_policyscope = true %> <% pundit_house_id = pundit_user.user.person.house_id %> <% ref_house_id = pundit_house_id %> <% ref_house = House.find(ref_house_id) %> <% else %> <% user_has_house_policyscope = false %> <% ref_house_id = @filter_params[:filterhouse_id] %> <% ref_house = ref_house_id.is_valid_id? ? House.find(ref_house_id) : nil %> <% end %>

<%= HouseQec.label %>

<%= form_tag(house_qecs_path, method: :get) do %> <%= view_table_open %> <%= view_table_row_open %> <%= render "shared/filterdate" %> <% if !pundit_user.has_house_policyscope?(HouseQec) %> <%= render "shared/filterhouse_id" %> <% end %> <%= view_table_row_close %> <%= view_table_close %> <% end %>
<% if ref_house_id.is_valid_id? %> <%= view_table_open %> <%= view_table_head_open %> <%= view_table_row_open %> <%= view_table_head_cell( HouseQec.human_attribute_name(:competenza), nil, 'LightGrey' ) %> <%= view_table_head_cell( 'Emissioni federali', nil, 'LightGrey' ) %> <%= view_table_head_cell( HousePn.label, nil, 'LightGrey' ) %> <%= view_table_head_cell( 'Piano dei conti', nil, 'LightGrey' ) %> <%= view_table_head_cell( HouseAdac.label, nil, 'LightGrey' ) %> <%= view_table_head_cell_span( 4, 'Emissioni di nucleo', 'LightGrey' ) %> <% if !user_has_house_policyscope %> <%= view_table_head_cell(nil, nil, 'LightGrey') %> <%= view_table_head_cell(nil, nil, 'LightGrey') %> <% end %> <%= view_table_row_close %> <%= view_table_head_close %> <%= view_table_body_open %> <% list_of_months.each do |month| %> <% next if month < HouseQecsHelper::DateStartOfHouseQecs %> <% filter = {filterdate: month, filterhouse_id: ref_house_id} %> <% house_qec = HouseQec.search(filter).first %> <% month_label = daterange_name(month) %> <% exist_any_data = false %> <% exist_any_data_message = "" %> <% if HousePn.search(filter).any? %> <% exist_any_data = true %> <% else %> <% exist_any_data_message += "Non ci sono movimenti in #{HousePn.label} in #{month_label}. "%> <% end %> <% if SrgQec.search(filter).any? %> <% exist_any_data = true %> <% else %> <% exist_any_data_message += "Emissione federale non disponibile per #{month_label}. "%> <% end %> <% if house_qec.present? or exist_any_data %> <%= view_table_row_open %> <%= view_table_cell ( "#{month_label}

#{month.month}

".html_safe ) %> <% if SrgQec.search(filter).any? %> <%#= view_table_cell (iconprintlink_to print_srg_qecs_path(@filter_params.merge(filterhouse_id: ref_house_id, filterdate: month, print_what: SrgQecsHelper::PrintEmissioneNucleo)), icon('file-pdf'), "Emissioni
federali di
#{daterange_name(month)}") %> <%= view_table_cell ( iconbutton_print(print_srg_qecs_path, "Emissioni
federali di
#{daterange_name(month)}", @filter_params.merge(filterhouse_id: ref_house_id, filterdate: month, print_what: SrgQecsHelper::PrintEmissioneNucleo), icon('file-pdf'), 'btn-warning') ) %> <% else %> <%= view_table_cell ("non disponibile...") %> <% end %> <%= view_table_cell ( iconbutton_to(house_pns_path, HousePn.modelIcon, 'btn-info', "Vedi
#{HousePn.label}
di #{month_label}", @filter_params.merge(filterhouse_id: ref_house_id, filterdate: month)) ) %> <%= view_table_cell ( iconbutton_to(view_crbs_table_house_qecs_path, icon('file-alt'), 'btn-info', "Piano dei conti
mensile di
#{daterange_name(month)}", {filterhouse_id: current_user.person.house_id, filterdate: month} ) ) %> <%= view_table_cell ( iconbutton_to(house_adacs_path, HouseAdac.modelIcon, 'btn-info', "Vedi
#{HouseAdac.label}
di #{month_label}", @filter_params.merge(filterhouse_id: ref_house_id, filterdate: month)) ) %> <% if house_qec.present? %> <%= view_table_cell () %> <%= view_table_cell ( iconbutton_to(print_house_qecs_path, icon('print'), 'btn-success', "Vedi
emissioni di
#{month_label}", @filter_params.merge(print_what: HouseQecsHelper::PrintEmissioneNucleoByCrb, filterhouse_id: ref_house_id, filterdate: month, print_mode: HouseQecsHelper::PrintHtml)) ) %> <% if house_qec.exist_next? %> <%= view_table_cell() %> <%= view_table_cell() %> <% else %> <% if month > HouseQecsHelper::DateStartOfHouseQecs %> <%= view_table_cell ( iconbutton_to(view_qecs_table_house_qecs_path, icon('file-alt'), 'btn-success', "Gestione incassi
per emissioni di
#{month_label}", @filter_params.merge(filterhouse_id: ref_house_id, filterdate: month)) ) %> <%= view_table_cell( iconbutton_to(massdelete_house_qecs_path, icon('trash'), 'btn-danger', "Elimina
emissioni di
#{month_label}", @filter_params.merge(delete_what: HouseQecsHelper::CancellaDatiNucleo, filterhouse_id: ref_house_id, filterdate: month), false, :delete) ) %> <% else %> <%= view_table_cell() %> <%= view_table_cell() %> <% end %> <% end %> <% if !user_has_house_policyscope %> <%= view_table_cell( iconbutton_view house_qec, '') %> <%= view_table_cell( iconbutton_edit edit_house_qec_path(house_qec), '') %> <% end %> <% else %> <% if exist_any_data and (month > HouseQecsHelper::DateStartOfHouseQecs) %> <%= view_table_cell( iconbutton_to(calc_house_qecs_path, icon('euro-sign'), 'btn-success', "Calcola
emissioni di
#{month_label}", @filter_params.merge(calc_what: HouseQecsHelper::CalcolaEmissioneNucleo, filterhouse_id: ref_house_id, filterdate: month)) ) %> <%= view_table_cell() %> <%= view_table_cell() %> <%= view_table_cell() %> <% else %> <%= view_table_cell(exist_any_data_message) %> <%= view_table_cell() %> <%= view_table_cell() %> <%= view_table_cell() %> <% end %> <% if !user_has_house_policyscope %> <%= view_table_cell() %> <%= view_table_cell() %> <% end %> <% end %> <%= view_table_row_close %> <% end %> <% end %> <%= view_table_body_close %> <%= view_table_close %> <% else %> Nucleo non selezionato... <% end %>