<% content_for :content_title, "#{h(@registration.full_name)} #{h(@workshop.title)}".html_safe %> <% content_for :content_title_extra do %> <%= page_header_buttons do %> <%= present(@registration).admin_status_label %> <%= link_to icon_label(:view, 'Registrations'), [:admin, @workshop], class: 'btn btn-xs btn-default' %> <% end %> <% end %>
<%#--- Overview Tab %>
<%= avatar_for(@registration.user_profile.user, '100%') %>
<%= @registration.full_name %><%= @registration.user_profile.country.english_name %> <%= @registration.user_profile.email %> <%= "no user account".html_safe unless @registration.user_profile.user %>
<% if @registration.workshop_price %>
Registered On
<%= format_date(@registration.created_at) %>
Price
<%= price_details(@registration.workshop_price) %>
<% if @registration.payment_comment %>
Reason for Discount
<%= @registration.payment_comment.body %>
<% end %>
<% end %> <%= subsection title: "Previous Event Registrations" do %> <%# outstanding = Money.new(0) %> <% Registration.where(user_profile_id: @registration.user_profile).each do |registration| %> <% unless registration == @registration %> <%# 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 %> <% end %>
Workshop Title Paid
<%= link_to registration.workshop.title, edit_admin_registration_path(registration) %> <%= present(registration).balance_or_paid %>
Outstanding Balance <%= outstanding.format %>
<% end %>
    <% color = @registration.balance_owed.positive? ? :danger : :success %>
  • <%= stat_block_small label: 'Balance', number: @registration.balance_owed.format(no_cents_if_whole: true), color_type: color, icon: 'icon-coin', percent: 100 %>
<% if @registration.payment_owed.positive? %> <% end %>
Price <%= @registration.price.format %>
Discount - <%= @registration.discount.format %>
Total <%= @registration.discounted_price.format %>
Paid <%= @registration.amount_paid.format %>
Payment Owed <% if @registration.workshop_price.recurring_payments? %>
On a payment plan
<% end %>
<%= @registration.payment_owed.format %>
Payment Due On <%= format_date(@registration.last_payment_due_on) %>
<%#--- Update Registration Tab %>
<%= simple_form_for @registration, url: admin_registration_path, html: { class: 'form-horizontal' }, wrapper: :bs3_horizontal_form, wrapper_mappings: DmAdmin::FormWrapperMappings do |f| %> <%= subsection title: 'Price' do %> <%= f.error_notification message: "Please review the problems below" %> <% if @workshop.workshop_prices.empty? %>
No workshop prices / options defined
<% else %>
<%= f.input :workshop_price_id, collection: @workshop.workshop_prices.map { |r| [price_details(r), r.id] } %>
<% 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 %> <% @registration.payment_histories.order('created_on ASC').each do |payment| %> <% end %>
Date Description Paid Method <%= icons(:edit) %>
<%= format_date(payment.payment_date) %> <%= payment.item_ref %> <%= payment.total.format(no_cents_if_whole: true, symbol: true) %> <%= payment.payment_method %> <% if payment.user_profile #--- only allow editing of manual payments %> <%= link_to(icons('icon-pencil3'), '#', data: { toggle: "modal", target: "#edit_payment_#{payment.id}"}, title: 'Edit Payment') %> <% end %>
<%= link_to 'Add Payment', '#', data: { toggle: "modal", target: "#enter_new_payment"}, title: 'Add Payment', class: "btn btn-xs btn-primary" %> <%= link_to 'Customer Payment Page', @registration.payment_url, target: '_blank', class: 'btn btn-xs btn-default' %> <% if @registration.payment_owed.positive? %>   Next payment should be: <%= @registration.payment_owed.format %> <% end %> <% end %>
<% if @registration.payment_owed.positive? %> <% end %>
Price <%= @registration.price.format %>
Discount - <%= @registration.discount.format %>
Total <%= @registration.discounted_price.format %>
Paid <%= @registration.amount_paid.format %>
Payment Owed <% if @registration.workshop_price.recurring_payments? %>
On a payment plan
<% end %>
<%= @registration.payment_owed.format %>
Payment Due On <%= format_date(@registration.last_payment_due_on) %>
<%= 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 %>
<% if @registration.payment_reminder_sent_on.nil? %> <% else %> <% @registration.payment_reminder_history.each do |date| %> <% end %> <% end %>
Last Sent On
not yet
<%= format_date(date) %>
<%= 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 %>
<%#--- Comments Tab %>
<%= subsection title: 'Private Comments' do %> <%= render partial: 'dm_core/admin/comments/comment_section', locals: {commenting_on: @registration, comments: @registration.private_comments, name: 'private_comments'} %> <% end %>
<%= simple_form_for :payment_history, url: ajax_payment_admin_registration_path(@registration), html: { class: 'form-horizontal' }, wrapper: :bs3_horizontal_form, wrapper_mappings: DmAdmin::FormWrapperMappings do |f| %> <%= modal_dialog title: 'Enter New Payment', id: 'enter_new_payment', include_save: true do %> <% if @registration.workshop_price.nil? %>

