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/app/views/cost_objects/_form.html.erb

207 lines
8.0 KiB

<%#-- copyright
OpenProject Costs Plugin
Copyright (C) 2009 - 2014 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 3.
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.
++#%>
<%= f.hidden_field :kind %>
<div class="form--field">
<%= f.text_field :subject, required: true %>
</div>
<div class="form--field">
<%= f.text_area :description, rows: (@cost_object.description.blank? ? 10 : [[10, @cost_object.description.length / 50].max, 100].min), cols: 60 %>
</div>
<div class="form--field">
<%= f.text_field :fixed_date, container_class: '-xslim' %>
<%= calendar_for :cost_object_fixed_date %>
</div>
<% if @cost_object.kind == "VariableCostObject" -%>
<script type="text/javascript">
//<![CDATA[
materialBudgetItemsForm = new Subform('<%= escape_javascript(render(:partial => "material_budget_item", :object => @cost_object.material_budget_items.build(:cost_type => CostType.default) )) %>',<%= @cost_object.material_budget_items.length %>,'material_budget_items_body');
<%# we have to assign the cost_object here as following methods depend on the item having an object -%>
<% item = @cost_object.labor_budget_items.build.tap do |i|
i.cost_object = @cost_object
end -%>
laborBudgetItemsForm = new Subform('<%= escape_javascript(render(:partial => "labor_budget_item", :object => item )) %>',<%= @cost_object.labor_budget_items.length %>,'labor_budget_items_body');
//]]>
</script>
<fieldset id="material_budget_items_fieldset" class="form--fieldset -collapsible">
<legend class="form--fieldset-legend" onclick="toggleFieldset(this);"><%= VariableCostObject.human_attribute_name(:material_budget) %></legend>
<div class="generic-table--container">
<div class="generic-table--results-container">
<table interactive-table class="generic-table" id="material_budget_items">
<colgroup>
<col highlight-col>
<col highlight-col>
<col highlight-col>
<% if User.current.allowed_to?(:view_cost_rates, @project)%>
<col highlight-col>
<%end%>
<col>
</colgroup>
<thead>
<tr>
<th class="cost_units">
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= MaterialBudgetItem.human_attribute_name(:units) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= MaterialBudgetItem.human_attribute_name(:cost_type) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= MaterialBudgetItem.human_attribute_name(:comment) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= MaterialBudgetItem.human_attribute_name(:description) %>
</span>
</div>
</div>
</th>
<% if User.current.allowed_to?(:view_cost_rates, @project)%>
<th class="currency" id="material_budget_items_price">
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= MaterialBudgetItem.human_attribute_name(:budget) %>
</span>
</div>
</div>
</th>
<%end%>
<th class="-short"></th>
</tr>
</thead>
<tbody id="material_budget_items_body">
<%- @cost_object.material_budget_items.each_with_index do |material_budget_item, index| -%>
<%= render :partial => 'material_budget_item', :object => material_budget_item, :locals => {:index => index} %>
<%- end -%>
</tbody>
</table>
<div class="generic-table--header-background"></div>
</div>
</div>
<div class="generic-table--action-buttons">
<%= link_to_function t(:button_add_budget_item), "materialBudgetItemsForm.add()", {class: "button -alt-highlight -with-icon icon-context icon-add"} %>
</div>
</fieldset>
<fieldset id="labor_budget_items_fieldset" class="form--fieldset -collapsible">
<legend class="form--fieldset-legend" onclick="toggleFieldset(this);"><%= VariableCostObject.human_attribute_name(:labor_budget) %></legend>
<div class="generic-table--container">
<div class="generic-table--results-container">
<table interactive-table class="generic-table" id="labor_budget_items">
<colgroup>
<col highlight-col>
<col highlight-col>
<col highlight-col>
<% if User.current.allowed_to?(:view_cost_rates, @project)%>
<col highlight-col>
<%end%>
<col>
</colgroup>
<thead>
<tr>
<th class="cost_units">
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= LaborBudgetItem.human_attribute_name(:hours) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= LaborBudgetItem.human_attribute_name(:user) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= LaborBudgetItem.human_attribute_name(:comment) %>
</span>
</div>
</div>
</th>
<% if User.current.allowed_to?(:view_cost_rates, @project)%>
<th class="currency" id="labor_budget_items_price">
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= LaborBudgetItem.human_attribute_name(:budget) %>
</span>
</div>
</div>
</th>
<%end%>
<th class="-short"></th>
</tr>
</thead>
<tbody id="labor_budget_items_body">
<%- @cost_object.labor_budget_items.each_with_index do |labor_budget_item, index| -%>
<%= render :partial => 'labor_budget_item', :object => labor_budget_item, :locals => {:index => index} %>
<%- end -%>
</tbody>
</table>
<div class="generic-table--header-background"></div>
</div>
</div>
<div class="generic-table--action-buttons">
<%= link_to_function t(:button_add_budget_item), "laborBudgetItemsForm.add()", {class: "button -alt-highlight -with-icon icon-context icon-add"} %>
</div>
</fieldset>
<%- end %>
<div style="clear: both;"> </div>
<% if @cost_object.new_record? %>
<p><label><%=t(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
<% end %>
<%= wikitoolbar_for 'cost_object_description' %>