<%# outstanding += registration.balance_owed %>
<% end %>
<% end %>
<% if false # [todo] Unfortunately, this code did not work since each workshop could be in a different currency. Revisit %>
Outstanding Balance
<%= outstanding.format %>
<% end %>
<% end %>
<% color = @registration.balance_owed.positive? ? :danger : :success %>
<% if @registration.workshop_price && @registration.workshop_price.price %>
<% discount_currency = @registration.workshop_price.price.currency.symbol %>
<%= f.input :discount_value, label: 'Discount', wrapper: :bs3_horizontal_group, input_wrapper_html: {class: 'col-sm-4'} do %>
<%= f.input_field :discount_value, as: :string, class: "form-control" %>
<%= f.select :discount_use_percent, [['%', true], [discount_currency, false]] %>
<% end %>
<% end %>
<% if @registration.payment_comment %>
<%= f.input :payment_comment_text, label: 'Reason for discount', as: :text_full_width, rows: 3, hint: 'Used for justifcation of discount. Will then be available in comment section.', disabled: true, input_html: {value: @registration.payment_comment.body} %>
<% else %>
<%= f.input 'payment_comment_text', label: 'Reason for discount', as: :text_full_width, rows: 3, hint: 'Used for justifcation of discount. Will then be available in comment section.' %>
<% end %>
<% end %>
<% end %>
<% unless @workshop.custom_field_defs.empty? %>
<%= subsection title: 'Custom Fields' do %>
<% f.object.build_missing_fields @workshop %>
<%= f.simple_fields_for :custom_fields do |builder| %>
<% field = builder.object %>
<%= render "dm_core/admin/custom_fields/#{field.field_type}", field: field, f: builder %>
<% end %>
<% end %>
<% end %>
<%= submit_or_cancel cancel_url: admin_workshop_path(@workshop), delete_url: [:admin, @registration], delete_confirm: 'Are you sure you wish to delete this registration? Any associated payments will also be deleted!' %>
<% end %>
<%#--- Payments Tab %>
<%= subsection title: 'Recorded Payments' do %>
Date
Description
Paid
Method
<%= icons(:edit) %>
<% @registration.payment_histories.order('created_on ASC').each do |payment| %>
<%= subsection title: 'Payment Reminders' do %>
<%= simple_form_for @registration, url: admin_registration_path,
html: { class: 'form-horizontal' }, wrapper: :bs3_horizontal_form, wrapper_mappings: DmAdmin::FormWrapperMappings do |f| %>
<%= f.input :preferred_payment_reminder_hold_until, label: 'No reminder until', as: :date_picker, input_wrapper_html: {class: 'col-sm-4'},
hint: 'When sending reminders in batch, this persons reminder will not be sent unless after the specified date' %>
<%= submit_or_cancel cancel: false %>
<% end %>
Last Sent On
<% if @registration.payment_reminder_sent_on.nil? %>
not yet
<% else %>
<% @registration.payment_reminder_history.each do |date| %>
<%= format_date(date) %>
<% end %>
<% end %>
<%= link_to 'Send', send_payment_reminder_emails_admin_workshop_path(@registration.workshop, registration_id: @registration.id), title: 'Send reminder now', class: 'btn btn-xs btn-default', method: :patch, data: {confirm: "Are you sure you wish to send a reminder email to this person?"} %>
<% if @registration.preferred_payment_reminder_hold_until && @registration.preferred_payment_reminder_hold_until > Time.now %>
Requested not to send reminder until <%= format_date(@registration.preferred_payment_reminder_hold_until) %>
<% end %>
<% end %>