They must be registered for some type of payment first

<% else %> <%= f.input :payment_date, label: 'Paid On', as: :date_picker, input_wrapper_html: {class: 'col-sm-4'}, input_html: {value: Date.today.strftime("%Y/%m/%d")} %> <%= f.input :cost, label: 'Amount', wrapper: :bs3_horizontal_group, input_wrapper_html: {class: 'col-sm-4'} do %> <%= f.input_field :cost, as: :string, class: "form-control", value: @registration.payment_owed.amount %> <%= f.select :total_currency, @registration.workshop_price.currency_list, {} %> <% end %> <%= f.input :payment_method, label: 'Method', as: 'select', collection: WorkshopPrice::PAYMENT_METHODS, include_blank: false, input_wrapper_html: {class: 'col-sm-4'} %> <%= f.input :item_ref, label: 'Description', required: false %> <%= f.input :bill_to_name, label: 'Payed By', required: false %> <%= f.input :receipt_requested, as: 'boolean', label: false, inline_label: 'Customer would like a receipt', required: false %> <% end %> <% end %> <% end %> <% @registration.payment_histories.order('created_on ASC').each do |payment_history| %> <% #--- only allow editing of manual payments %> <% if payment_history.user_profile %> <%= simple_form_for payment_history, url: ajax_edit_payment_admin_registration_path(locale: I18n.locale, id: @registration, payment_id: payment_history.id), html: { class: 'form-horizontal' }, wrapper: :bs3_horizontal_form, wrapper_mappings: DmAdmin::FormWrapperMappings do |f| %> <%= modal_dialog title: 'Enter New Payment', id: "edit_payment_#{payment_history.id}", include_save: true, delete_url: ajax_delete_payment_admin_registration_path(locale: I18n.locale, id: @registration, payment_id: payment_history.id), delete_msg: 'Are you sure you want to delete this payment?' do %> <%= f.input :payment_date, label: 'Paid On', as: :date_picker, input_wrapper_html: {class: 'col-sm-4'} %> <%= f.input :cost, label: 'Amount', wrapper: :bs3_horizontal_group, input_wrapper_html: {class: 'col-sm-4'} do %> <%= f.input_field :cost, as: :string, class: "form-control" %> <%= f.select :total_currency, @registration.workshop_price.currency_list, {} %> <% end %> <%= f.input :payment_method, label: 'Method', as: 'select', collection: WorkshopPrice::PAYMENT_METHODS, include_blank: false, input_html: {style: "width: 200px"} %> <%= f.input :item_ref, label: 'Description', required: false %> <%= f.input :bill_to_name, label: 'Payed By', required: false %> <% end %> <% end %> <% end %> <% end %>