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/deliverables/_form.rhtml

122 lines
6.8 KiB

<script type="text/javascript">
//<![CDATA[
deliverableCostsNextRow = 1;
deliverableHoursNextRow = 1;
//]]>
</script>
<p><%= f.select :kind, [[l(:label_fixed_deliverable), FixedDeliverable.name], [l(:label_cost_based_deliverable), CostBasedDeliverable.name]], :required => true, :prompt => "Select Type" %></p>
<%= observe_field :deliverable_kind, :url => { :action => :new },
:update => :content,
:with => "Form.serialize('deliverable-form')" %>
<hr />
<p><%= f.text_field :subject, :size => 80, :required => true %></p>
<p><%= f.text_area :description,
:cols => 60,
:rows => (@deliverable.description.blank? ? 10 : [[10, @deliverable.description.length / 50].max, 100].min),
:accesskey => accesskey(:edit),
:class => 'wiki-edit' %></p>
<% if @deliverable.kind == "CostBasedDeliverable" -%>
<div class="splitcontentleft"><div class="p">
<label><%= l(:caption_materials_budget) %></label>
<table class="list deliverable_costs" id="deliverable_costs">
<thead><tr>
<th><%= l(:caption_cost_unit_plural)%></th>
<th><%= l(:caption_cost_type) %></th>
<% if User.current.allowed_to?(:view_unit_price, @project)%><th id="deliverable_costs_price"><%= l(:caption_overall_costs) %></th><%end%>
<th></th>
</tr></thead>
<tbody id="deliverable_costs_body">
<% @deliverable.deliverable_costs.each do |c| %>
<tr class="cost-entry" id="<%= "deliverable_costs_#{c.id}" %>">
<td class="cost_units">
<%= text_field c, :units, :value => c.units, :size => 3, :id => "deliverable_costs_#{c.id}_units", :name => "deliverable_costs[#{c.id}][units]" %>
<span id="<%= "deliverable_costs_#{c.id}_unit_name" %>"><%=h c.units.to_s == '1.0' ? c.cost_type.unit : c.cost_type.unit_plural %></span>
</td>
<td>
<%= select c.cost_type, :id, cost_types_collection_for_select_options, {}, :name => "deliverable_costs[#{c.id}][cost_type_id]", :id => "deliverable_costs_#{c.id}_cost_type_id" %>
<%= observe_field( "deliverable_costs_#{c.id}_cost_type_id", :url => {:action => :update_deliverable_costs_row}, :with => "'cost_type_id=' + encodeURIComponent(value) + '&units=' + encodeURIComponent(document.getElementById('deliverable_costs_#{c.id}_units').value) + '&element_id=deliverable_costs_#{c.id}'") %>
</td>
<% if User.current.allowed_to?(:view_unit_price, @project)%><td class="currency">
<span id="<%= "deliverable_costs_#{c.id}_costs" %>"><%= number_to_currency(c.costs) if c.costs > 0 %></span>
<%= observe_field( "deliverable_costs_#{c.id}_units", :frequency => 1, :url => {:action => :update_deliverable_costs_row}, :with => "'cost_type_id=' + encodeURIComponent(document.getElementById('deliverable_costs_#{c.id}_cost_type_id').value) + '&units=' + encodeURIComponent(value) + '&element_id=deliverable_costs_#{c.id}'") %>
</td><% end %>
<td align="center">
<%= image_to_function 'delete.png', "deleteDeliverableCostsEntry('deliverable_costs_#{c.id}')" %>
</td>
</tr>
<% end %>
<%= render :partial => 'deliverable_costs_row', :locals => {:row_id => 1} %>
</tbody>
</table>
<div style="text-align: right"><%= link_to_remote l(:button_add_material_cost),
{ :url => { :controller => 'deliverables', :action => 'add_deliverable_costs_row', :project_id => @project },
:method => 'post',
:with => "'row_id=' + deliverableCostsNextRow",
:before => "deliverableCostsNextRow++"
}, :class => "icon icon-add" %>
</div>
</div></div>
<div class="splitcontentright"><div class="p">
<label><%= l(:caption_labor_budget) %></label>
<table class="list deliverable_rates" id="deliverables_rates">
<thead><tr>
<th><%= l(:field_hours)%></th>
<th><%= l(:label_user) %></th>
<% if User.current.allowed_to?(:view_all_rates, @project) || (user == User.current && User.current.allowed_to?(:view_own_rate, @project)) %>
<th id="deliverable_hours_price"><%= l(:caption_overall_costs) %></th>
<% end %>
<th></th>
</tr></thead>
<tbody id="deliverable_hours_body">
<% @deliverable.deliverable_hours.each do |c| %>
<tr class="cost-entry" id="<%= "deliverable_hours_#{c.id}" %>">
<td class="cost_units">
<%= text_field c, :units, :value => c.hours, :size => 3, :id => "deliverable_hours_#{c.id}_hours", :name => "deliverable_hours[#{c.id}][hours]" %>
</td>
<td>
<%= select c.user, :id, user_collection_for_select_options (:generic_user => true), {}, :name => "deliverable_hours[#{c.id}][user_id]", :id => "deliverable_hours_#{c.id}_user_id" %>
<%= observe_field( "deliverable_hours_#{c.id}_cost_type_id", :url => {:action => :update_deliverable_hours_row}, :with => "'user_id=' + encodeURIComponent(value) + '&hours=' + encodeURIComponent(document.getElementById('deliverable_hours_#{c.id}_hours').value) + '&element_id=deliverable_hours_#{c.id}'") %>
</td>
<% if User.current.allowed_to?(:view_unit_price, @project)%><td class="currency">
<span id="<%= "deliverable_hours_#{c.id}_costs" %>"><%= number_to_currency(c.costs) if c.costs > 0 %></span>
<%= observe_field( "deliverable_hours_#{c.id}_hours", :frequency => 1, :url => {:action => :update_deliverable_hours_row}, :with => "'user_id=' + encodeURIComponent(document.getElementById('deliverable_hours_#{c.id}_user_id').value) + '&hours=' + encodeURIComponent(value) + '&element_id=deliverable_hours_#{c.id}'") %>
</td><% end %>
<td align="center">
<%= image_to_function 'delete.png', "deleteDeliverableHoursEntry('deliverable_hours_#{c.id}')" %>
</td>
</tr>
<% end %>
<%= render :partial => 'deliverable_hours_row', :locals => {:row_id => 1} %>
</tbody>
</table>
<div style="text-align: right"><%= link_to_remote l(:button_add_labor_cost),
{ :url => { :controller => 'deliverables', :action => 'add_deliverable_hours_row', :project_id => @project },
:method => 'post',
:with => "'row_id=' + deliverableHoursNextRow",
:before => "deliverableHoursNextRow++"
}, :class => "icon icon-add" %>
</div>
</div></div>
<%- end %>
<div style="clear: both;"> </div>
<div class="splitcontentleft">
<p><%= f.check_box(:project_manager_signoff) %></p>
<p><%= f.check_box(:client_signoff) %></p>
</div>
<div class="splitcontentright">
<p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('deliverable_due') %></p>
</div>
<div style="clear: both;"> </div>
<%= wikitoolbar_for 'deliverable_description' %>