armandofox/audience1st

View on GitHub
app/views/vouchertypes/index.html.haml

Summary

Maintainability
Test Coverage
= form_tag vouchertypes_path, :method=>:get, :class => 'form' do
  .row.form-group
    .col-md-3.text-right
      %label.col-form-label{:for => 'season'} Listing voucher types for season:
    .col-md-2= select_tag 'season', options_for_seasons(3.years.ago.year,2.years.from_now.year,@season), :onchange => 'this.form.submit();', :class => 'form-control'

- if @vouchertypes.empty?
  .alert.alert-secondary.text-center= t('season_setup.errors.no_vouchertypes_exist', :season => Option.humanize_season(@season))
- else
  .row
    .col-md-4.form-group
      .form-check.form-check-inline
        = check_box_tag 'revenue', 1, true, :class => 'vouchertype-filter form-check-input'
        %label.form-check-label{:for => 'revenue'} Regular revenue vouchers (single tickets)
    .col-md-4.form-group
      .form-check.form-check-inline
        = check_box_tag 'comp', 1, true, :class => 'vouchertype-filter form-check-input'
        %label.form-check-label{:for => 'comp'} Comps (single tickets)
    .col-md-4.form-group
      .form-check.form-check-inline
        = check_box_tag 'nonticket', 1, true, :class => 'vouchertype-filter form-check-input'
        %label.form-check-label{:for => 'nonticket'} Nonticket products
  .row
    .col-md-4.form-group
      .form-check.form-check-inline
        = check_box_tag 'bundle-sub', 1, true, :class => 'vouchertype-filter form-check-input'
        %label.form-check-label{:for => 'bundle-sub'} Subscription Bundles
    .col-md-4.form-group
      .form-check.form-check-inline
        = check_box_tag 'bundle-nonsub', 1, true, :class => 'vouchertype-filter form-check-input'
        %label.form-check-label{:for => 'bundle-nonsub'} Nonsubscription Bundles
    .col-md-4.form-group
      .form-check.form-check-inline
        = check_box_tag 'subscriber', 1, true, :class => 'vouchertype-filter form-check-input'
        %label.form-check-label{:for => 'subscriber'} Vouchers included in a bundle

  %table.a1-table.table.table-hover#vouchertypes
    %thead
      %tr 
        %th
        %th.position-relative Sort #{popup_help_for(:vouchertype_display_order)}
        %th Name
        %th Price
        %th.position-relative Acc# #{popup_help_for(:vouchertype_account_code)}
        %th Sub?
        %th Who can purchase?
        %th Link
        %th Description
        %th.position-relative Walkup? #{popup_help_for(:vouchertype_walkup_sale_allowed)}
        %th
    %tbody
      - @vouchertypes.each do |vouchertype|
        %tr[vouchertype]{:class => [(vouchertype.subscription? ? 'subscriberVouchertype' : ''),css_class_for_vouchertype(vouchertype)] }
          %td
            - if @superadmin && vouchertype.vouchers.count == 0
              = link_to(image_tag('delete.png', :alt => '[Delete]'), vouchertype_path(vouchertype), {:method =>:delete, 'data-confirm' => "Deleting the '#{vouchertype.name}' voucher type cannot be undone. Continue?", :id => "delete_#{vouchertype.id}"})
          %td= vouchertype.display_order
          %td= link_to vouchertype.name, edit_vouchertype_path(vouchertype)
          %td.text-right= number_to_currency(vouchertype.price)   
          %td.text-right
            - unless vouchertype.zero_cost?
              = account_code_with_popup_link(vouchertype.account_code)
          %td.text-center= vouchertype.subscription? ? "Yes" : ""
          %td= vouchertype.visibility  
          %td.text-center= purchase_link_popup(link_icon, link_to_subscription_purchase(vouchertype.id), "'#{vouchertype.name}' subscriptions") if (vouchertype.subscription? && vouchertype.offer_public > 0)
          %td 
            -if vouchertype.bundle? 
              - vouchertype.included_vouchers.each_pair do |vt,qty| 
                - if (v = Vouchertype.find_by(:id => vt))
                  = sprintf("%2d  %s<br/>",qty,Vouchertype.find(vt).name).html_safe if qty>0
                - else
                  (Deleted Vouchertype ID #{vt})
          %td= vouchertype.walkup_sale_allowed? ? "Yes" : ""
          %td
            - unless vouchertype.bundle?
              = link_to 'Clone', clone_vouchertype_path(vouchertype), :class => 'btn btn-sm btn-warning'

.row
  .col= link_to  'New Voucher Type', new_vouchertype_path, :class => 'btn btn-primary'