409 lines
18 KiB
Plaintext
409 lines
18 KiB
Plaintext
<%
|
|
data = action_data
|
|
@application_form = data["application_form"]
|
|
@application_form_signup = data["application_form_signup"]
|
|
@time_now = data["time_now"]
|
|
@form_index = 0
|
|
email_regex = @application_form.get_email_regex(true)
|
|
if data["prefix_url"]
|
|
prefix_url = data["prefix_url"]
|
|
else
|
|
prefix_url = OrbitHelper.url_to_show(@application_form.to_param)
|
|
end
|
|
%>
|
|
<% if @application_form.application_form_start_date < @time_now and ( @application_form.application_form_end_date.nil? or @application_form.application_form_end_date+1.days > @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" %>
|
|
<% notice = flash["notice"] || params[:notice] %>
|
|
<% flash.each do |key, msg| %>
|
|
<% next if key.to_s == "notice" %>
|
|
<%= content_tag :p, msg, :class => [key, "alert alert-error in fade"], :style => "color: red; font-weight: bold;" %>
|
|
<% end %>
|
|
<% if notice.present? %>
|
|
<%= content_tag :p, params[:notice], :class => ["notice alert alert-error in fade"], :style => "color: red; font-weight: bold;" %>
|
|
<script type="text/javascript">
|
|
window.alert("<%=notice%>");
|
|
</script>
|
|
<% end %>
|
|
<style type="text/css">
|
|
.checkbox input[type=checkbox], .checkbox-inline input[type=checkbox], .radio input[type=radio], .radio-inline input[type=radio] {
|
|
position: relative;
|
|
margin: 0;
|
|
}
|
|
</style>
|
|
<%= form_for @application_form_signup, url: application_forms_path, html: {class: "content form-horizontal" , :id=>"new-application_form-signup"} do |f| %>
|
|
<fieldset>
|
|
|
|
<!-- Title -->
|
|
<div class="form-group">
|
|
<label for="title" class="col-sm-2 control-label"><%= t('application_form.title') %></label>
|
|
<div class="col-sm-10">
|
|
<%= @application_form.title %>
|
|
</div>
|
|
</div>
|
|
<% if !@application_form.signup_note.blank? %>
|
|
<div class="form-group">
|
|
<label for="note" class="col-sm-2 control-label"><%= t('application_form.note') %></label>
|
|
<div class="col-sm-10">
|
|
<%= @application_form.signup_note.html_safe %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<div>
|
|
<div class="col-sm-12" style="text-align: center;"> *(<%= t('application_form.required') %>) </div>
|
|
</div>
|
|
<% if @application_form.application_form_signup_field_sets.count != 0 %>
|
|
<% @application_form.application_form_signup_field_sets.each do |signup_field| %>
|
|
<% if !(signup_field.disabled) && signup_field.field_name != 'recaptcha' %>
|
|
<div class="form-group<%= (@application_form.registration_status[0] == 'G' && signup_field.field_name == 'password') ? ' hide' : '' %>" id="<%= signup_field.field_name == 'password' ? 'registration_status' : '' %>">
|
|
<label for="<%= signup_field['name'][I18n.locale] %>" class="col-sm-2 control-label">
|
|
<% if !(['address','note'].include? signup_field.field_name) %>
|
|
*
|
|
<% end %>
|
|
<%= signup_field['name'][I18n.locale] %>
|
|
</label>
|
|
<% if signup_field.field_name == 'status' %>
|
|
<% status_translations = ['G','C'].map{|c| [c, t("application_form.registration_status_#{c}")] }.to_h %>
|
|
<% status_translations = {'G'=>'No','C'=>'Yes'} if (signup_field.name.values.select{|v| v.include?('?') || v.include?('是否')}.count != 0 rescue false) %>
|
|
<div class="col-sm-10">
|
|
<% if @application_form.registration_status.include?('G') %>
|
|
<label class="radio-inline">
|
|
<%= f.radio_button :status, 'G', :checked => true , :onclick => "$('#registration_status').addClass('hide');" %> <%= status_translations['G'] %>
|
|
</label>
|
|
<% end %>
|
|
<% if @application_form.registration_status.include?('C') %>
|
|
<label class="radio-inline">
|
|
<%= f.radio_button :status, 'C', :onclick => "$('#registration_status').removeClass('hide');", :checked => (@application_form.registration_status.count == 1 and @application_form.registration_status.include?('C') ? true : false) %> <%= status_translations['C'] %>
|
|
</label>
|
|
<% end %>
|
|
</div>
|
|
<% elsif signup_field.field_name == 'unit' %>
|
|
<div class="col-sm-10">
|
|
<%= f.text_field 'unit', :class=>"input-medium form-control", :value => (@application_form_signup.send("unit_translations")[locale] rescue nil), :placeholder=> "#{signup_field.placeholder[I18n.locale]}", :required => true %>
|
|
</div>
|
|
<% elsif signup_field.field_name == 'address' %>
|
|
<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 => (@application_form_signup.send("address_translations")[locale] rescue nil), :placeholder=> "#{signup_field.placeholder[I18n.locale]}" %>
|
|
<% 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>
|
|
<% elsif signup_field.field_name == 'email' %>
|
|
<div class="col-sm-10">
|
|
<%= f.email_field :email, :class=>"input-medium form-control availibility", :placeholder=> signup_field.placeholder[I18n.locale], :required => true %>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
function scrollIntoView(selector, offset = 0) {
|
|
window.scroll(0, document.querySelector(selector).offsetTop - offset);
|
|
}
|
|
var email_regex = "<%=email_regex%>";
|
|
if(email_regex.length != 0){
|
|
email_regex = new RegExp(email_regex);
|
|
var submit_flag = false;
|
|
var $form = $("#new-application_form-signup");
|
|
var email_field = $('#application_form_signup_email');
|
|
if($form.length != 0 && email_field.length != 0){
|
|
$form.submit(function(){
|
|
if(!submit_flag){
|
|
submit_flag = true;
|
|
if(email_regex.test(email_field.val())){
|
|
submit_flag = false;
|
|
}else{
|
|
email_field.css("border", "2px solid red");
|
|
scrollIntoView('#application_form_signup_email');
|
|
alert("<%=t('application_form.please_check_email_format')%>");
|
|
email_field.one("input",function(){
|
|
email_field.css("border", "");
|
|
})
|
|
submit_flag = false;
|
|
return false;
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
<% elsif signup_field.field_name == 'note' %>
|
|
<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 => (@application_form_signup.send("note_translations")[locale] rescue nil), :placeholder=> "#{signup_field.placeholder[I18n.locale]}" %>
|
|
<% 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>
|
|
<% else %>
|
|
<div class="col-sm-10">
|
|
<%= f.text_field signup_field['field_name'], :class=>"input-medium form-control", :id=>signup_field['field_name'], :placeholder=> signup_field.placeholder[I18n.locale], :required => (signup_field.field_name=='password' ? false : true) %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
<% else %>
|
|
<div class="form-group">
|
|
<label for="status" class="col-sm-2 control-label"><%= t('application_form.registration_status') %></label>
|
|
<div class="col-sm-10">
|
|
<% if @application_form.registration_status.include?('G') %>
|
|
<label class="radio-inline">
|
|
<%= f.radio_button :status, 'G', :checked => true , :onclick => "$('#registration_status').addClass('hide');" %> <%= t('application_form.registration_status_G') %>
|
|
</label>
|
|
<% end %>
|
|
<% if @application_form.registration_status.include?('C') %>
|
|
<label class="radio-inline">
|
|
<%= f.radio_button :status, 'C', :onclick => "$('#registration_status').removeClass('hide');", :checked => (@application_form.registration_status.count == 1 and @application_form.registration_status.include?('C') ? true : false) %> <%= t('application_form.registration_status_C') %>
|
|
</label>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Name to Last Name -->
|
|
<div class="form-group">
|
|
<label for="name" class="col-sm-2 control-label">*<%= t('application_form_signup.name') %></label>
|
|
<div class="col-sm-10">
|
|
<%= f.text_field :name, :class=>"input-medium form-control", :id=>'name', :placeholder=> t('application_form_signup.name'), :required => true %>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tel to First Name -->
|
|
<div class="form-group">
|
|
<label for="tel" class="col-sm-2 control-label">*<%= t('application_form_signup.tel') %></label>
|
|
<div class="col-sm-10">
|
|
<%= f.text_field :tel, :class=>"input-medium form-control", :placeholder=> t('application_form_signup.tel'), :required => true %>
|
|
</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 %>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
function scrollIntoView(selector, offset = 0) {
|
|
window.scroll(0, document.querySelector(selector).offsetTop - offset);
|
|
}
|
|
var email_regex = "<%=email_regex%>";
|
|
if(email_regex.length != 0){
|
|
email_regex = new RegExp(email_regex);
|
|
var submit_flag = false;
|
|
var $form = $("#new-application_form-signup");
|
|
var email_field = $('#application_form_signup_email');
|
|
if($form.length != 0 && email_field.length != 0){
|
|
$form.submit(function(){
|
|
if(!submit_flag){
|
|
submit_flag = true;
|
|
if(email_regex.test(email_field.val())){
|
|
submit_flag = false;
|
|
}else{
|
|
email_field.css("border", "2px solid red");
|
|
scrollIntoView('#application_form_signup_email');
|
|
alert("<%=t('application_form.please_check_email_format')%>");
|
|
email_field.one("input",function(){
|
|
email_field.css("border", "");
|
|
})
|
|
submit_flag = false;
|
|
return false;
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
</div>
|
|
|
|
<% end %>
|
|
<% @application_form.reviewer_enables.each_with_index do |flag,k| %>
|
|
<% if flag %>
|
|
<div class="form-group">
|
|
<label for="status" class="col-sm-2 control-label"><%= t("application_form.reviewers.#{k+1}") %></label>
|
|
<div class="col-sm-10">
|
|
<% tmp = Array(@application_form.reviewer_ids_list[k]) %>
|
|
<% if @application_form.reviewer_type_list[k]=='fixed' %>
|
|
<%= MemberProfile.where(:id.in=>tmp).collect{|m| m.name}.join(', ') %>
|
|
<% else %>
|
|
<%= render partial: 'application_forms/email_selection_box', locals: {field: "#{f.object_name}[reviewer_ids_list][#{k}][]", email_members: [], member_profiles: (tmp.count == 0 ? MemberProfile.all : MemberProfile.where(:id.in=>tmp)), index: "#{k+1}", select_name: "reviewer_ids_list_#{k}"} %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
|
|
<% end %>
|
|
<% end %>
|
|
<% @application_form.application_form_signup_fields.asc(:_id).each do |rf| %>
|
|
|
|
<div class="form-group">
|
|
|
|
<%= rf.block_helper(@application_form,@form_index,false,"application_form_signup",@application_form_signup, rf.to_require) %>
|
|
|
|
</div>
|
|
|
|
<% @form_index = @form_index +1 %>
|
|
|
|
<% end %>
|
|
|
|
|
|
<!-- 驗證碼 -->
|
|
<% if @application_form.application_form_signup_field_sets.count != 0 %>
|
|
<% if !(@application_form.application_form_signup_field_sets.select{|v| v.field_name=='recaptcha'}[0].disabled) %>
|
|
<div class="form-group">
|
|
<label for="note" class="col-sm-2 control-label"><%= t('application_form_signup.recaptcha') %></label>
|
|
<div class="col-sm-10">
|
|
<%= gotcha_error %>
|
|
<%= gotcha %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<!-- <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="<%= prefix_url %>?method=show_privacy" target="_blank"><%= t("application_form_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 rescue "/" %>">
|
|
<input type="hidden" name="application_form_signup[application_form_main_id]" value="<%= @application_form.id %>">
|
|
<%= f.submit "Submit", class: 'btn btn-primary', :id => 'button-mail' %>
|
|
<%= f.button "Delete", type: 'reset', class: 'btn' %>
|
|
</div>
|
|
</div>
|
|
|
|
</fieldset>
|
|
<% end %>
|
|
|
|
|
|
<script type="text/javascript">
|
|
(function(){
|
|
$(".rucaptcha-image").siblings("input[type=\"text\"]").attr("placeholder","Verification");
|
|
var validated = false,
|
|
chks = false,
|
|
pwd = $('#application_form_signup_password')
|
|
|
|
$("form.content").submit(function(event) {
|
|
|
|
|
|
if ($('#application_form_signup_status_c:checked').val() == 'C'){
|
|
if (pwd.val() == ''){
|
|
pwd.attr('required', true);
|
|
pwd.focus();
|
|
alert( '<%= t('application_form_signup.password') %>' + ' is required');
|
|
return false;
|
|
}
|
|
}
|
|
|
|
<%
|
|
@application_form.application_form_signup_fields.asc(:_id).each do |rf|
|
|
|
|
if rf.markup == 'checkbox'
|
|
%>
|
|
|
|
var checkedCount = $("input[type=checkbox][id^=application_form_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 : "<%= "#{prefix_url}?method=check_availability&no=#{@application_form.id}" %>",
|
|
data : {"type" : type, "value" : value},
|
|
dataType : "json",
|
|
type : "get",
|
|
success : function(data){
|
|
if( data.success == true ){
|
|
}else{
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
if( value ){
|
|
if(type == "application_form_signup_email"){
|
|
checkAvailability();
|
|
}
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
})();
|
|
</script>
|
|
|
|
<% elsif @application_form.application_form_start_date > @time_now %>
|
|
|
|
<%= t('application_form.sign_up_not_yet') %>
|
|
|
|
<% else %>
|
|
|
|
<%= t('application_form.sign_up_overdue') %>
|
|
|
|
<% end %>
|
|
<script type="text/javascript">
|
|
var email_regex = "<%=email_regex%>";
|
|
if(email_regex.length != 0)
|
|
email_regex = new RegExp(email_regex);
|
|
</script> |