Skip to content

Instantly share code, notes, and snippets.

@javier
Forked from anonymous/_invoice.html.erb
Created August 9, 2011 15:07
Show Gist options
  • Save javier/1134304 to your computer and use it in GitHub Desktop.
Save javier/1134304 to your computer and use it in GitHub Desktop.
...
<td class="Text13Grey numeric">
<span id="invoice_paid_status_<%= invoice.url_id %>"> <%= partial_payment_in_redbox(invoice) %></span>
</td>
...
<div id="redbox-for-partial-payment" class="redbox_contents" style="display: none; width: 300px;">
<div style="padding: 10px">
<div id="total_payment">
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<tr>
<td class="CellTablebuttonL">
<%= button_to_function t('.full_payment'), :class=> "button", :id => "full-payment", :onclick => "fullPayment();"%>
</td>
<td>
<%= button_to_function t('.partial_payment'), :class=> "button", :id => "partial-payment", :onclick => "partialPayment();" %>
</td>
</tr>
</table>
</div>
<div id="partial_payment_form" style="display: none;">
<div>
<% remote_form_for invoice_partial_payments_path([invoice, PartialPayment.new]) do |f| %>
<%= f.text_field :amount, :maxlength => 13, :size => 13, :class => "amount" %>
<% end %>
</div>
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<tr>
<td class="CellTablebuttonL">
<%= button_to_function t ('.cancel'), "RedBox.close()", :class => 'button' %>
</td>
<td class="CellTablebuttonR" align="right">
<%= submit_tag t('.accept'), :class => 'button' %>
</td>
</tr>
</table>
</div>
</div>
</div>
...
def partial_payment_in_redbox (invoice)
pending = invoice.total-invoice.total_paid
if pending > 0
html = render(:partial => 'invoices/redbox/partial_payment', :locals => {:invoice => invoice })
html << link_to_redbox (format_money_as_decimal (pending), 'redbox-for-partial-payment', :class => "Text13Orange")
html
else
html = format_money_as_decimal (0)
end
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment