<% # encoding: utf-8 %>
<% 
	data = action_data 
	@seminars = data["seminars"]
	@total_pages = data["total_pages"]
	@time_now = data["time_now"]
%>
<% begin %>
<table class="table table-hover table-striped seminar-index">
	<caption>
		<% page = OrbitHelper.page rescue Page.where(:page_id => OrbitHelper.params[:page_id]).first %>
		<h3><%= page.name rescue t('seminar.seminar') %></h3>
	</caption>
	<thead>
		<tr>
			<th class="col-md-2"><%= t(:category) %></th>
			<th class="col-md-3"><%= t('seminar.title') %></th>
			<th class="col-md-2"><%= t('seminar_signup.time') %></th>
			<th class="col-md-2"><%= t('seminar_signup.place') %></th>
			<th class="col-md-2"><%= t('seminar.signup') %></th>
		</tr>
	</thead>
	<tbody>
		<% 
			@seminars.each do |seminar| 	

			  if !seminar.registration_status.blank? and (seminar.signup_start_date <= @time_now rescue false) and ( seminar.signup_end_date.nil? or  seminar.signup_end_date+1 >= @time_now )
			  	sign_up = ('<a href="'+ OrbitHelper.url_to_show(seminar.to_param) + '" target="_blank">' + t('seminar.signup') + '</a>').html_safe
			  elsif seminar.registration_status.blank?
			  	sign_up = t('seminar.sign_up_not_open')
			  elsif (seminar.signup_start_date > @time_now rescue false)
			  	sign_up = t('seminar.sign_up_not_yet')
			  else
			  	sign_up = t('seminar.sign_up_overdue')
			  end
		%>
		<tr>
			<td><%= seminar.category.title %></td>
			<td>
				<% if (seminar.enable_custom_template rescue false) %>
					<%= ('<a href="'+ OrbitHelper.url_to_show(seminar.to_param) + '/home/introduction" target="_blank">' + seminar.title + '</a>').html_safe %>
				<% else %>
					<%= ('<a href="'+ OrbitHelper.url_to_show(seminar.to_param) + '?method=show_data" target="_blank">' + seminar.title + '</a>').html_safe %>
				<% end %>
			</td>
			<td><%= SeminarMain.time_range(seminar.seminar_start_date, seminar.seminar_end_date) %></td>
			<td><%= seminar.act_place %></td>
			<td>
				<%= sign_up %> <br />

				<%= 
				if !seminar.registration_status.blank? and seminar.registration_status.include?('C') and (seminar.contribute_start_date <= @time_now rescue false) and ( seminar.contribute_end_date.nil? or (seminar.contribute_end_date+1 >= @time_now rescue false) )
					if !session[:seminar_signup_id].blank? 
						if session[:seminar_main_id] == seminar.id
						('<a href="'+ OrbitHelper.url_to_show(seminar.to_param) + '?method=con_upload">' + t('seminar_signup.uploads') + '</a>').html_safe
						else
							('<a href="'+ OrbitHelper.url_to_show(seminar.to_param) + '?method=con_login">' + t('seminar_signup.con_login') + '</a>').html_safe
						end
					else
						('<a href="'+ OrbitHelper.url_to_show(seminar.to_param) + '?method=con_login">' + t('seminar_signup.con_login') + '</a>').html_safe
					end
				end
				 %>
			</td>
		</tr>
		<% end %>
	</tbody>
</table>
<% rescue => e
puts [e,e.backtrace]
	end
%>
<%= create_pagination(@total_pages).html_safe if @total_pages > 1 %>