_institution.html.erb 7.59 KB
<div class="form-description">
  <div class="spb-row no-margin-top">
    <% if environment.enabled?('admin_must_approve_new_communities') %>
      <div class='spb-col spb-col-12 explanation'>
        <%= _("Note that the creation of institutions 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 %>
  </div>

  <div class="spb-row spb-col spb-col-12 required-field">
    <%= _("The highlighted fields are mandatory") %>
  </div>
</div>

<div class="spb-row spb-col spb-col-12">
  <div class="errorExplanation" id="create_institution_errors">
    <% unless flash[:errors].blank? %>
      <h2><%= _("Can`t create new Institution: #{flash[:errors].length} errors") %></h2>
      <ul>
      <% flash[:errors].each do |error| %>
        <li><%= error %></li>
      <% end %>
      </ul>
    <% end %>
  </div>
</div>

<%= form_for :community, :url => {:action=>"new_institution"}, :html => { :multipart => true, :id=>"institution_form" } do |f| %>

  <%= hidden_field_tag "edit_institution_page", false %>
  <%= fields_for :institutions do |inst| %>
    <div class="spb-row no-margin-top">
      <div class='spb-col'>
        <%= labelled_radio_button _('Public Institution'), 'institutions[type]', 'PublicInstitution', true %>
      </div>

      <div class="spb-col">
        <%= labelled_radio_button _('Private Institution'), 'institutions[type]', 'PrivateInstitution' %>
      </div>

    </div>

    <div class="spb-row">
      <div class="spb-col">
        <label for="community_name" class="formlabel">
          <%= _("Corporate Name") %><!-- razão social -->
          <span class="required-field">(*)</span>
        </label>

        <%= f.text_field(:name, :class => flash[:error_community_name], :maxlength => 250, :value => params[:community][:name]) %>
        <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %>
      </div>

    <div class="public-institutions-fields">
      <div class="spb-col">
        <%= hidden_field_tag "acronym_translate", _("Acronym") %>
        <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %>
        <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel", id: "institution_acronym_label") %>
        <%= inst.text_field(:acronym, :value => params[:institutions][:acronym], :maxlength => 12) %>
      </div>
    </div>

    </div>

    <div class="spb-row">
      <div class="spb-col spb-col-12">
        <%= inst.label "corporate_name", _("Fantasy name"), :class=>"formlabel" %><!-- Nome fantasia -->
        <%= inst.text_field(:corporate_name, :value => params[:institutions][:corporate_name], :size => 55, :maxlength => 250) %>
      </div>
    </div>

    <div class="spb-row">

      <div class="spb-col">
        <label for="community_country" class="formlabel">
          <%= _("Country") %>
          <span class="required-field">(*)</span>
        </label>

        <%= select("community", "country", [[_('Select a country'), -1]] + country_helper.countries, {:class => "type-select #{flash[:error_community_country]}"}) %>
      </div>

      <div class="spb-col">
        <label for="community_state" class="formlabel">
          <%= _("State") %>
          <span class="required-field">(*)</span>
        </label>

        <%= select("community", "state", [[_('Select a state'), '']] + @state_options,  {:class => "type-select #{flash[:error_community_state]}"}) %>
      </div>

      <div class="spb-col">
        <label class="formlabel" for="community_city">
          <%= _("City") %>
          <span class="required-field">(*)</span>
        </label>

        <%= f.text_field(:city, :class => flash[:error_community_city], :value => params[:community][:city], :maxlength => 250) %>
      </div>
    </div>


    <div class="spb-row">
      <div class="spb-col spb-col-12">
         <label class="formlabel" for="institutions_cnpj">
          <%= _("CNPJ") %>
          <span id="cnpj_required_field_mark" class="required-field"></span>
        </label>
        <%= inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field", :value => params[:institutions][:cnpj]) %>
      </div>
    </div>


    <div class="spb-row public-institutions-fields">
      <div class="spb-col spb-col-6">
        <label class="formlabel" for="institutions_governmental_sphere_id">
          <%= _("Governmental Sphere") %>
          <span class="required-field">(*)</span>
        </label>

        <%= inst.select(:governmental_sphere, @governmental_sphere, :selected=>params[:institutions][:governmental_sphere], :class => flash[:error_institution_governmental_sphere])%>
      </div>
    </div>

    <div class="spb-row public-institutions-fields">
      <div class="spb-col spb-col-6">
        <label class="formlabel" for="institutions_governmental_power_id">
          <%= _("Governmental Power") %>
          <span class="required-field">(*)</span>
        </label>

        <%= inst.select(:governmental_power, @governmental_power, :selected=>params[:institutions][:governmental_sphere], :class => flash[:error_institution_governmental_power])%>
      </div>
    </div>

    <div class="spb-row public-institutions-fields">
      <div class="spb-col spb-col-6">
        <label class="formlabel" for="institutions_juridical_nature_id">
          <%= _("Juridical Nature") %>
          <span class="required-field">(*)</span>
        </label>

        <%= inst.select(:juridical_nature, @juridical_nature, :selected=>params[:institutions][:juridical_nature], :class => flash[:error_institution_juridical_nature])%>
      </div>
    </div>

    <% if @show_admin_fields %>
      <div class="spb-row public-institutions-fields">
        <div class="spc-col spb-col-12 sisp-fields">
          <div class="spb-col spb-col-3">

            <div class="spb-col spb-col-12">
              <%= _("SISP?") %>
            </div>

            <div class="spb-col spb-col-5">
              <%= inst.radio_button(:sisp, true, :class => "#{flash[:error_institution_sisp]}" ) %>
              <%= inst.label :sisp ,_("Yes"), :value => true %>
            </div>

            <div class="spb-col spb-col-6">
              <%= inst.radio_button(:sisp, false, :checked=>"checked", :class => "#{flash[:error_institution_sisp]}") %>
              <%= inst.label :sisp ,_("No"), :value => false %>
            </div>
          </div>
        </div>
      </div>

      <div class="spb-row public-institutions-fields">
        <div class="spb-col spb-col-12">
          <%= inst.label("siorg_code" ,_("SIORG Code"), :class=>"formlabel") %>
          <%= inst.text_field(:siorg_code, :value => params[:institutions][:siorg_code]) %>
        </div>
      </div>
    <% end %>

    <div class="spb-row modal-form-actions">
      <div class="spb-col spb-col-6">
        <% if @url_token == "create_institution_admin" %>
          <%= submit_button :save, _('Save') %>
          <%= button(:cancel, _("Cancel"), {:controller => "admin_panel", :action => 'index'}) %>
        <% else %>
           <%= 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', "data-dismiss".to_sym => "modal") %>
           <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %>
        <% end %>
      </div>
    </div>

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