_institution.html.erb 6.27 KB
<h1><%= _('New Institution') %></h1>

<% if environment.enabled?('admin_must_approve_new_communities') %>
  <div class='explanation'>
    <%= _("Note that the creation of communities in this environment is restricted. Your request to create this new community will be sent to %{environment} administrators and will be approved or rejected according to their methods and criteria.") % { :environment => environment.name }%>
  </div>
<%end %>

<% unless flash[:errors].nil? %>
<div class="errorExplanation" id="errorExplanation">
  <h2> <%= _("Can`t create new Institution: #{flash[:errors].length} errors") %> </h2>
  <ul>
  <% flash[:errors].each do |key, value| %>
    <% key_name = key.to_s.gsub("_", " ") %>
    <% if value.length > 0 %>
      <li> <%= _("<b>#{key_name.capitalize}</b> #{value.join()}") %> </li>
    <% end %>
  <% end %>
  </ul>
</div>
<% end %>

<div id = 'create_institution_errors' class='errorExplanation hide-field'></div>

<div>
  <div class="fields-required">
    <span class="errorExplanation"><%= required_fields_message %></span>
  </div>
  <br/>
  <%= labelled_form_for :community, :url => {:action=>"new_institution"}, :html => { :multipart => true, :id=>"institution_form" } do |f| %>
    <div class="fields-required">
      <span class="errorExplanation"><%= required_fields_message %></span>
    </div>
    <br/>
    <%= hidden_field_tag "edit_institution_page", false %>
    <%= fields_for :institutions do |inst| %>
      <span class=''>
          <div class='formfield type-radio'>
            <label>
              <%= _("Private Institution") %>
              <%= radio_button_tag("institutions[type]" ,"PrivateInstitution", true)%>
            </label>

            <label> <%= _("Public Institution") %>
              <%= radio_button_tag("institutions[type]", "PublicInstitution") %>
            </label>
          </div>
        </span>

      <%= required f.text_field(:name, :class => flash[:error_community_name]) %>
      <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %>

      <div class= <%= @error_corporate_name %> >
        <span class='required-field'>
          <div class="formfield type-text">
            <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %>
            <%= required inst.text_field(:corporate_name, :value => params[:institutions][:corporate_name], :size => 55, :class => "#{params[:error_institution_corporate_name]}") %>
          </div>
        </span>
      </div>

      <span class='optional-field'>
        <div class="formfield type-text">
          <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %>
          <%= required inst.text_field(:corporate_name, :class => flash[:error_institution_corporate_name]) %>
        </div>
      </span>

      <%= required select_country(_('Country'), 'community', 'country', {:class => "type-select #{flash[:error_community_country]}", :id => "community_country"}) %>

      <span class='required-field'>
        <div class="formfield">
          <label for="community_state" class="formlabel"><%= _("State") %></label>
          <%= f.select(:state, @state_list.collect {|state| [state.name, state.name]}, {}, {:class => flash[:error_community_state]}) %>
        </div>
      </span>

      <%= required f.text_field(:city, :class => flash[:error_community_city]) %>


      <span class='required-field'>
        <div class="formfield type-text">
          <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %>
          <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field #{flash[:error_institution_cnpj]}") %>
        </div>
      </span>

      <span class='optional-field'>
        <div class="formfield type-text">
          <%= hidden_field_tag "acronym_translate", _("Acronym") %>
          <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %>
          <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %>
          <%= inst.text_field(:acronym) %>
        </div>
      </span>

      <span class='required-field public-institutions-fields'>
        <div class="formfield type-text">
          <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %>
          <%= inst.select(:governmental_sphere, @governmental_sphere, {:selected=>0})%>
        </div>
      </span>

      <span class='required-field public-institutions-fields'>
        <div class="formfield type-text">
          <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %>
          <%= inst.select(:governmental_power, @governmental_power, {:selected=>0})%>
        </div>
      </span>
      <span class='required-field public-institutions-fields'>
        <div class="formfield type-text">
          <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %>
          <%= inst.select(:juridical_nature, @juridical_nature, {:selected=>0})%>
        </div>
      </span>

      <span class='required-field public-institutions-fields'>
        <div class="formfield type-text">
          <%= _("SISP?") %>
          <% if @show_sisp_field %>
            <%= inst.radio_button(:sisp, true, :class => "#{params[:error_institution_sisp]}" ) %>
            <%= inst.label :sisp ,_("Yes"), :value => true %>
            <%= inst.radio_button(:sisp, false, :checked=>"checked", :class => "#{params[:error_institution_sisp]}") %>
            <%= inst.label :sisp ,_("No"), :value => false %>
          <% else %>
            <%= inst.label("sisp", _("No")) %>
          <% end %>
          </div>
      </span>
      <br />

      <% if @url_token == "create_institution_admin" %>
        <%= submit_button :save, _('Save') %>
        <%= button(:cancel, _("Cancel"), {:controller => "admin_panel", :action => 'index'}) %>
      <%else%>
        <div>
         <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %>
         <%= link_to(_('Cancel'), '#', :id=>"cancel_institution_button", :class=>'button with-text icon-cancel') %>
        </div>
        <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %>
      <%end%>

    <% end %>

  <% end %>
</div>
<%= hidden_field_tag :loading_message, _("Creating institution") %>