OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/modules/costs/app/views/costlog/edit.html.erb

136 lines
5.8 KiB

<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 2012-2020 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-2017 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 docs/COPYRIGHT.rdoc for more details.
++#%>
<% html_title t(:label_log_costs) %>
<h2><%= t(:label_log_costs) %></h2>
<% url = @cost_entry.new_record? ?
{ action: 'create', project_id: @project.id } :
{ action: 'update', id: @cost_entry } %>
<% method = @cost_entry.new_record? ?
:post :
:put %>
Feature/remove timelog (#8557) * rename costs, introduce budgets * move files from costs to budgets * rename cost_object to budget * remove unused code * move hook - should be turned into standard code in the long run * move type attributes change over to budgets * move patch to work_package proper * move budget menu item up * combine reporting, time and cost module * remove rails based time_entries & reports code * rename cost object filter * adapt menu spec expectations * use cost project module name in administration * include timeline labels in migration * properly place budget linking method * fix permitted params * remove outdated routing spec * adapt budget request specs * ensure order of descendent updates * remove outdated specs * fix checking for reporting to be enabled * fix displaying spent units * fix time entries activity event url * reenable current rate tab * fix path on budget page * allow bulk editing of budgets only in one project scenario * fix sanitizing reference in controller * include module required for format_date * fix reference to correct units from work package spent units * linting * remove outdated spec * remove outdated views and permission references * remove acts_as_event from time_entries There is no atom link for time entries * remove acts_as_event from projects There are no atom links for projects * introduce budget filter for cost reports * remove actions added to removed controller * move time entries to the costs module * factor in view_own permission when calculating time entry visibility * linting * move mounting of time entries * include budgets into api v3 documentation
4 years ago
<remote-field-updater data-url="<%= url_for(controller: :budgets, action: :update_material_budget_item, project_id: @cost_entry.project) %>"
data-mode="json">
</remote-field-updater>
<%= 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' } %>
<div class="form--field -required">
<%= f.text_field :work_package_id,
size: 6,
required: true,
autofocus: true,
container_class: '-xslim' %>
<% if @cost_entry.work_package %>
<div class="form--field-instructions">
<%= h("#{@cost_entry.work_package.to_s}") %>
</div>
<% end %>
</div>
<div class="form--field -required">
<%= f.text_field :spent_on,
size: 10,
required: true,
class: 'remote-field--input -augmented-datepicker',
data: { :'remote-field-key' =>'fixed_date' },
container_class: '-xslim' %>
<label for="cost_entry_spent_on" class="hidden-for-sighted"><%= l(:label_date) %> <%=l(:text_hint_date_format) %></label>
</div>
<% if User.current.allowed_to? :log_costs, @project %>
<div class="form--field">
<%# 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' %>
</div>
<% else %>
<%= f.hidden_field :user_id, value: User.current.id %>
<% end %>
<div class="form--field -required">
<%# 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' }
} %></p>
</div>
<div class="form--field -required">
<% if @cost_entry.cost_type.nil? %>
<%= f.text_field :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,
required: true,
suffix: h(suffix),
suffix_id: 'cost_entry_unit_name',
class: 'remote-field--input',
data: { :'remote-field-key' => 'units' },
container_class: '-slim' %>
<% end %>
</div>
<div class="form--field">
<label for="cost_entry_costs_edit" class="form--label"><%= CostEntry.human_attribute_name(:costs) %></label>
<span class="form--field-container">
<cost-unit-subform obj-id="cost_entry"
obj-name="cost_entry[overridden_costs]" %>
<% if User.current.allowed_to? :view_cost_rates, @cost_entry.project %>
<a href="#" id="cost_entry_costs" class="costs--edit-planned-costs-btn icon-context icon-edit" title="<%= t(:help_click_to_edit) %>">
<%= number_to_currency(@cost_entry.real_costs) %>
</a>
<% else %>
<span id="cost_entry_costs_editor" class="form--text-field-container">
Feature/remove timelog (#8557) * rename costs, introduce budgets * move files from costs to budgets * rename cost_object to budget * remove unused code * move hook - should be turned into standard code in the long run * move type attributes change over to budgets * move patch to work_package proper * move budget menu item up * combine reporting, time and cost module * remove rails based time_entries & reports code * rename cost object filter * adapt menu spec expectations * use cost project module name in administration * include timeline labels in migration * properly place budget linking method * fix permitted params * remove outdated routing spec * adapt budget request specs * ensure order of descendent updates * remove outdated specs * fix checking for reporting to be enabled * fix displaying spent units * fix time entries activity event url * reenable current rate tab * fix path on budget page * allow bulk editing of budgets only in one project scenario * fix sanitizing reference in controller * include module required for format_date * fix reference to correct units from work package spent units * linting * remove outdated spec * remove outdated views and permission references * remove acts_as_event from time_entries There is no atom link for time entries * remove acts_as_event from projects There are no atom links for projects * introduce budget filter for cost reports * remove actions added to removed controller * move time entries to the costs module * factor in view_own permission when calculating time entry visibility * linting * move mounting of time entries * include budgets into api v3 documentation
4 years ago
<input class="currency form--text-field" value="<%= number_to_currency(@cost_entry.overridden_costs, unit: "").strip if @cost_entry.overridden_costs %>" size="7" name="cost_entry[overridden_costs]" id="cost_entry_costs_edit"/> <%= Setting.plugin_costs['costs_currency'] %>
</span>
<br /><em><%= t(:help_override_rate) %></em>
<% end %>
</cost-unit-subform>
</span>
</div>
<div class="form--field">
<%= f.text_field :comments, size: 100, container_class: '-wide' %>
</div>
<%= styled_button_tag t(:button_save), class: '-with-icon icon-checkmark' %>
<% end %>