<%= link_to "#{t('valuation.spending_proposals.show.heading')} #{@spending_proposal.id}", valuation_spending_proposal_path(@spending_proposal), class: 'back' %>
<h2><%= t("valuation.spending_proposals.edit.dossier") %></h2>

<%= form_for(@spending_proposal, url: valuate_valuation_spending_proposal_path(@spending_proposal), html: {id: "valuation_spending_proposal_edit_form"}) do |f| %>
  <%= render 'shared/errors', resource: @spending_proposal %>
  <div class="row">
    <div class="small-12 medium-8 column">
      <fieldset class="fieldset">
        <legend><%= t('valuation.spending_proposals.edit.feasibility') %></legend>
        <div class="small-4 column">
            <span class="radio">
              <%= f.radio_button :feasible, :nil, label: false, checked: @spending_proposal.feasible.nil? %>
              <%= f.label :feasible_nil, t('valuation.spending_proposals.edit.undefined_feasible') %>
            </span>
        </div>

        <div class="small-4 column">
            <span class="radio">
              <%= f.radio_button :feasible, true, value: true, label: false %>
              <%= f.label :feasible_true, t('valuation.spending_proposals.edit.feasible') %>
            </span>
        </div>

        <div class="small-4 column">
            <span class="radio">
              <%= f.radio_button :feasible, false, value: false, label: false %>
              <%= f.label :feasible_false, t('valuation.spending_proposals.edit.not_feasible') %>
            </span>
        </div>
      </fieldset>
    </div>
  </div>

  <div id="not_feasible_fields" >

    <div class="row">
      <div class="small-12 medium-8 column">
        <%= f.label :feasible_explanation, t("valuation.spending_proposals.edit.feasible_explanation_html") %>
        <%= f.text_area :feasible_explanation, label: false, rows: 3 %>
      </div>
    </div>

  </div>

  <div id="feasible_fields">

    <div class="row">
      <div class="small-12 medium-4 column">
        <%= f.label :price, "#{t('valuation.spending_proposals.edit.price_html', currency: t('valuation.spending_proposals.edit.currency'))}" %>
        <%= f.number_field :price, label: false, max: 1000000000000000 %>
      </div>

      <div class="small-12 medium-4 column end">
        <%= f.label :price_first_year, "#{t('valuation.spending_proposals.edit.price_first_year_html', currency: t('valuation.spending_proposals.edit.currency'))}" %>
        <%= f.number_field :price_first_year, label: false, max: 1000000000000000 %>
      </div>
    </div>

    <div class="row">
      <div class="small-12 medium-8 column">
        <%= f.label :price_explanation, t("valuation.spending_proposals.edit.price_explanation_html") %>
        <%= f.text_area :price_explanation, label: false, rows: 3 %>
      </div>
    </div>

    <div class="row">
      <div class="small-12 medium-8 column">
        <%= f.label :time_scope, t("valuation.spending_proposals.edit.time_scope_html") %>
        <%= f.text_field :time_scope, label: false %>
      </div>
    </div>

  </div>

  <div class="row">
    <div class="small-12 medium-8 column">
      <%= f.label :valuation_finished do %>
        <%= f.check_box :valuation_finished, title: t('valuation.spending_proposals.edit.valuation_finished'), label: false %>
        <span class="checkbox"><%= t("valuation.spending_proposals.edit.valuation_finished") %></span>
      <% end %>
    </div>
  </div>

  <div class="row">
    <div class="small-12 medium-8 column">
      <%= f.label :internal_comments, t("valuation.spending_proposals.edit.internal_comments_html") %>
      <%= f.text_area :internal_comments, label: false, rows: 3 %>
    </div>
  </div>

  <div class="row">
    <div class="actions small-12 medium-4 column">
      <%= f.submit(class: "button expanded large", value: t("valuation.spending_proposals.edit.save")) %>
    </div>
  </div>
<% end %>

<h1><%= @spending_proposal.title %></h1>

<%= safe_html_with_links @spending_proposal.description %>

<% if @spending_proposal.external_url.present? %>
  <p><%= text_with_links @spending_proposal.external_url %></p>
<% end %>

<h2><%= t("valuation.spending_proposals.show.info") %></h2>

<p><strong><%= t("valuation.spending_proposals.show.by") %>:</strong>
  <%= link_to @spending_proposal.author.name, user_path(@spending_proposal.author) %>
</p>

<% if @spending_proposal.association_name.present? %>
  <p><strong><%= t("valuation.spending_proposals.show.association_name") %>:</strong>
    <%= @spending_proposal.association_name %>
  </p>
<% end %>

<p><strong><%= t("valuation.spending_proposals.show.geozone") %>:</strong>
  <%= geozone_name(@spending_proposal) %>
</p>

<p><strong><%= t("valuation.spending_proposals.show.sent") %>:</strong>
  <%= l @spending_proposal.created_at, format: :datetime %>
</p>

<h2><%= t("valuation.spending_proposals.show.responsibles") %></h2>

<p><strong><%= t("valuation.spending_proposals.show.assigned_admin") %>:</strong>
  <% if @spending_proposal.administrator.present? %>
    <%= @spending_proposal.administrator.name %> (<%= @spending_proposal.administrator.email %>)
  <% else %>
    <%= t("valuation.spending_proposals.show.undefined") %></li>
  <% end %>
</p>

<p><strong><%= t("valuation.spending_proposals.show.assigned_valuators") %>:</strong></p>
<div id="assigned_valuators">
  <ul>
    <% @spending_proposal.valuators.each do |valuator| %>
      <li><%= valuator.name %> (<%= valuator.email %>)</li>
    <% end %>

    <% if @spending_proposal.valuators.empty? %>
      <li><%= t("valuation.spending_proposals.show.undefined") %></li>
    <% end %>
  </ul>
</div>