- <% if root -%>
- <%# section_field = @section.section_fields.find_by_language(@authorization_record.language) or @section.section_fields.find_by_is_default_language(true)-%>
- <% section_field = @sections_field[@section.id.to_s] %>
- <% save_the_ids = [] %>
- <% form_tag( {:controller => "sections", :action=>"save_answers"}, :id => "form_#{@section.id.to_s}", :class => "ajaxForm") do %>
- <%= hidden_field_tag :section, @section.id -%>
- <% if @loop_item -%>
- <%= hidden_field_tag :root_loop_item, @loop_item.id %>
- <%= hidden_field_tag "section_looping_identifiers_#{@section.id.to_s}[#{@loop_item.sort_index}]" %>
- <% end -%>
- <% if @section.depends_on_option.present? -%>
- <% section_visible = @section.dependency_condition_met?(current_user, looping_identifier ? looping_identifier : nil ) -%>
- <%= hidden_field_tag "hidden[#{@section.id.to_s + (looping_identifier ? "_#{looping_identifier}" : "")}]", section_visible ? "0" : "1" -%>
- <% else -%>
- <% section_visible = true -%>
- <% end -%>
- <div id="section_<%=@section.id.to_s + (looping_identifier ? "_#{looping_identifier}" : "")%>" class="root_submit_section <%= section_visible ? "" : "hide" %>">
- <div class="info_header" style="border-bottom-width: 0">
- <% if not @section.is_hidden? %>
- <div class="span-16">
- <h2><%= ( @section.section_type == 0 and @loop_item.present? ) ? h(section_field.loop_title(nil, @loop_item)) : h(section_field.title) %></h2>
- </div>
- <div class="span-2 last options">
- <p><!-- floats right -->
- <a href="#" class="show_info" style="display: inline"><%= image_tag 'icons/expand.png', :title => "Expand", :alt => "Expand"%></a>
- <a href="#" class="hide_info" style="display: none"><%= image_tag 'icons/collapse.png', :title =>"Collapse", :alt => "Collapse"%></a>
- <%= image_submit_tag 'icons/disk.png', :alt => "Save", :title => "Save", :class => 'hide save_button' -%>
- </p>
- </div>
- <% end -%>
- </div><!-- /.report_info_header -->
- <div class="clear info <%= @section.is_hidden? ? "" : "hide" %>">
- <% if not @section.is_hidden? %>
- <%#=h( ((number == 0 ? "" : number.to_s) + "- " + ( looping_identifier.nil? ? section.name : section.name.gsub(" #[#{looping_identifier.item_type}]"," "+looping_identifier.item_name)))) %>
- <% if section_field.description.present? -%>
- <p>
- <%=h section_field.description %>
- </p>
- <% end -%>
- <% end -%>
- <% @section.questions.each do |question| -%>
- <%= render :partial => "questions/submission", :locals => {:question => question, :loop_item => @loop_item, :looping_identifier => looping_identifier, :question_field => @questions_field[question.id.to_s], :answer_type_help_text => @answer_types.present? ? @answer_types_help[question.answer_type_id.to_s] : nil, :loop_sources => loop_sources }, :inline => true %>
- <% end -%>
- <% @section.children.each do |child|
- #if not @sections_field.has_key?(child.id.to_s)
- # @sections_field[child.id.to_s] = child.section_fields.find_by_language(@authorization_record.language) or child.section_fields.find_by_is_default_language(true)
- #end
- if child.section_type == 0
- items = child.get_next_loop_items @loop_item, loop_sources
- new_multiplier = (multiplier ? multiplier * items.size : (@loop_item ? @loop_item.siblings.size : 1)) #if the multiplier didn't exist before it is 1 for the first item'
- items.each do |item|
- if child.available_for? current_user, item
- # the looping_identifier is an unique number calculated as "root_sort_index + current_item.sort_index * root.siblings" For further levels add ancestors total items count "item.sort_index * ancestors.siblings.count"
- new_looping_identifier = (looping_identifier ? (looping_identifier + item.sort_index * new_multiplier) : item.sort_index)
- save_the_ids << [new_looping_identifier, new_multiplier, looping_identifier, item.sort_index]-%>
- <% loop_sources["loop_source_#{child.loop_source.id}"] = item -%>
- <%= render :partial => "sections/submission", :locals => {:save_the_ids => save_the_ids,:section => child, :root => false, :loop_item => item, :loop_sources => loop_sources, :multiplier => new_multiplier, :looping_identifier => new_looping_identifier,:section_field => @sections_field[child.id.to_s], :section_visible => section_visible }, :inline => true %>
- <% end -%>
- <% end -%>
- <% else -%>
- <%= render :partial => "sections/submission", :locals => {:save_the_ids => save_the_ids,:section => child, :root => false, :loop_item => @loop_item ? @loop_item : nil, :loop_sources => loop_sources, :multiplier => multiplier, :looping_identifier => looping_identifier, :section_field => @sections_field[child.id.to_s], :section_visible => section_visible }, :inline => true %>
- <% end -%>
- <% end -%>
- <p class="clear"><strong>* mandatory questions</strong></p>
- </div>
- <div class="clear">
- <p><%= image_submit_tag 'icons/disk.png', :alt => "Save", :title => "Save" -%></p>
- </div>
- <% end -%>
- </div><!-- /section_gen_root_section_id -->
- <% else -%>
- <% if looping_identifier -%>
- <%= hidden_field_tag "section_looping_identifiers_#{section.id.to_s}[#{looping_identifier.to_s}]" %>
- <% end -%>
- <% if section.depends_on_option.present? -%>
- <% section_visible = section.dependency_condition_met?(current_user, looping_identifier ? looping_identifier : nil ) -%>
- <% else -%>
- <% section_visible = true -%>
- <% end -%>
- <%= hidden_field_tag "hidden[#{section.id.to_s + (looping_identifier ? "_#{looping_identifier}" : "")}]", section_visible ? "0" : "1" -%>
- <div id="section_<%=section.id.to_s + (looping_identifier ? "_#{looping_identifier}" : "")%>" class="submit_section <%= section_visible ? "" : "hide" %>">
- <div class="info_header" style="border-bottom-width: 0">
- <% if not section.is_hidden? %>
- <div class="span-16">
- <h3><%= ( section.section_type == 0 and loop_item.present? ) ? h(section_field.loop_title(nil, loop_item)) : h(section_field.title) %></h3>
- </div>
- <div class="span-2 last">
- <p><!-- floats right -->
- <a href="#" class="show_info" style="display: inline"><%= image_tag 'icons/expand.png', :title => "Expand", :alt => "Expand"%></a>
- <a href="#" class="hide_info" style="display: none"><%= image_tag 'icons/collapse.png', :title =>"Collapse", :alt => "Collapse"%></a>
- <%= image_submit_tag 'icons/disk.png', :alt => "Save", :title => "Save", :class => 'hide save_button'-%>
- </p>
- </div>
- <% end -%>
- </div><!-- /.report_info_header -->
- <div class="info clear <%= section.is_hidden? ? "" : "hide" %>">
- <% if not section.is_hidden? -%>
- <%#=h( ((number == 0 ? "" : number.to_s) + "- " + ( loop_item.nil? ? section.name : section.name.gsub(" #[#{loop_item.item_type}]"," "+loop_item.item_name)))) %>
- <% if section_field.description.present? -%>
- <p>
- <%=h section_field.description %>
- </p>
- <% end -%>
- <% end -%>
- <% section.questions.each do |question| -%>
- <%= render :partial => "questions/submission", :locals => {:question => question, :loop_item => loop_item, :looping_identifier => looping_identifier, :question_field => @questions_field[question.id.to_s], :answer_type_help_text => @answer_types_field.present? ? @answer_types_field[question.answer_type_id.to_s] : nil, :loop_sources => loop_sources }, :inline => true %>
- <% end -%>
- <% section.children.each do |child|
- #if not @sections_field.has_key?(child.id.to_s)
- # @sections_field[child.id.to_s] = child.section_fields.find_by_language(@authorization_record.language) or child.section_fields.find_by_is_default_language(true)
- #end
- if child.section_type == 0
- items = child.get_next_loop_items loop_item, loop_sources
- new_multiplier = (multiplier ? multiplier * items.size : (loop_item ? loop_item.siblings.size : 1)) #if the multiplier didn't exist before it is 1 for the first item'
- items.each do |item|
- if child.available_for? current_user, item
- new_looping_identifier = (looping_identifier ? (looping_identifier + item.sort_index * new_multiplier) : item.sort_index)
- save_the_ids << [new_looping_identifier, new_multiplier, looping_identifier, item.sort_index]
- loop_sources["loop_source_#{child.loop_source.id}"] = item -%>
- <%= render :partial => "sections/submission", :locals => {:save_the_ids => save_the_ids, :section => child, :root => false, :loop_item => item, :loop_sources => loop_sources, :multiplier => new_multiplier, :looping_identifier => new_looping_identifier, :section_field => @sections_field[child.id.to_s], :section_visible => section_visible }, :inline => true %>
- <% end -%>
- <% end -%>
- <% else -%>
- <%= render :partial => "sections/submission", :locals => {:save_the_ids => save_the_ids, :section => child, :root => false, :loop_item => loop_item ? loop_item : nil, :loop_sources => loop_sources, :multiplier => multiplier, :looping_identifier => looping_identifier, :section_field => @sections_field[child.id.to_s], :section_visible => section_visible }, :inline => true %>
- <% end -%>
- <% end -%>
- </div>
- </div><!-- /section_gen_section_id -->
- <% end -%>
- <div id="show_the_ids">
- <ul>
- <% save_the_ids.each do |newid, m, lid, si | %>
- <li><%= lid.to_s + " + " + m.to_s + " * " + si.to_s + " = " + newid.to_s %></li>
- <% end %>
- </ul>
- </div>