Application_Form/app/views/seminars/show.html.erb

311 lines
11 KiB
Plaintext

<%
data = action_data
@seminar = data["seminar"]
@seminar_signup = data["seminar_signup"]
@time_now = data["time_now"]
@form_index = 0
%>
<% if !@seminar.registration_status.blank? and @seminar.signup_start_date < @time_now and ( @seminar.signup_end_date.nil? or @seminar.signup_end_date+1 > @time_now ) %>
<%#= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "basic/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/date.time.picker.js" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<% flash.each do |key, msg| %>
<%= content_tag :p, msg, :class => [key, "alert alert-error in fade"] %>
<% end %>
<%= form_for @seminar_signup, url: seminars_path, html: {class: "content form-horizontal" , :id=>"new-seminar-signup"} do |f| %>
<fieldset>
<!-- Title -->
<div class="form-group">
<label for="title" class="col-sm-2 control-label"><%= t('seminar.title') %></label>
<div class="col-sm-10">
<%= @seminar.title %>
</div>
</div>
<div class="form-group">
<label for="status" class="col-sm-2 control-label"><%= t('seminar.registration_status') %></label>
<div class="col-sm-10">
<% if @seminar.registration_status.include?('G') %>
<label class="radio-inline">
<%= f.radio_button :status, 'G', :checked => true , :onclick => "$('#registration_status').addClass('hide');" %> <%= t('seminar.registration_status_G') %>
</label>
<% end %>
<% if @seminar.registration_status.include?('C') %>
<label class="radio-inline">
<%= f.radio_button :status, 'C', :onclick => "$('#registration_status').removeClass('hide');", :checked => (@seminar.registration_status.count == 1 and @seminar.registration_status.include?('C') ? true : false) %> <%= t('seminar.registration_status_C') %>
</label>
<% end %>
</div>
</div>
<!-- Name -->
<div class="form-group">
<label for="name" class="col-sm-2 control-label">*<%= t('seminar_signup.name') %></label>
<div class="col-sm-10">
<%= f.text_field :name, :class=>"input-medium form-control", :id=>'name', :placeholder=> t('seminar_signup.name'), :required => true %>
</div>
</div>
<!-- unit -->
<div class="form-group">
<label for="unit" class="col-sm-2 control-label">*<%= t("seminar_signup.unit")%></label>
<div class="col-sm-10">
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="unit_<%= locale %>">
<%= f.fields_for "unit_translations".to_sym do |f| %>
<%= f.text_field locale, :class=>"input-medium form-control", :value => (@seminar_signup.send("unit_translations")[locale] rescue nil), :placeholder=> "#{t(locale.to_s)}", :required => true %>
<% end %>
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#unit_<%= locale %>" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
</div>
</div>
</div>
<!-- Tel -->
<div class="form-group">
<label for="tel" class="col-sm-2 control-label">*<%= t('seminar_signup.tel') %></label>
<div class="col-sm-10">
<%= f.text_field :tel, :class=>"input-medium form-control", :placeholder=> t('seminar_signup.tel'), :required => true %>
</div>
</div>
<!-- Phone -->
<div class="form-group">
<label for="phone" class="col-sm-2 control-label"><%= t('seminar_signup.phone') %></label>
<div class="col-sm-10">
<%= f.text_field :phone, :class=>"input-medium form-control", :placeholder=> t('seminar_signup.phone') %>
</div>
</div>
<!-- Fax -->
<div class="form-group">
<label for="fax" class="col-sm-2 control-label"><%= t('seminar_signup.fax') %></label>
<div class="col-sm-10">
<%= f.text_field :fax, :class=>"input-medium form-control", :placeholder=> t('seminar_signup.fax') %>
</div>
</div>
<!-- address -->
<div class="form-group">
<label for="address" class="col-sm-2 control-label"><%= t("seminar_signup.address")%></label>
<div class="col-sm-10">
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="address_<%= locale %>">
<%= f.fields_for "address_translations".to_sym do |f| %>
<%= f.text_field locale, :class=>"input-medium form-control", :value => (@seminar_signup.send("address_translations")[locale] rescue nil), :placeholder=> "#{t(locale.to_s)}" %>
<% end %>
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#address_<%= locale %>" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
</div>
</div>
</div>
<!-- Email -->
<div class="form-group">
<label for="email" class="col-sm-2 control-label">*<%= t(:email) %></label>
<div class="col-sm-10">
<%= f.email_field :email, :class=>"input-medium form-control availibility", :placeholder=> t(:email), :required => true %> <a href="#" onclick="window.open(' <%= OrbitHelper.url_to_show(@seminar.to_param) %>?method=check_email&no=<%=@seminar.id%>&layout=false&email='+ $('input[type=email]').val() , 'check mail', config='height=100,width=300');" class="btn btn-primary">check mail</a>
</div>
</div>
<div class="form-group <%= @seminar.registration_status[0] == 'C' ? '' : 'hide' %>" id="registration_status">
<label for="password" class="col-sm-2 control-label">*<%= t('seminar_signup.password') %></label>
<div class="col-sm-10">
<%= f.text_field :password, :class=>"input-medium form-control", :placeholder=> t('seminar_signup.password') %>
<%= t('seminar_signup.password_message') %>
</div>
</div>
<!-- Note -->
<div class="form-group">
<label for="note" class="col-sm-2 control-label"><%= t("seminar_signup.note")%></label>
<div class="col-sm-10">
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="note_<%= locale %>">
<%= f.fields_for "note_translations".to_sym do |f| %>
<%= f.text_area locale, rows: 5, :class=>"input-medium form-control", :value => (@seminar_signup.send("note_translations")[locale] rescue nil), :placeholder=> "#{t(locale.to_s)}" %>
<% end %>
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#note_<%= locale %>" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
</div>
</div>
</div>
<% @seminar.seminar_signup_fields.asc(:_id).each do |rf| %>
<div class="form-group">
<%= rf.block_helper(@seminar,@form_index,false,"seminar_signup",@seminar_signup, rf.to_require) %>
</div>
<% @form_index = @form_index +1 %>
<% end %>
<!-- 驗證碼 -->
<div class="form-group">
<label for="note" class="col-sm-2 control-label"><%= t('seminar_signup.recaptcha') %></label>
<div class="col-sm-10">
<%= gotcha_error %>
<%= gotcha %>
</div>
</div>
<!-- <div class="form-group">
<label for="note" class="col-sm-2 control-label"><%#= t('nkuht_donate.recaptcha') %></label>
<div class="col-sm-10">
<%#= show_simple_captcha %>
</div>
</div> -->
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<label>
<input id="agree" name="agree" value="1" type="checkbox" required="required">
<a href="<%= OrbitHelper.url_to_show(@seminar.to_param) %>?method=show_privacy" target="_blank"><%= t("seminar_signup.agree")%></a>
</label>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="hidden" name="referer_url" value="<%= request.original_url.split(request.env["HTTP_HOST"]).last %>">
<input type="hidden" name="seminar_signup[seminar_main_id]" value="<%= @seminar.id %>">
<%= f.submit t('submit'), class: 'btn btn-primary', :id => 'button-mail' %>
<%= f.button t('cancel'), type: 'reset', class: 'btn' %>
</div>
</div>
</fieldset>
<% end %>
<script type="text/javascript">
(function(){
var validated = false,
chks = false,
pwd = $('#seminar_signup_password')
$("form.content").submit(function(event) {
if ($('#seminar_signup_status_c:checked').val() == 'C'){
if (pwd.val() == ''){
pwd.attr('required', true);
pwd.focus();
alert( '<%= t('seminar_signup.password') %>' + ' is required');
return false;
}
}
<%
@seminar.seminar_signup_fields.asc(:_id).each do |rf|
if rf.markup == 'checkbox'
%>
var checkedCount = $("input[type=checkbox][id^=seminar_signup_values_<%= rf.id %>]:checked").length;
if (checkedCount == 0){
alert( '<%= rf.title %>' + ' is required');
return false;
}
<%
end
end
%>
var form = $(this),
isChecked = $('#agree:checked').val()?true:false;
if(!isChecked){
return false;
}
});
$(".availibility").blur(function(){
var type = $(this).attr("id"),
loader = $(this).parent().find('.loader'),
elem = $(this),
value = $(this).val() || null;
var checkAvailability = function(){
$.ajax({
url : "<%= "#{OrbitHelper.url_to_show(@seminar.to_param)}?method=check_availability&no=#{@seminar.id}" %>",
data : {"type" : type, "value" : value},
dataType : "json",
type : "get",
success : function(data){
if( data.success == true ){
alert("1tttt");
}else{
alert("1ssss2");
}
}
})
}
if( value ){
if(type == "seminar_signup_email"){
checkAvailability();
}
}
})
})();
</script>
<% elsif @seminar.registration_status.blank? %>
<%= t('seminar.sign_up_not_open') %>
<% elsif @seminar.signup_start_date > @time_now %>
<%= t('seminar.sign_up_not_yet') %>
<% else %>
<%= t('seminar.sign_up_overdue') %>
<% end %>