<%#-- copyright OpenProject is an open source project management software. Copyright (C) 2012-2021 the OpenProject GmbH This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3. OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: Copyright (C) 2006-2013 Jean-Philippe Lang Copyright (C) 2010-2013 the ChiliProject Team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. See COPYRIGHT and LICENSE files for more details. ++#%> <% html_title t(:label_log_costs) %>

<%= t(:label_log_costs) %>

<% url = @cost_entry.new_record? ? { action: 'create', project_id: @project.id } : { action: 'update', id: @cost_entry } %> <% method = @cost_entry.new_record? ? :post : :put %> <%= labelled_tabular_form_for @cost_entry, url: url, html: { method: method } do |f| %> <%= error_messages_for 'cost_entry' %> <%= back_url_hidden_field_tag %> <%= f.hidden_field :element_id, value: 'cost_entry', class: 'remote-field--input', data: { :'remote-field-key' => 'element_id' } %>
<%= f.text_field :work_package_id, size: 6, required: true, autofocus: true, container_class: '-xslim' %> <% if @cost_entry.work_package %>
<%= h("#{@cost_entry.work_package.to_s}") %>
<% end %>
<%= f.text_field :spent_on, size: 10, required: true, class: 'remote-field--input -augmented-datepicker', data: { :'remote-field-key' => 'fixed_date' }, container_class: '-xslim' %>
<% if User.current.allowed_to? :log_costs, @project %>
<%# Without knowing why `prompt` is in this case responsible for no blank line in the selection options %> <%= f.select :user_id, user_collection_for_select_options, required: true, prompt: true, container_class: '-middle' %>
<% else %> <%= f.hidden_field :user_id, value: User.current.id %> <% end %>
<%# see above %> <%= f.select :cost_type_id, cost_types_collection_for_select_options, { prompt: true, container_class: '-middle' }, { required: true, class: 'remote-field--input', data: { :'remote-field-key' => 'cost_type_id' } } %>

<% if @cost_entry.cost_type.nil? %> <%= f.text_field :units, value: unitless_currency_number(@cost_entry.units), size: 6, required: true, container_class: '-slim' %> <% else %> <% suffix = @cost_entry.units == 1 ? @cost_entry.cost_type.unit : @cost_entry.cost_type.unit_plural %> <%= f.text_field :units, size: 6, value: unitless_currency_number(@cost_entry.units), required: true, suffix: h(suffix), suffix_id: 'cost_entry_unit_name', class: 'remote-field--input', data: { :'remote-field-key' => 'units' }, container_class: '-slim' %> <% end %>
<%= hidden_field_tag :currency, Setting.plugin_costs['costs_currency'], id: 'cost_entry_currency' %> <% if User.current.allowed_to?(:view_cost_rates, @cost_entry.project) %> <%= hidden_field_tag :cost_value, unitless_currency_number(@cost_entry.real_costs), id: 'cost_entry_cost_value' %> <%= number_to_currency(@cost_entry.real_costs) %> <% else %> <%= f.text_field :overridden_costs, value: @cost_entry.overridden_costs ? unitless_currency_number(@cost_entry.overridden_costs).strip : '', placeholder: t(:label_example_placeholder, decimal: unitless_currency_number(1000.50)), no_label: true, suffix: Setting.plugin_costs['costs_currency'], id: 'cost_entry_cost_value', container_class: '-middle', size: 7 %>

<%= t(:help_override_rate) %>

<% end %>
<%= f.text_field :comments, size: 100, container_class: '-wide' %>
<%= styled_button_tag t(:button_save), class: '-with-icon icon-checkmark' %> <% end %>