osem-fcy/app/views/admin/registrations/index.html.haml
2014-08-13 22:53:13 +03:00

76 lines
3.4 KiB
Text

.row
.col-md-12
.page-header
%h2
Registrations
- if @registrations
= "(#{@registrations.length})"
= " - Attended (#{@attended})"
.btn-group.pull-right
- if can? :create, Registration
= link_to "New", new_admin_conference_registration_path(@conference.short_title), :class => "btn btn-default"
- if can? :read, Registration
= link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-default"
= link_to "Export XLS", {:format => :xlsx}, :class => "btn btn-default"
%table.table.table-bordered.table-striped.table-hover#registrations
%thead
%th
No
- @headers.each do |h|
- h = h.gsub("_", " ")
%th
= h.capitalize
%th
%th
%th
- counter = 0
- @registrations.each do |registration|
%tr
%td
= counter +=1
- @headers.each do |field|
%td
- if field == "name"
#{registration.name} #{registration.nickname} #{registration.affiliation}
- if registration.supporter_level && registration.supporter_level.title != 'Free'
%p{:style => "color:red"}
= registration.supporter_level.title
-elsif field == 'attended'
= link_to "#{registration.send(field.to_sym)}", admin_conference_registrations_change_field_path(@conference.short_title, :id => registration.id, :view_field => "#{field}"), :method => :patch, ":#{field}" => registration.send(field.to_sym), :class => "btn btn-success"
-elsif (registration.send(field.to_sym).class == TrueClass || registration.send(field.to_sym).class == FalseClass)
= link_to "#{registration.send(field.to_sym)}", admin_conference_registrations_change_field_path(@conference.short_title, :id => registration.id, :view_field => "#{field}"), :method => :patch, ":#{field}" => registration.send(field.to_sym)
- elsif field == 'arrival' || field == 'departure'
= registration.send(field.to_sym).strftime("%d %b %H:%M") if registration.send(field.to_sym)
- else
= registration.send(field.to_sym)
%td
= link_to "Questions", "javascript: void(0)", :class => "questions btn btn-success", :id => counter, :onclick => "toggle('row#{counter}')"
%td
= link_to "Edit", edit_admin_conference_registration_path(@conference.short_title, :id => registration), :method => :get, :class => "btn btn-primary"
%td
= link_to "Delete", admin_conference_registration_path(@conference.short_title, registration), :method => :delete, :class => "btn btn-danger", data: {confirm: "Really delete registration for #{registration.name} #{registration.email}?"}
%tr{:id => "row#{counter}", :style=>"display:none;"}
%td{:colspan=>13}
= render :partial => "questions", :locals => {:registration => registration}
:javascript
$(document).ready(function() {
$('#registrations').dataTable( {
"bPaginate": false,
"bLengthChange": false
} );
} );
function toggle(rowid) {
if( document.getElementById(rowid).style.display=='none' ){
document.getElementById(rowid).style.display = '';
}else{
document.getElementById(rowid).style.display = 'none';
}
};