commit dcb507659dd44f3a504fdc40d300102b41527a4e Author: spen Date: Fri Jan 30 15:02:08 2015 +0800 nkuht donate diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..bf7f0bd --- /dev/null +++ b/Gemfile @@ -0,0 +1,14 @@ +source "https://rubygems.org" + +# Declare your gem's dependencies in nkuht_donate.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use debugger +# gem 'debugger' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..9864228 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,87 @@ +PATH + remote: . + specs: + nkuht_donate (0.0.1) + rails (~> 4.1.7) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.1.7) + actionpack (= 4.1.7) + actionview (= 4.1.7) + mail (~> 2.5, >= 2.5.4) + actionpack (4.1.7) + actionview (= 4.1.7) + activesupport (= 4.1.7) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.7) + activesupport (= 4.1.7) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.7) + activesupport (= 4.1.7) + builder (~> 3.1) + activerecord (4.1.7) + activemodel (= 4.1.7) + activesupport (= 4.1.7) + arel (~> 5.0.0) + activesupport (4.1.7) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + arel (5.0.1.20140414130214) + builder (3.2.2) + erubis (2.7.0) + hike (1.2.3) + i18n (0.6.11) + json (1.8.1) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mime-types (2.4.3) + minitest (5.4.3) + multi_json (1.10.1) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rails (4.1.7) + actionmailer (= 4.1.7) + actionpack (= 4.1.7) + actionview (= 4.1.7) + activemodel (= 4.1.7) + activerecord (= 4.1.7) + activesupport (= 4.1.7) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.7) + sprockets-rails (~> 2.0) + railties (4.1.7) + actionpack (= 4.1.7) + activesupport (= 4.1.7) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.3.2) + sprockets (2.12.3) + hike (~> 1.2) + multi_json (~> 1.0) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.2.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) + sqlite3 (1.3.10) + thor (0.19.1) + thread_safe (0.3.4) + tilt (1.4.1) + tzinfo (1.2.2) + thread_safe (~> 0.1) + +PLATFORMS + ruby + +DEPENDENCIES + nkuht_donate! + sqlite3 diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..ea966ec --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2014 YOURNAME + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..c188354 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += NkuhtDonate + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..cfbc93a --- /dev/null +++ b/Rakefile @@ -0,0 +1,32 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'NkuhtDonate' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + + + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task default: :test diff --git a/app/assets/javascripts/check_nkuht_donate_set_departments.js.erb b/app/assets/javascripts/check_nkuht_donate_set_departments.js.erb new file mode 100644 index 0000000..6ef302d --- /dev/null +++ b/app/assets/javascripts/check_nkuht_donate_set_departments.js.erb @@ -0,0 +1,78 @@ +function checkTagsQuantity() { + var $tagLead = $('.tag-lead'), + $tagsGroups = $('.tags-groups'); + + $tagsGroups.each(function(i) { + var $children = $(this).children().length; + $tagLead.eq(i).children('.badge').text($children); + }) +} + +function checkedLength() { + var $tagsList = $('#tags-list'), + $defaultTags, + ids; + function reload_links() { + var _checked = 0; + ids = []; + $defaultTags = $('li.default input[type="checkbox"]'); + $defaultTags.each(function(index, el) { + if($(el).prop('checked')) { + _checked ++; + ids.push($(el).val()) + } + }); + console.log(_checked,ids) + if(_checked > 0) { + $('#deselect').removeClass('hide'); + $('#deselect').on('click', deselect); + $('#deleteUnits').attr('rel', "<%= Rails.application.routes.url_helpers.delete_departments_admin_nkuht_donate_departments_path %>" + "?ids=" + ids); + $('#deleteUnits').removeClass('hide'); + + } else { + $('#deselect').addClass('hide'); + $('#deleteUnits').attr('rel', ""); + $('#deleteUnits').addClass('hide'); + $('#deselect').off('click', deselect); + }; + } + $tagsList.on('click', '.card', function(event) { + reload_links(); + }); + $('#selectAllTags').on('click', function() { + $('.filter-item:not(".mark") input[type="checkbox"]').prop('checked', true); + $('.filter-item:not(".mark") .card').addClass('active'); + reload_links(); + }); + $('#deleteUnits').on('click', function() { + $('#delete_nkuht_donate_departments .tags-groups').empty(); + $('#delete_nkuht_donate_departments a.delete-tags').attr("href", $(this).attr("rel")); + if(ids.length) { + $('.filter-item').children('.card.active').each(function(i, e) { + console.log($(e)) + $(e).parents('.filter-item').clone().appendTo('#delete_nkuht_donate_departments .tags-groups'); + $('#delete_nkuht_donate_departments .tags-groups .filter-item').addClass('def'); + }); + } + + $('#delete_nkuht_donate_departments').modal('show', cleanTagInputs()); + function cleanTagInputs(){ + var $tagsDelete = $('#delete_nkuht_donate_departments'), + $filterItem = $tagsDelete.find('.filter-item'); + $filterItem.find('.card, .amount').remove(); + $filterItem.find('a').removeAttr('class'); + $filterItem.find('a').removeAttr('href'); + } + }); + + function deselect() { + $('.tags input[type="checkbox"]').prop('checked', false); + $('.card').removeClass('active'); + $('.bottomnav .toggable').not('.open-slide').addClass('hide'); + $('#deleteUnits').attr('rel', ""); + } +} + +$(function() { + checkedLength(); +}); diff --git a/app/assets/javascripts/check_nkuht_donate_set_units.js.erb b/app/assets/javascripts/check_nkuht_donate_set_units.js.erb new file mode 100755 index 0000000..990f055 --- /dev/null +++ b/app/assets/javascripts/check_nkuht_donate_set_units.js.erb @@ -0,0 +1,78 @@ +function checkTagsQuantity() { + var $tagLead = $('.tag-lead'), + $tagsGroups = $('.tags-groups'); + + $tagsGroups.each(function(i) { + var $children = $(this).children().length; + $tagLead.eq(i).children('.badge').text($children); + }) +} + +function checkedLength() { + var $tagsList = $('#tags-list'), + $defaultTags, + ids; + function reload_links() { + var _checked = 0; + ids = []; + $defaultTags = $('li.default input[type="checkbox"]'); + $defaultTags.each(function(index, el) { + if($(el).prop('checked')) { + _checked ++; + ids.push($(el).val()) + } + }); + console.log(_checked,ids) + if(_checked > 0) { + $('#deselect').removeClass('hide'); + $('#deselect').on('click', deselect); + $('#deleteUnits').attr('rel', "<%= Rails.application.routes.url_helpers.delete_units_admin_nkuht_donate_units_path %>" + "?ids=" + ids); + $('#deleteUnits').removeClass('hide'); + + } else { + $('#deselect').addClass('hide'); + $('#deleteUnits').attr('rel', ""); + $('#deleteUnits').addClass('hide'); + $('#deselect').off('click', deselect); + }; + } + $tagsList.on('click', '.card', function(event) { + reload_links(); + }); + $('#selectAllTags').on('click', function() { + $('.filter-item:not(".mark") input[type="checkbox"]').prop('checked', true); + $('.filter-item:not(".mark") .card').addClass('active'); + reload_links(); + }); + $('#deleteUnits').on('click', function() { + $('#delete_nkuht_donate_units .tags-groups').empty(); + $('#delete_nkuht_donate_units a.delete-tags').attr("href", $(this).attr("rel")); + if(ids.length) { + $('.filter-item').children('.card.active').each(function(i, e) { + console.log($(e)) + $(e).parents('.filter-item').clone().appendTo('#delete_nkuht_donate_units .tags-groups'); + $('#delete_nkuht_donate_units .tags-groups .filter-item').addClass('def'); + }); + } + + $('#delete_nkuht_donate_units').modal('show', cleanTagInputs()); + function cleanTagInputs(){ + var $tagsDelete = $('#delete_nkuht_donate_units'), + $filterItem = $tagsDelete.find('.filter-item'); + $filterItem.find('.card, .amount').remove(); + $filterItem.find('a').removeAttr('class'); + $filterItem.find('a').removeAttr('href'); + } + }); + + function deselect() { + $('.tags input[type="checkbox"]').prop('checked', false); + $('.card').removeClass('active'); + $('.bottomnav .toggable').not('.open-slide').addClass('hide'); + $('#deleteUnits').attr('rel', ""); + } +} + +$(function() { + checkedLength(); +}); diff --git a/app/assets/javascripts/check_nkuht_donate_set_uses.js.erb b/app/assets/javascripts/check_nkuht_donate_set_uses.js.erb new file mode 100644 index 0000000..42fe23b --- /dev/null +++ b/app/assets/javascripts/check_nkuht_donate_set_uses.js.erb @@ -0,0 +1,78 @@ +function checkTagsQuantity() { + var $tagLead = $('.tag-lead'), + $tagsGroups = $('.tags-groups'); + + $tagsGroups.each(function(i) { + var $children = $(this).children().length; + $tagLead.eq(i).children('.badge').text($children); + }) +} + +function checkedLength() { + var $tagsList = $('#tags-list'), + $defaultTags, + ids; + function reload_links() { + var _checked = 0; + ids = []; + $defaultTags = $('li.default input[type="checkbox"]'); + $defaultTags.each(function(index, el) { + if($(el).prop('checked')) { + _checked ++; + ids.push($(el).val()) + } + }); + console.log(_checked,ids) + if(_checked > 0) { + $('#deselect').removeClass('hide'); + $('#deselect').on('click', deselect); + $('#deleteUnits').attr('rel', "<%= Rails.application.routes.url_helpers.delete_uses_admin_nkuht_donate_uses_path %>" + "?ids=" + ids); + $('#deleteUnits').removeClass('hide'); + + } else { + $('#deselect').addClass('hide'); + $('#deleteUnits').attr('rel', ""); + $('#deleteUnits').addClass('hide'); + $('#deselect').off('click', deselect); + }; + } + $tagsList.on('click', '.card', function(event) { + reload_links(); + }); + $('#selectAllTags').on('click', function() { + $('.filter-item:not(".mark") input[type="checkbox"]').prop('checked', true); + $('.filter-item:not(".mark") .card').addClass('active'); + reload_links(); + }); + $('#deleteUnits').on('click', function() { + $('#delete_nkuht_donate_uses .tags-groups').empty(); + $('#delete_nkuht_donate_uses a.delete-tags').attr("href", $(this).attr("rel")); + if(ids.length) { + $('.filter-item').children('.card.active').each(function(i, e) { + console.log($(e)) + $(e).parents('.filter-item').clone().appendTo('#delete_nkuht_donate_uses .tags-groups'); + $('#delete_nkuht_donate_uses .tags-groups .filter-item').addClass('def'); + }); + } + + $('#delete_nkuht_donate_uses').modal('show', cleanTagInputs()); + function cleanTagInputs(){ + var $tagsDelete = $('#delete_nkuht_donate_uses'), + $filterItem = $tagsDelete.find('.filter-item'); + $filterItem.find('.card, .amount').remove(); + $filterItem.find('a').removeAttr('class'); + $filterItem.find('a').removeAttr('href'); + } + }); + + function deselect() { + $('.tags input[type="checkbox"]').prop('checked', false); + $('.card').removeClass('active'); + $('.bottomnav .toggable').not('.open-slide').addClass('hide'); + $('#deleteUnits').attr('rel', ""); + } +} + +$(function() { + checkedLength(); +}); diff --git a/app/assets/javascripts/nkuht_donate.js.coffee b/app/assets/javascripts/nkuht_donate.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/nkuht_donate.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/nkuht_donate_sets.js b/app/assets/javascripts/nkuht_donate_sets.js new file mode 100644 index 0000000..92be5b3 --- /dev/null +++ b/app/assets/javascripts/nkuht_donate_sets.js @@ -0,0 +1,29 @@ +$(function() { + + $('a[data-toggle="tab"]').click(function (e) { + e.preventDefault(); + $(this).tab('show'); + }); + + $.pageslide.closeCallback(function(pageslide, item) { + $('.filter-item').removeClass("active"); + }); + + $.pageslide.loadComplete(function(pageslide, item) { + + $('.filter-item').removeClass("active"); + + item.closest('li').addClass('active'); + + if(item.data('id') == 'new') { + resetForm(); + pageslide.find('form:eq(0)').attr('action', window.location.pathname); + pageslide.find('form:eq(0)').attr('method', 'post'); + }else { + setForm(item.data('form')); + pageslide.find('form:eq(0)').attr('action', window.location.pathname + '/' + item.data('id')); + pageslide.find('form:eq(0)').attr('method', 'put'); + } + + }); +}) \ No newline at end of file diff --git a/app/assets/stylesheets/nkuht_donate.css.scss b/app/assets/stylesheets/nkuht_donate.css.scss new file mode 100644 index 0000000..e1eeac3 --- /dev/null +++ b/app/assets/stylesheets/nkuht_donate.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the nkuht_donate controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/nkuht_donate_sets.css b/app/assets/stylesheets/nkuht_donate_sets.css new file mode 100644 index 0000000..16aacf9 --- /dev/null +++ b/app/assets/stylesheets/nkuht_donate_sets.css @@ -0,0 +1,3 @@ +/* + *= require lib/tags-groups +*/ \ No newline at end of file diff --git a/app/controllers/admin/nkuht_donate_departments_controller.rb b/app/controllers/admin/nkuht_donate_departments_controller.rb new file mode 100644 index 0000000..3074167 --- /dev/null +++ b/app/controllers/admin/nkuht_donate_departments_controller.rb @@ -0,0 +1,51 @@ +class Admin::NkuhtDonateDepartmentsController < OrbitAdminController + + def initialize + super + @app_title = 'nkuht_donate' + end + + def index + @nkuht_donate_departments = NkuhtDonateDepartment.all + @url = admin_nkuht_donate_department_path(@nkuht_donate_departments) + end + + def create + @nkuht_donate_department = NkuhtDonateDepartment.new(nkuht_donate_department_params) + @nkuht_donate_department.save + redirect_to request.referer, :status => 303 + end + + def create_in_form + @nkuht_donate_department = NkuhtDonateDepartment.new(nkuht_donate_department_params) + @nkuht_donate_department.save + render :json => {:id=>@nkuht_donate_department.id.to_s, :title=>@nkuht_donate_department.title}.to_json ,:layout => false + end + + def update + @nkuht_donate_department = NkuhtDonateDepartment.find(params[:id]) + @nkuht_donate_department.update_attributes(nkuht_donate_department_params) + redirect_to request.referer, :status => 303 + end + + def toggle + @nkuht_donate_department = NkuhtDonateDepartment.find(params[:id]) + @nkuht_donate_department.save! + redirect_to request.referer, :status => 303 + end + + def delete_departments + departments = NkuhtDonateDepartment.find(params[:ids].split(',')) rescue nil + if departments + departments.each(&:destroy) + end + redirect_to request.referer, :status => 303 + end + + private + + def nkuht_donate_department_params + params.require(:nkuht_donate_department).permit! + end + +end diff --git a/app/controllers/admin/nkuht_donate_units_controller.rb b/app/controllers/admin/nkuht_donate_units_controller.rb new file mode 100644 index 0000000..3c6fbf3 --- /dev/null +++ b/app/controllers/admin/nkuht_donate_units_controller.rb @@ -0,0 +1,52 @@ +class Admin::NkuhtDonateUnitsController < OrbitAdminController + + def initialize + super + @app_title = 'nkuht_donate' + end + + def index + @nkuht_donate_units = NkuhtDonateUnit.all + @url = admin_nkuht_donate_unit_path(@nkuht_donate_units) + end + + def create + @nkuht_donate_unit = NkuhtDonateUnit.new(nkuht_donate_unit_params) + @nkuht_donate_unit.save + redirect_to request.referer, :status => 303 + end + + def create_in_form + @nkuht_donate_unit = NkuhtDonateUnit.new(nkuht_donate_unit_params) + @nkuht_donate_unit.save + render :json => {:id=>@nkuht_donate_unit.id.to_s, :title=>@nkuht_donate_unit.title}.to_json ,:layout => false + end + + def update + @nkuht_donate_unit = NkuhtDonateUnit.find(params[:id]) + @nkuht_donate_unit.update_attributes(nkuht_donate_unit_params) + redirect_to request.referer, :status => 303 + end + + def toggle + @nkuht_donate_unit = NkuhtDonateUnit.find(params[:id]) + @nkuht_donate_unit.save! + redirect_to request.referer, :status => 303 + end + + def delete_units + units = NkuhtDonateUnit.find(params[:ids].split(',')) rescue nil + if units + units.each(&:destroy) + end + redirect_to request.referer, :status => 303 + end + + + private + + def nkuht_donate_unit_params + params.require(:nkuht_donate_unit).permit! + end + +end diff --git a/app/controllers/admin/nkuht_donate_uses_controller.rb b/app/controllers/admin/nkuht_donate_uses_controller.rb new file mode 100644 index 0000000..3297c0e --- /dev/null +++ b/app/controllers/admin/nkuht_donate_uses_controller.rb @@ -0,0 +1,52 @@ +class Admin::NkuhtDonateUsesController < OrbitAdminController + + def initialize + super + @app_title = 'nkuht_donate' + end + + def index + @nkuht_donate_uses = NkuhtDonateUse.all + @url = admin_nkuht_donate_use_path(@nkuht_donate_uses) + end + + def create + @nkuht_donate_use = NkuhtDonateUse.new(nkuht_donate_use_params) + @nkuht_donate_use.save + redirect_to request.referer, :status => 303 + end + + def create_in_form + @nkuht_donate_use = NkuhtDonateUse.new(nkuht_donate_use_params) + @nkuht_donate_use.save + render :json => {:id=>@nkuht_donate_use.id.to_s, :title=>@nkuht_donate_use.title}.to_json ,:layout => false + end + + def update + @nkuht_donate_use = NkuhtDonateUse.find(params[:id]) + @nkuht_donate_use.update_attributes(nkuht_donate_use_params) + redirect_to request.referer, :status => 303 + end + + def toggle + @nkuht_donate_use = NkuhtDonateUse.find(params[:id]) + @nkuht_donate_use.save! + redirect_to request.referer, :status => 303 + end + + def delete_uses + uses = NkuhtDonateUse.find(params[:ids].split(',')) rescue nil + if uses + uses.each(&:destroy) + end + redirect_to request.referer, :status => 303 + end + + + private + + def nkuht_donate_use_params + params.require(:nkuht_donate_use).permit! + end + +end diff --git a/app/controllers/admin/nkuht_donates_controller.rb b/app/controllers/admin/nkuht_donates_controller.rb new file mode 100644 index 0000000..9e0861f --- /dev/null +++ b/app/controllers/admin/nkuht_donates_controller.rb @@ -0,0 +1,120 @@ +# encoding: utf-8 +class Admin::NkuhtDonatesController < OrbitAdminController + + require 'axlsx' + + before_action ->(module_app = @app_title) { set_variables module_app } + before_action :set_nkuht_donate, only: [:edit, :update, :set_write_off, :destroy] + + def initialize + super + @app_title = "nkuht_donate" + end + + def index + + @filter_fields = {} + @table_fields = ['nkuht_donate.donation_payment_number', 'nkuht_donate.donation_serial_date', 'nkuht_donate.name', 'nkuht_donate.donation_amount', 'nkuht_donate.donation_way', 'nkuht_donate.donate_public', 'nkuht_donate.donation_unit', 'nkuht_donate.donation_use', 'nkuht_donate.donation_payment_status', 'nkuht_donate.donation_write_off_status'] + + !params[:sort].blank? ? sort = {params[:sort].to_sym=>params[:order]} : sort = {:created_at=>"desc"} + + @nkuht_donates = NkuhtDonateMain.all.order_by(sort) + + @nkuht_donates = search_data(@nkuht_donates,[:name]).page(params[:page]).per(10) + + if request.xhr? + render :partial => "index" + end + + end + + def export + + @nkuht_donates = NkuhtDonateMain.all.order_by({:created_at=>"desc"}) + respond_to do |format| + format.xlsx { + response.headers['Content-Disposition'] = 'attachment; filename="export.xlsx"' + } + end + + end + + def new + + @nkuht_donate = NkuhtDonateMain.new + + @nkuht_donate_units = NkuhtDonateUnit.all + @nkuht_donate_departments = NkuhtDonateDepartment.all + @nkuht_donate_uses = NkuhtDonateUse.all + + @showother = "hide" + + end + + def create + + nkuht_donate = NkuhtDonateMain.new(nkuht_donate_params) + + nkuht_donate.donation_serial_number = NkuhtDonateMain.get_serial_number + nkuht_donate.donation_payment_number = NkuhtDonateMain.get_payment_number + + nkuht_donate.create_user_id = current_user.id + nkuht_donate.update_user_id = current_user.id + nkuht_donate.save + redirect_to params['referer_url'] + + end + + def edit + + @nkuht_donate_units = NkuhtDonateUnit.all + @nkuht_donate_departments = NkuhtDonateDepartment.all + @nkuht_donate_uses = NkuhtDonateUse.all + + if !@nkuht_donate.nkuht_donate_use_id.blank? + if @nkuht_donate.nkuht_donate_use.title == "其他" || @nkuht_donate.nkuht_donate_use.title == "Other" + @showother = "" + else + @showother = "hide" + end + else + @showother = "hide" + end + + end + + def update + + @nkuht_donate.update_user_id = current_user.id + + @nkuht_donate.update_attributes(nkuht_donate_params) + redirect_to params['referer_url'] + + end + + def set_write_off + + @nkuht_donate.donation_write_off_status = true + @nkuht_donate.save + + redirect_to "/admin/nkuht_donates?page=#{params['page']}" + + end + + def destroy + + @nkuht_donate.destroy + redirect_to "/admin/nkuht_donates" + + end + + private + + def set_nkuht_donate + @nkuht_donate = NkuhtDonateMain.find(params[:id]) + end + + def nkuht_donate_params + params.require(:nkuht_donate_main).permit! + end +end diff --git a/app/controllers/nkuht_donates_controller.rb b/app/controllers/nkuht_donates_controller.rb new file mode 100644 index 0000000..a673335 --- /dev/null +++ b/app/controllers/nkuht_donates_controller.rb @@ -0,0 +1,214 @@ +class NkuhtDonatesController < ApplicationController + + include ApplicationHelper + + include SimpleCaptcha::ControllerHelpers + + def index + + nkuht_donate = NkuhtDonateMain.new + + nkuht_donate_units = NkuhtDonateUnit.all + nkuht_donate_departments = NkuhtDonateDepartment.all + nkuht_donate_uses = NkuhtDonateUse.all + + { + "nkuht_donate" => nkuht_donate, + "nkuht_donate_units" => nkuht_donate_units, + "nkuht_donate_departments" => nkuht_donate_departments, + "nkuht_donate_uses" => nkuht_donate_uses + } + + end + + def donate_list + params = OrbitHelper.params + + if !params[:mq].blank? + nkuht_donates = NkuhtDonateMain.where(:donate_public=>true).any_of({:name => /#{params[:mq]}/i}).order_by(:created_at=>"desc").page(params[:page_no]).per(20) + else + nkuht_donates = NkuhtDonateMain.where(:donate_public=>true).order_by(:created_at=>"desc").page(params[:page_no]).per(20) + end + + { + "nkuht_donates" => nkuht_donates, + "total_pages" => nkuht_donates.total_pages + } + + end + + def receipt_notice + + params = OrbitHelper.params + + nkuht_donate = NkuhtDonateMain.find(params[:no]) + + { + "nkuht_donate" => nkuht_donate + } + + end + + def create + + @nkuht_donate = NkuhtDonateMain.new(nkuht_donate_params) + + @nkuht_donate.donation_serial_number = NkuhtDonateMain.get_serial_number + @nkuht_donate.donation_payment_number = NkuhtDonateMain.get_payment_number + + if @nkuht_donate.donation_amount < '1' + + @notice = [] + @notice << t('nkuht_donate.donation_amount_err') + redirect_to "#{params[:referer_url]}", :notice => @notice + + elsif @nkuht_donate.donation_way == '2' and @nkuht_donate.donation_amount > '30000' + + @notice = [] + @notice << t('nkuht_donate.donation_amount_atm') + redirect_to "#{params[:referer_url]}", :notice => @notice + + elsif @nkuht_donate.donation_way == '3' and @nkuht_donate.donation_amount > '20000' + + @notice = [] + @notice << t('nkuht_donate.donation_amount_market') + redirect_to "#{params[:referer_url]}", :notice => @notice + + elsif simple_captcha_valid? && @nkuht_donate.save + + # ways1: 信用卡 + # ways2: atm轉帳 + # ways3: 超商繳款 + # ways4: 現金 + # ways5: 支票 + # ways6: 匯款 + + if @nkuht_donate.donation_way == '1' + redirect_to "#{params[:referer_url]}/?method=print_card_payment&no=#{@nkuht_donate.id}" + elsif @nkuht_donate.donation_way == '2' + redirect_to "#{params[:referer_url]}/?method=print_atm_payment&no=#{@nkuht_donate.id}" + elsif @nkuht_donate.donation_way == '3' + redirect_to "#{params[:referer_url]}/?method=print_market_payment&no=#{@nkuht_donate.id}&layout=false" + else + redirect_to "#{params[:referer_url]}/?method=print_msg&no=#{@nkuht_donate.id}" + end + else + + if !simple_captcha_valid? + @notice = [t('recaptcha.errors.verification_failed')] + else + + @notice = [] + @errors = @nkuht_donate.errors.messages.first + + @notice << t('recaptcha.errors.verification_failed') if !gotcha_valid? + @notice << "#{t("nkuht_donate.donation_amount")}#{@errors[1][0]}" if !@errors.blank? + + end + redirect_to "#{params[:referer_url]}", :notice => @notice + # redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed') + end + + end + + def print_card_payment + + params = OrbitHelper.params + + nkuht_donate = NkuhtDonateMain.find(params[:no]) + + { + "nkuht_donate" => nkuht_donate + } + end + + def print_atm_payment + + require 'digest/sha1' + require 'openssl' + require 'base64' + # require 'mcrypt' + + params = OrbitHelper.params + + nkuht_donate = NkuhtDonateMain.find(params[:no]) + + sendseqno = nkuht_donate.donation_serial_time.to_datetime.strftime("%Y%m%d%H%M%S") + "%04d" % (nkuht_donate.donation_serial_number) + + { + "nkuht_donate" => nkuht_donate, + "xmldata" => Base64.encode64("#{sendseqno}T00774955421#{nkuht_donate.donation_payment_number}#{nkuht_donate.donation_payment_number}#{nkuht_donate.donation_amount}#{nkuht_donate.get_atm_mac_number}http://donations.nkuht.edu.tw/donate_atm") + } + + end + + def print_market_payment + + require 'barby' + require 'barby/barcode/code_39' + require 'barby/outputter/png_outputter' + + params = OrbitHelper.params + + nkuht_donate = NkuhtDonateMain.find(params[:no]) + + barcodes = nkuht_donate.get_market_number + + barcodes.each_with_index do |code,i| + barcode =Barby::Code39.new(code, true) + File.open("public/code39_#{i + 1}.png", 'w'){|f| + # f.write barcode.to_png(:margin => 3, :xdim => 2, :height => 50) + f.write barcode.to_png(:height => 40) + } + end + + { + "nkuht_donate" => nkuht_donate, + "barcodes" => barcodes + } + + end + + def print_msg + + params = OrbitHelper.params + + nkuht_donate = NkuhtDonateMain.find(params[:no]) + + { + "nkuht_donate" => nkuht_donate + } + + end + + def payment_ok + end + + def payment_no + + params = OrbitHelper.params + + nkuht_donate = NkuhtDonateMain.where(:_id => params['no']).first + + msg = { + 'V211' => '傳送序號重複,訊息丟棄', + 'V212' => '此筆訂單之收款資料已存在且已成功付款', + 'V213' => '此筆訂單之收款資料已存在,但交易仍在進行中', + 'V214' => '此筆訂單之收款資料已存在,但主機交易中斷狀態不明', + 'J001' => '主機交易逾時 Pending', + '0' => '收款交易成功', + '' => '收款交易失敗'} + + { + "nkuht_donate" => nkuht_donate, + "msg" => msg + } + + + end + + def nkuht_donate_params + params.require(:nkuht_donate_main).permit! + end + +end \ No newline at end of file diff --git a/app/helpers/nkuht_donate_helper.rb b/app/helpers/nkuht_donate_helper.rb new file mode 100644 index 0000000..4b1078b --- /dev/null +++ b/app/helpers/nkuht_donate_helper.rb @@ -0,0 +1,22 @@ +module NkuhtDonateHelper + def page_for_donate_payment(status=nil, id="") + + pages = Page.where(:module=>'nkuht_donate') + ann_page = pages.first + + if status == 'ok' + request.protocol+(request.host_with_port+'/'+I18n.locale.to_s+ann_page.url+'/?method=payment_ok').gsub('//','/') rescue "/" + else + request.protocol+(request.host_with_port+'/'+I18n.locale.to_s+ann_page.url+'/?method=payment_no&no='+id).gsub('//','/') rescue "/" + end + + end + + def page_for_donate_receipt_notice(donate=nil) + ann_page = nil + pages = Page.where(:module=>'nkuht_donate') + ann_page = pages.first + request.protocol+(request.host_with_port+'/'+I18n.locale.to_s+ann_page.url+'/?method=receipt_notice&no='+donate.to_param+"&layout=false").gsub('//','/') rescue "/" + end + +end \ No newline at end of file diff --git a/app/models/nkuht_donate_department.rb b/app/models/nkuht_donate_department.rb new file mode 100644 index 0000000..0c59892 --- /dev/null +++ b/app/models/nkuht_donate_department.rb @@ -0,0 +1,9 @@ +class NkuhtDonateDepartment + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + belongs_to :nkuht_donate_main + +end \ No newline at end of file diff --git a/app/models/nkuht_donate_main.rb b/app/models/nkuht_donate_main.rb new file mode 100644 index 0000000..a6eb64d --- /dev/null +++ b/app/models/nkuht_donate_main.rb @@ -0,0 +1,193 @@ +class NkuhtDonateMain + include Mongoid::Document + include Mongoid::Timestamps + + include OrbitModel::Impression + # encoding: utf-8 + + field :name + field :donors_service_unit + field :tel + field :email + field :donation_way, :default => 1 + field :cheque_number + field :donation_amount + field :donation_use_other + + field :is_alumni, :type => Boolean, :default => true + field :graduation_year + + field :has_receipt, :type => Boolean, :default => true + field :receipt_title, :default => 1 + field :receipt_title_other + + field :receipt_number + field :receipt_address, :default => 1 + field :receipt_address_other + field :donate_public, :type => Boolean, :default => true + + field :note + + field :create_user_id + field :update_user_id + + field :donation_serial_date, :type => String, :default => Date.current #新增日 + field :donation_serial_time, :type => String, :default => Time.current #新增日時分 + field :donation_serial_number #流水號 + field :donation_payment_number #銷帳編號 & 訂單編號 + + field :donation_payment_status, :type => Boolean, :default => false #付款狀態 + field :donation_payment_status_msg #付款失敗訊息代碼 + field :donation_write_off_status, :type => Boolean, :default => false #銷帳狀態 + + + belongs_to :nkuht_donate_unit + belongs_to :nkuht_donate_department + belongs_to :nkuht_donate_use + + validates_numericality_of :donation_amount, :only_integer => true + + #10335+年月日(8)+流水號(1~999) + def self.get_payment_number + + @number = '10335' + Date.current.strftime("%Y%m%d") + get_serial_number + + end + + def self.get_serial_number + number = "%03d" % ( NkuhtDonateMain.where(:donation_serial_date=>Date.current).count + 1 ) + # return number.rjust(3, '0') + end + + def get_atm_mac_number + #年月日時分秒+流水號4碼 == 傳送序號 + #傳送序號+特店代碼+訂單編號+銷帳編號+金額 + sendseqno = self.donation_serial_time.to_datetime.strftime("%Y%m%d%H%M%S") + "%04d" % (self.donation_serial_number) + + message = Digest::SHA1.hexdigest("#{sendseqno}T00774955421#{self.donation_payment_number}#{self.donation_payment_number}#{self.donation_amount}") + key = 'S8G46IY64UHZZBSKGZFI6D7E' + iv = '00000000' + + message = [message+iv].pack('H*') + + + # Encrypt plaintext using Triple DES + cipher = OpenSSL::Cipher::Cipher.new("des-ede3-cbc") + cipher.padding = 0 + cipher.key = key + cipher.iv = iv + cipher.encrypt # Call this before setting key or iv + ciphertext = cipher.update(message) + # ciphertext << cipher.final + # Base64-encode the ciphertext + encodedCipherText = Base64.strict_encode64(ciphertext) + # encodedCipherText = Base64.strict_encode64(ciphertext) + + return encodedCipherText + end + + def get_market_number + #’A’:1, ’B’:2, ’C’:3, ’D’:4, ’E’:5, ’F’:6, ’G’:7, ’H’:8, ’I’:9 + + # 第一段(9碼) 繳費期限yymmdd (6碼) + 代收項目6HC (3碼) + @date = self.donation_serial_date.to_date + 14 #到期日 + @pdate = (@date.strftime("%Y").to_i - 1911 ).to_s[-2..-1] + @date.strftime("%m%d") + @ckno1 = @pdate + '683' + @no1 = @pdate + '6HC' + + # 第二段(16碼) 交易序號由業者自行訂定(前5碼銀行編 貴校為10335,且16碼必須全為數字) + @no2 = self.donation_payment_number + + # 第三段(15碼) 應繳日期 mmdd (4碼) + 檢碼(2碼) + 應繳金額(9碼) + + @ckno3 = @pdate[-4..-1].to_s + ("%09d" % self.donation_amount) + @key1 = NkuhtDonateMain.get_market_number_key1(@ckno1, @no2, @ckno3) + @key2 = NkuhtDonateMain.get_market_number_key2(@ckno1, @no2, @ckno3) + + @no3 = @pdate[-4..-1].to_s + @key1 + @key2 + ("%09d" % self.donation_amount) + + return [@no1,@no2,@no3] + + end + + def self.get_market_number_key1(code1,code2,code3) + + @n1 = [] + + (0..8).each{|a| @n1 << code1[a].to_i if a % 2 == 0 } + + @n2 = [] + + (0..15).each{|a| @n2 << code2[a].to_i if a % 2 == 0 } + + @n3 = [] + + (0..12).each{|a| @n3 << code3[a].to_i if a % 2 == 0 } + + @key1 = (( @n1.sum + @n2.sum + @n3.sum ) % 11).to_s + + if @key1 == '0' + return 'A' + elsif @key1 == '10' + return 'B' + else + return @key1 + end + + end + + def self.get_market_number_key2(code1,code2,code3) + + @n1 = [] + + (0..8).each{|a| @n1 << code1[a].to_i if a % 2 != 0 } + + @n2 = [] + + (0..15).each{|a| @n2 << code2[a].to_i if a % 2 != 0 } + + @n3 = [] + + (0..12).each{|a| @n3 << code3[a].to_i if a % 2 != 0 } + + @key2 = (( @n1.sum + @n2.sum + @n3.sum ) % 11).to_s + + if @key2 == '0' + return 'X' + elsif @key2 == '10' + return 'Y' + else + return @key2 + end + + end + + # 轉大寫數字 + def self.change_cash( cash ) + + cNum = ["零","壹","貳","叁","肆","伍","陸","柒","捌","玖","-","-","萬","仟","佰","拾","億","仟","佰","拾","萬","仟","佰","拾",""] + + i = 0 + sNum = "" + sTemp = "" + result = "" + + tmp = cash.to_i + return '零' if tmp == 0 + raise '整數部分加二位小數長度不能大於15' if tmp.to_s.size > 15 + sNum = tmp.to_s.rjust(15, ' ') + + for i in 0..14 + stemp = sNum.slice(i, 1) + if stemp == ' ' + next + else + result += " " + cNum[stemp.to_i] + " " + cNum[i + 10] + end + end + + return result + + end + +end diff --git a/app/models/nkuht_donate_unit.rb b/app/models/nkuht_donate_unit.rb new file mode 100644 index 0000000..bd8d2c4 --- /dev/null +++ b/app/models/nkuht_donate_unit.rb @@ -0,0 +1,9 @@ +class NkuhtDonateUnit + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + belongs_to :nkuht_donate_main + +end \ No newline at end of file diff --git a/app/models/nkuht_donate_use.rb b/app/models/nkuht_donate_use.rb new file mode 100644 index 0000000..bb8b930 --- /dev/null +++ b/app/models/nkuht_donate_use.rb @@ -0,0 +1,9 @@ +class NkuhtDonateUse + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + belongs_to :nkuht_donate_main + +end \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_departments/_delete_modal.html.erb b/app/views/admin/nkuht_donate_departments/_delete_modal.html.erb new file mode 100644 index 0000000..64c6226 --- /dev/null +++ b/app/views/admin/nkuht_donate_departments/_delete_modal.html.erb @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_departments/_department.html.erb b/app/views/admin/nkuht_donate_departments/_department.html.erb new file mode 100644 index 0000000..01546a1 --- /dev/null +++ b/app/views/admin/nkuht_donate_departments/_department.html.erb @@ -0,0 +1,8 @@ +
  • +

    + +

    + <%= link_to '#', class: "open-slide", data: {title: t('nkuht_donate_department.edit_department'), id: department.id.to_s, form: department.title_translations} do %> + <%= department.title_translations.values.join(" / ") %> + <% end %> +
  • \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_departments/_form.html.erb b/app/views/admin/nkuht_donate_departments/_form.html.erb new file mode 100644 index 0000000..e5da237 --- /dev/null +++ b/app/views/admin/nkuht_donate_departments/_form.html.erb @@ -0,0 +1,11 @@ +<%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
    + +
    + + <%= t('front_page.name_field_helper') %> +
    +
    + <% end %> +<% end %> diff --git a/app/views/admin/nkuht_donate_departments/_index.html.erb b/app/views/admin/nkuht_donate_departments/_index.html.erb new file mode 100644 index 0000000..29d318f --- /dev/null +++ b/app/views/admin/nkuht_donate_departments/_index.html.erb @@ -0,0 +1,27 @@ + +
    +
    + + + <%= link_to t(:delete_), '#', id: "deleteUnits", class: "btn btn-danger toggable hide", rel: '' %> + <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('nkuht_donate_department.new_department'), id: 'new'} %> +
    +
    + + + +
    +
    +

    <%= t('nkuht_donate_department.set_department') %>

    + <% if !@nkuht_donate_departments.blank? %> +
      + <%= render partial: "department", collection: @nkuht_donate_departments, locals: {in_module: true} %> +
    + <% end %> +
    +
    + + + +<%= render 'delete_modal' %> + \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_departments/index.html.erb b/app/views/admin/nkuht_donate_departments/index.html.erb new file mode 100644 index 0000000..1ec9211 --- /dev/null +++ b/app/views/admin/nkuht_donate_departments/index.html.erb @@ -0,0 +1,81 @@ +
    + <%= render 'index' %> +
    + + +
    +
    + + + + +
    +
    +
    +
    +
    + +
    + +
    + <%= form_for :nkuht_donate_department, url: nil, remote: true do |f| %> +
    + <%= render :partial => "form", :locals => { :f => f } %> +
    + <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %> +
    +
    + <% end %> +
    + +
    + +
    +
    +
    +
    +
    + +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "nkuht_donate_sets" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "check_nkuht_donate_set_departments.js" %> + <%= javascript_include_tag "nkuht_donate_sets.js" %> +<% end %> + + + \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_departments/index.js.erb b/app/views/admin/nkuht_donate_departments/index.js.erb new file mode 100644 index 0000000..a5809c0 --- /dev/null +++ b/app/views/admin/nkuht_donate_departments/index.js.erb @@ -0,0 +1,8 @@ +$("#delete_nkuht_donate_departments").modal('hide'); +$("#nkuht_donate_departments_index").html("<%= j render 'index' %>") +$.pageslide.close(); +openSlide(); +$('.card').cardCheck({ + item: $('.card input[type="checkbox"]'), +}); +checkedLength(); \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_units/_delete_modal.html.erb b/app/views/admin/nkuht_donate_units/_delete_modal.html.erb new file mode 100644 index 0000000..6eb333a --- /dev/null +++ b/app/views/admin/nkuht_donate_units/_delete_modal.html.erb @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_units/_form.html.erb b/app/views/admin/nkuht_donate_units/_form.html.erb new file mode 100644 index 0000000..154395e --- /dev/null +++ b/app/views/admin/nkuht_donate_units/_form.html.erb @@ -0,0 +1,11 @@ +<%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
    + +
    + + <%= t('front_page.name_field_helper') %> +
    +
    + <% end %> +<% end %> diff --git a/app/views/admin/nkuht_donate_units/_index.html.erb b/app/views/admin/nkuht_donate_units/_index.html.erb new file mode 100644 index 0000000..d6e6742 --- /dev/null +++ b/app/views/admin/nkuht_donate_units/_index.html.erb @@ -0,0 +1,27 @@ + +
    +
    + + + <%= link_to t(:delete_), '#', id: "deleteUnits", class: "btn btn-danger toggable hide", rel: '' %> + <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('nkuht_donate_unit.new_unit'), id: 'new'} %> +
    +
    + + + +
    +
    +

    <%= t('nkuht_donate_unit.set_unit') %>

    + <% if !@nkuht_donate_units.blank? %> +
      + <%= render partial: "unit", collection: @nkuht_donate_units, locals: {in_module: true} %> +
    + <% end %> +
    +
    + + + +<%= render 'delete_modal' %> + \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_units/_unit.html.erb b/app/views/admin/nkuht_donate_units/_unit.html.erb new file mode 100644 index 0000000..64c0c17 --- /dev/null +++ b/app/views/admin/nkuht_donate_units/_unit.html.erb @@ -0,0 +1,8 @@ +
  • +

    + +

    + <%= link_to '#', class: "open-slide", data: {title: t('nkuht_donate_unit.edit_unit'), id: unit.id.to_s, form: unit.title_translations} do %> + <%= unit.title_translations.values.join(" / ") %> + <% end %> +
  • \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_units/index.html.erb b/app/views/admin/nkuht_donate_units/index.html.erb new file mode 100644 index 0000000..5ea5da4 --- /dev/null +++ b/app/views/admin/nkuht_donate_units/index.html.erb @@ -0,0 +1,81 @@ +
    + <%= render 'index' %> +
    + + +
    +
    + + + + +
    +
    +
    +
    +
    + +
    + +
    + <%= form_for :nkuht_donate_unit, url: nil, remote: true do |f| %> +
    + <%= render :partial => "form", :locals => { :f => f } %> +
    + <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %> +
    +
    + <% end %> +
    + +
    + +
    +
    +
    +
    +
    + +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "nkuht_donate_sets" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "check_nkuht_donate_set_units.js" %> + <%= javascript_include_tag "nkuht_donate_sets.js" %> +<% end %> + + + \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_units/index.js.erb b/app/views/admin/nkuht_donate_units/index.js.erb new file mode 100644 index 0000000..54020ae --- /dev/null +++ b/app/views/admin/nkuht_donate_units/index.js.erb @@ -0,0 +1,8 @@ +$("#delete_nkuht_donate_units").modal('hide'); +$("#nkuht_donate_units_index").html("<%= j render 'index' %>") +$.pageslide.close(); +openSlide(); +$('.card').cardCheck({ + item: $('.card input[type="checkbox"]'), +}); +checkedLength(); \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_uses/_delete_modal.html.erb b/app/views/admin/nkuht_donate_uses/_delete_modal.html.erb new file mode 100644 index 0000000..bd1d290 --- /dev/null +++ b/app/views/admin/nkuht_donate_uses/_delete_modal.html.erb @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_uses/_form.html.erb b/app/views/admin/nkuht_donate_uses/_form.html.erb new file mode 100644 index 0000000..0dd8c41 --- /dev/null +++ b/app/views/admin/nkuht_donate_uses/_form.html.erb @@ -0,0 +1,11 @@ +<%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
    + +
    + + <%= t('front_page.name_field_helper') %> +
    +
    + <% end %> +<% end %> diff --git a/app/views/admin/nkuht_donate_uses/_index.html.erb b/app/views/admin/nkuht_donate_uses/_index.html.erb new file mode 100644 index 0000000..036e578 --- /dev/null +++ b/app/views/admin/nkuht_donate_uses/_index.html.erb @@ -0,0 +1,27 @@ + +
    +
    + + + <%= link_to t(:delete_), '#', id: "deleteUnits", class: "btn btn-danger toggable hide", rel: '' %> + <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('nkuht_donate_use.new_use'), id: 'new'} %> +
    +
    + + + +
    +
    +

    <%= t('nkuht_donate_use.set_use') %>

    + <% if !@nkuht_donate_uses.blank? %> +
      + <%= render partial: "use", collection: @nkuht_donate_uses, locals: {in_module: true} %> +
    + <% end %> +
    +
    + + + +<%= render 'delete_modal' %> + \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_uses/_use.html.erb b/app/views/admin/nkuht_donate_uses/_use.html.erb new file mode 100644 index 0000000..b5f65fb --- /dev/null +++ b/app/views/admin/nkuht_donate_uses/_use.html.erb @@ -0,0 +1,8 @@ +
  • +

    + +

    + <%= link_to '#', class: "open-slide", data: {title: t('nkuht_donate_use.edit_use'), id: use.id.to_s, form: use.title_translations} do %> + <%= use.title_translations.values.join(" / ") %> + <% end %> +
  • \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_uses/index.html.erb b/app/views/admin/nkuht_donate_uses/index.html.erb new file mode 100644 index 0000000..8417437 --- /dev/null +++ b/app/views/admin/nkuht_donate_uses/index.html.erb @@ -0,0 +1,81 @@ +
    + <%= render 'index' %> +
    + + +
    +
    + + + + +
    +
    +
    +
    +
    + +
    + +
    + <%= form_for :nkuht_donate_use, url: nil, remote: true do |f| %> +
    + <%= render :partial => "form", :locals => { :f => f } %> +
    + <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %> +
    +
    + <% end %> +
    + +
    + +
    +
    +
    +
    +
    + +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "nkuht_donate_sets" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "check_nkuht_donate_set_uses.js" %> + <%= javascript_include_tag "nkuht_donate_sets.js" %> +<% end %> + + + \ No newline at end of file diff --git a/app/views/admin/nkuht_donate_uses/index.js.erb b/app/views/admin/nkuht_donate_uses/index.js.erb new file mode 100644 index 0000000..d995d66 --- /dev/null +++ b/app/views/admin/nkuht_donate_uses/index.js.erb @@ -0,0 +1,8 @@ +$("#delete_nkuht_donate_uses").modal('hide'); +$("#nkuht_donate_uses_index").html("<%= j render 'index' %>") +$.pageslide.close(); +openSlide(); +$('.card').cardCheck({ + item: $('.card input[type="checkbox"]'), +}); +checkedLength(); \ No newline at end of file diff --git a/app/views/admin/nkuht_donates/_form.html.erb b/app/views/admin/nkuht_donates/_form.html.erb new file mode 100644 index 0000000..47ff28f --- /dev/null +++ b/app/views/admin/nkuht_donates/_form.html.erb @@ -0,0 +1,243 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + + +
    + + +
    + +
    + +
    + + +
    +
    + + +
    + +
    + +
    + <%= t('nkuht_donate.department') %> <%= f.select :nkuht_donate_department_id, @nkuht_donate_departments.collect{|t| [ t.title, t.id ]}, {prompt: 'Select'} %> +
    +
    + +
    + +
    + <%= f.text_field :graduation_year, :id=>'graduation_year', :placeholder=> t('nkuht_donate.graduation_year') %> +
    +
    + +
    + +
    + +
    + <%= f.text_field :name, :class=>"input-block-level", :placeholder=> t('nkuht_donate.name'), :required => true %> +
    +
    + +
    + +
    + <%= f.text_field :donors_service_unit, :class=>"input-block-level", :id=>'donors_service_unit', :placeholder=> t('nkuht_donate.donors_service_unit') %> +
    +
    + +
    + +
    + <%= f.text_field :tel, :class=>"input-block-level", :id=>'tel', :placeholder=> t('nkuht_donate.tel'), :required => true %> +
    +
    + +
    + +
    + <%= f.text_field :email, :class=>"input-block-level", :id=>'email', :placeholder=> t('nkuht_donate.email') %> +
    +
    + +
    + +
    + 新台幣<%= f.text_field :donation_amount, :id=>'donation_amount', :placeholder=> t('nkuht_donate.donation_amount'), :required => true %> 元(請輸入數字) +
    +
    + +
    + +
    + <% (1..6).each do |a| %> + + <% end %> +
    +
    + +
    + +
    + <%= f.text_field :cheque_number, :placeholder=> t('nkuht_donate.cheque_number') %> +
    +
    + +
    + +
    + <%= f.select :nkuht_donate_unit_id, @nkuht_donate_units.collect{|t| [ t.title, t.id ]}, {prompt: 'Select'} %> +
    +
    + +
    + +
    + <%= f.select :nkuht_donate_use_id, @nkuht_donate_uses.collect{|t| [ t.title, t.id ]}, {}, {:onChange=>"showOther(this)"} %> + + + <%= t('nkuht_donate.donation_use_other') %> + <%= f.text_field :donation_use_other, :id=>'donation_use_other' %> + +
    +
    + +
    + +
    + + +
    +
    + +
    + +
    + +
    + <% (1..3).each do |a| %> + + <% end %> + <%= f.text_field :receipt_title_other, :id=>'receipt_title_other' %> +
    +
    + +
    + +
    + <%= f.text_field :receipt_number, :id=>'receipt_number', :placeholder=> t('nkuht_donate.receipt_number') %> +
    +
    + +
    + +
    + <% (1..2).each do |a| %> + + <% end %> + <%= f.text_field :receipt_address_other, :class=>"input-block-level", :id=>'receipt_title_other' %> +
    +
    + +
    + +
    + +
    + + + +
    +
    + +
    + +
    + <%= f.text_area :note, rows: 5, :class=>"input-block-level", :placeholder=> t('nkuht_donate.note') %> +
    +
    + +
    + +
    + + +
    +
    + +
    + +
    + + +
    +
    + + +
    + +
    + + +
    + <%= get_referer_url[:action] rescue "" %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <% if !params['page'].blank? %> + + <% else %> + + <% end %> + <%= link_to t('cancel'), admin_nkuht_donates_path, :class=>"btn" %> +
    + + \ No newline at end of file diff --git a/app/views/admin/nkuht_donates/_index.html.erb b/app/views/admin/nkuht_donates/_index.html.erb new file mode 100644 index 0000000..2c942ee --- /dev/null +++ b/app/views/admin/nkuht_donates/_index.html.erb @@ -0,0 +1,66 @@ +<% # encoding: utf-8 %> + +<% content_for :right_nav do %> + +<% end %> + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + <% @nkuht_donates.each do |nkuht_donate| %> + + + + + + + + + + + + + <% end %> + +
    <%= nkuht_donate.donation_payment_number %><%= nkuht_donate.donation_serial_date %> + <%= nkuht_donate.name %> +
    + +
    +
    <%= number_to_currency(nkuht_donate.donation_amount, unit: '', precision: 0) %><%= t("nkuht_donate_ways.ways#{nkuht_donate.donation_way}") if !nkuht_donate.donation_way.blank? %><%= nkuht_donate.donate_public.blank? ? t('nkuht_donate.donate_public_no_') : t('nkuht_donate.donate_public_yes_') %><%= nkuht_donate.nkuht_donate_unit.title if !nkuht_donate.nkuht_donate_unit.blank? %> + <%= + if !nkuht_donate.nkuht_donate_use.blank? + if nkuht_donate.nkuht_donate_use.title == '其他' || nkuht_donate.nkuht_donate_use.title == 'Other' + "#{nkuht_donate.nkuht_donate_use.title}(#{nkuht_donate.donation_use_other})" + else + nkuht_donate.nkuht_donate_use.title + end + end + %> + <%= nkuht_donate.donation_payment_status ? t('nkuht_donate.yes_') : t('nkuht_donate.no_') %><%= nkuht_donate.donation_write_off_status ? t('nkuht_donate.yes_') : t('nkuht_donate.no_') %>
    + +<%= + content_tag :div, class: "bottomnav clearfix" do + content_tag :div, paginate(@nkuht_donates), class: "pagination pagination-centered" + end +%> \ No newline at end of file diff --git a/app/views/admin/nkuht_donates/edit.html.erb b/app/views/admin/nkuht_donates/edit.html.erb new file mode 100644 index 0000000..bd8e8c5 --- /dev/null +++ b/app/views/admin/nkuht_donates/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @nkuht_donate, url: admin_nkuht_donate_path(@nkuht_donate), html: {class: "form-horizontal main-forms"} do |f| %> +
    + <%= render :partial => 'form', locals: {f: f} %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/admin/nkuht_donates/export.xlsx.axlsx b/app/views/admin/nkuht_donates/export.xlsx.axlsx new file mode 100644 index 0000000..890883b --- /dev/null +++ b/app/views/admin/nkuht_donates/export.xlsx.axlsx @@ -0,0 +1,117 @@ +# encoding: utf-8 + +wb = xlsx_package.workbook +wb.add_worksheet(name: '捐贈芳名錄') do |sheet| + + row = [ + t('nkuht_donate.donate_public'), + t('nkuht_donate.donation_payment_number'), + t('nkuht_donate.donation_serial_date'), + t('nkuht_donate.is_alumni'), + t('nkuht_donate.graduation_department'), + t('nkuht_donate.graduation_year'), t('nkuht_donate.name'), + t('nkuht_donate.donors_service_unit'), t('nkuht_donate.tel'), + t('nkuht_donate.email'), + t('nkuht_donate.donation_amount'), + t('nkuht_donate.donation_way'), + t('nkuht_donate.cheque_number'), + t('nkuht_donate.donation_unit'), + t('nkuht_donate.donation_use'), + t('nkuht_donate.donation_use_other'), + t('nkuht_donate.has_receipt'), + t('nkuht_donate.receipt_title'), + t('nkuht_donate_receipt_title.title3'), + t('nkuht_donate.receipt_number'), + t('nkuht_donate.receipt_address'), + t('nkuht_donate_receipt_address.add2'), + t('nkuht_donate.donation_payment_status'), + t('nkuht_donate.donation_write_off_status'), + t('nkuht_donate.note') + ] + + sheet.add_row row + + @nkuht_donates.each do |nkuht_donate| + row2 = [] + + @donate_public = nkuht_donate.donate_public.blank? ? "#{t('nkuht_donate.donate_public_no_')} " : "#{t('nkuht_donate.donate_public_yes_')} " + row2 << @donate_public + + row2 << "#{nkuht_donate.donation_payment_number} " + + row2 << "#{nkuht_donate.donation_serial_time} " + + @is_alumni = nkuht_donate.is_alumni.blank? ? "#{t('nkuht_donate.no_')} " : "#{t('nkuht_donate.yes_')} " + row2 << @is_alumni + + @nkuht_donate_department = !nkuht_donate.nkuht_donate_department.blank? ? nkuht_donate.nkuht_donate_department.title : "" + row2 << @nkuht_donate_department + + @graduation_year = !nkuht_donate.nkuht_donate_department.blank? ? "#{nkuht_donate.graduation_year} " : "" + row2 << @graduation_year + + row2 << "#{nkuht_donate.name} " + + row2 << "#{nkuht_donate.donors_service_unit} " + + row2 << "#{nkuht_donate.tel} " + + row2 << "#{nkuht_donate.email} " + + row2 << "#{number_to_currency(nkuht_donate.donation_amount, unit: '', precision: 0)} " + + @donation_way = !nkuht_donate.donation_way.blank? ? t("nkuht_donate_ways.ways#{nkuht_donate.donation_way}") : "" + row2 << @donation_way + + @cheque_number = nkuht_donate.donation_way == '5' ? "#{nkuht_donate.cheque_number} " : "" + row2 << @cheque_number + + @nkuht_donate_unit = !nkuht_donate.nkuht_donate_unit.blank? ? nkuht_donate.nkuht_donate_unit.title : "" + row2 << @nkuht_donate_unit + + @nkuht_donate_use = !nkuht_donate.nkuht_donate_use.blank? ? nkuht_donate.nkuht_donate_use.title : "" + row2 << @nkuht_donate_use + + if !nkuht_donate.nkuht_donate_use.blank? + if @nkuht_donate_use == '其他' || @nkuht_donate_use == 'Other' + @donation_use_other = nkuht_donate.donation_use_other + else + @donation_use_other = "" + end + else + @donation_use_other = "" + end + row2 << @donation_use_other + + @has_receipt = !nkuht_donate.has_receipt.blank? ? "#{t('nkuht_donate.yes_')} " : "#{t('nkuht_donate.no_')} " + row2 << @has_receipt + + @receipt_title = !nkuht_donate.has_receipt.blank? ? t("nkuht_donate_receipt_title.title#{nkuht_donate.receipt_title}") : "" + row2 << @receipt_title + + @receipt_title_other = !nkuht_donate.has_receipt.blank? ? "#{nkuht_donate.receipt_title_other} " : "" + row2 << @receipt_title_other + + @receipt_number = !nkuht_donate.has_receipt.blank? ? "#{nkuht_donate.receipt_number} " : "" + row2 << @receipt_number + + @receipt_address = !nkuht_donate.has_receipt.blank? ? t("nkuht_donate_receipt_address.add#{nkuht_donate.receipt_address}") : "" + row2 << @receipt_address + + @receipt_address_other = !nkuht_donate.has_receipt.blank? ? "#{nkuht_donate.receipt_address_other} " : "" + row2 << @receipt_address_other + + @donation_payment_status = nkuht_donate.donation_payment_status ? t('nkuht_donate.yes_') : t('nkuht_donate.no_') + row2 << @donation_payment_status + + @donation_write_off_status = nkuht_donate.donation_write_off_status ? t('nkuht_donate.yes_') : t('nkuht_donate.no_') + row2 << @donation_write_off_status + + row2 << nkuht_donate.note + + sheet.add_row row2 + + end + +end + diff --git a/app/views/admin/nkuht_donates/index.html.erb b/app/views/admin/nkuht_donates/index.html.erb new file mode 100644 index 0000000..4513c37 --- /dev/null +++ b/app/views/admin/nkuht_donates/index.html.erb @@ -0,0 +1,6 @@ +<%= render_filter @filter_fields, "index_table" %> + + <%= render 'index'%> + + +<%= render 'layouts/delete_modal', delete_options: @delete_options %> diff --git a/app/views/admin/nkuht_donates/new.html.erb b/app/views/admin/nkuht_donates/new.html.erb new file mode 100644 index 0000000..bc54240 --- /dev/null +++ b/app/views/admin/nkuht_donates/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @nkuht_donate, url: admin_nkuht_donates_path, html: {class: "form-horizontal main-forms"} do |f| %> +
    + <%= render :partial => 'form', locals: {f: f} %> +
    +<% end %> \ No newline at end of file diff --git a/app/views/nkuht_donates/donate_list.html.erb b/app/views/nkuht_donates/donate_list.html.erb new file mode 100644 index 0000000..b69cc25 --- /dev/null +++ b/app/views/nkuht_donates/donate_list.html.erb @@ -0,0 +1,51 @@ +<% # encoding: utf-8 %> +<% + data = action_data + @nkuht_donates = data["nkuht_donates"] + @total_pages = data["total_pages"] +%> + +
    +
    + +捐款人姓名: <%= text_field_tag 'mq',( params[:mq] ? params[:mq] : '' ), {:id=>'filter-input', :class => "search-query input-medium", :placeholder => 'Search'} %> + + +
    +
    +
    +
    +

    捐款芳名錄

    + + + + + + + + + + + <% @nkuht_donates.each do |nkuht_donate| %> + + + + + + <% end %> + +
    捐款日期捐款人捐款用途捐款金額
    <%= (nkuht_donate.donation_serial_date.to_date.strftime("%Y").to_i - 1911 ).to_s + nkuht_donate.donation_serial_date.to_date.strftime("/%m/%d") %><%=nkuht_donate.name%> + <%= + if !nkuht_donate.nkuht_donate_use.blank? + if nkuht_donate.nkuht_donate_use.title == '其他' or nkuht_donate.nkuht_donate_use.title == 'Other' + "#{nkuht_donate.nkuht_donate_use.title}(#{nkuht_donate.donation_use_other})" + else + nkuht_donate.nkuht_donate_use.title + end + else + nil + end + %><%= number_to_currency(nkuht_donate.donation_amount, unit: '', precision: 0) %>元
    +
    + +<%= create_pagination(@total_pages).html_safe if @total_pages > 1 %> \ No newline at end of file diff --git a/app/views/nkuht_donates/index.html.erb b/app/views/nkuht_donates/index.html.erb new file mode 100644 index 0000000..f35fc5c --- /dev/null +++ b/app/views/nkuht_donates/index.html.erb @@ -0,0 +1,244 @@ +<% # encoding: utf-8 %> +<% + data = action_data + @nkuht_donate = data["nkuht_donate"] + @nkuht_donate_units = data["nkuht_donate_units"] + @nkuht_donate_departments = data["nkuht_donate_departments"] + @nkuht_donate_uses = data["nkuht_donate_uses"] +%> + +<% flash.collect do |key, msg| %> + <% msg.each do |m|%> + <%= + content_tag :p do + content_tag :span, m, :class => [key, "alert alert-error in fade"] + end + %> + <% end %> +<% end %> + +<%= form_for @nkuht_donate, url: nkuht_donates_path, html: {class: "content form-horizontal" , :id=>"new-nkuht-donate"} do |f| %> + +
    + +
    + +
    + + +
    +
    + + +
    + +
    + +
    + <%= t('nkuht_donate.department') %> <%= f.select :nkuht_donate_department_id, @nkuht_donate_departments.collect{|t| [ t.title, t.id ]}, {prompt: 'Select'} %> +
    + +
    + +
    + +
    + <%= f.text_field :graduation_year, :id=>'graduation_year', :class=>"form-control", :placeholder=> t('nkuht_donate.graduation_year') %> +
    +
    + +
    + + + +
    + +
    + <%= f.text_field :name, :id=>'nkuht_donate_name', :class=>"form-control", :placeholder=> t('nkuht_donate.name'), :required => true %> +
    +
    + (<%= t('nkuht_donate.anonymous') %>) +
    +
    + +
    + +
    + <%= f.text_field :donors_service_unit, :class=>"input-medium form-control", :id=>'donors_service_unit', :placeholder=> t('nkuht_donate.donors_service_unit') %> +
    +
    + +
    + +
    + <%= f.text_field :tel, :class=>"input-medium form-control", :id=>'tel', :placeholder=> t('nkuht_donate.tel'), :required => true %> +
    +
    + +
    + +
    + <%= f.text_field :email, :class=>"input-medium form-control", :id=>'email', :placeholder=> t('nkuht_donate.email') %> +
    +
    + +
    + +
    + <%= t('nkuht_donate.nt') %><%= f.number_field :donation_amount, :id=>'donation_amount', :min=>"1", :max=>"", :placeholder=> t('nkuht_donate.donation_amount'), :required => true %> <%= t('nkuht_donate.dollars') %>(<%= t('nkuht_donate.amount_note') %>) +
    +
    + +
    + +
    + <% (1..3).each do |a| %> + + <% end %> +
    +
    + +
    +
    + ※<%= t('nkuht_donate.notice') %>:
    + 1. <%= t('nkuht_donate.notice1') %>(<%= t('nkuht_donate.download_page') %>)<%= t('nkuht_donate.notice1_1') %>
    + 2. <%= t('nkuht_donate.notice2') %>
    + 3. <%= t('nkuht_donate.notice3') %>
    + 4.其餘捐款方式請參閱捐款方式 +
    +
    + +
    + +
    + <%= f.select :nkuht_donate_unit_id, @nkuht_donate_units.collect{|t| [ t.title, t.id ]}, {prompt: 'Select'} %> +
    +
    + +
    + +
    + <%= f.select :nkuht_donate_use_id, @nkuht_donate_uses.collect{|t| [ t.title, t.id ]}, {}, {:onChange=>"showOther(this)"} %> + + + <%= t('nkuht_donate.donation_use_other') %> + <%= f.text_field :donation_use_other, :id=>'donation_use_other' %> + +
    +
    + +
    + +
    + + +
    +
    + + +
    + +
    + +
    + <% (1..3).each do |a| %> + + <% end %> + <%= f.text_field :receipt_title_other, :id=>'receipt_title_other' %> +
    +
    + +
    + +
    + <%= f.text_field :receipt_number, :id=>'receipt_number', :class=>"form-control", :placeholder=> t('nkuht_donate.receipt_number') %> +
    +
    + +
    + +
    + <% (1..2).each do |a| %> + + <% end %> + <%= f.text_field :receipt_address_other, :class=>"input-medium form-control", :id=>'receipt_address_other' %> +
    +
    + +
    + + +
    + +
    + + + +
    +
    + + +
    + +
    + <%= f.text_area :note, rows: 5, :class=>"input-medium form-control", :placeholder=> t('nkuht_donate.note') %> +
    +
    + +
    + +
    + <%= show_simple_captcha %> +
    +
    + +
    +
    + "> + <%= f.submit t('submit'), class: 'btn btn-primary', :id => 'button-mail' %> + <%= f.button t('cancel'), type: 'reset', class: 'btn' %> +
    +
    + +
    + +<% end %> + + diff --git a/app/views/nkuht_donates/payment_no.html.erb b/app/views/nkuht_donates/payment_no.html.erb new file mode 100644 index 0000000..b1295ce --- /dev/null +++ b/app/views/nkuht_donates/payment_no.html.erb @@ -0,0 +1,19 @@ +<% # encoding: utf-8 %> + +<% + data = action_data + @nkuht_donate = action_data['nkuht_donate'] + @msg = action_data['msg'] +%> + +付款失敗, 請重新填寫捐款 + +<%# if @nkuht_donate.donation_way == '1' %> + + <%#= @nkuht_donate.donation_payment_status_msg %> + +<%# elsif @nkuht_donate.donation_way == '2' %> + + <%#= @msg["#{@nkuht_donate.donation_payment_status_msg}"] %> + +<%# end %> diff --git a/app/views/nkuht_donates/payment_ok.html.erb b/app/views/nkuht_donates/payment_ok.html.erb new file mode 100644 index 0000000..751e58e --- /dev/null +++ b/app/views/nkuht_donates/payment_ok.html.erb @@ -0,0 +1,6 @@ +<% # encoding: utf-8 %> + +<% + data = action_data +%> +付款完成 \ No newline at end of file diff --git a/app/views/nkuht_donates/print_atm_payment.html.erb b/app/views/nkuht_donates/print_atm_payment.html.erb new file mode 100644 index 0000000..74f7036 --- /dev/null +++ b/app/views/nkuht_donates/print_atm_payment.html.erb @@ -0,0 +1,21 @@ +<% # encoding: utf-8 %> + +<% + data = action_data + @nkuht_donate = data["nkuht_donate"] + @xmldata = data["xmldata"] +%> + +<% if @nkuht_donate.donation_way == '2' %> + +
    + +
    + + + +<% else %> +no data +<% end %> \ No newline at end of file diff --git a/app/views/nkuht_donates/print_card_payment.html.erb b/app/views/nkuht_donates/print_card_payment.html.erb new file mode 100644 index 0000000..4157597 --- /dev/null +++ b/app/views/nkuht_donates/print_card_payment.html.erb @@ -0,0 +1,36 @@ +<% # encoding: utf-8 %> + +<% + data = action_data + @nkuht_donate = data["nkuht_donate"] +%> + +<% if @nkuht_donate.donation_way == '1' %> + +
    + + + + + + + + + + + + + + + + + +
    + + + +<% else %> +no data +<% end %> \ No newline at end of file diff --git a/app/views/nkuht_donates/print_market_payment.html.erb b/app/views/nkuht_donates/print_market_payment.html.erb new file mode 100644 index 0000000..8b551fe --- /dev/null +++ b/app/views/nkuht_donates/print_market_payment.html.erb @@ -0,0 +1,130 @@ +<% # encoding: utf-8 %> +<% + data = action_data + @nkuht_donate = data["nkuht_donate"] + @barcodes = data["barcodes"] +%> + +<% if @nkuht_donate.donation_way == '3' %> + + + + + +捐贈繳款單 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    國立高雄餐旅大學 捐款單
    感謝您捐款興學!
    第一聯客戶留存繳款編號<%= @nkuht_donate.donation_payment_number %>超商代收收訖章
    繳款項目捐款 
    印單日期<%= @nkuht_donate.donation_serial_date.to_date %>
    繳款期限<%= @nkuht_donate.donation_serial_date.to_date + 14 %>
    應繳金額NT$ <%= @nkuht_donate.donation_amount %>
    *繳款完畢,請保留收據,作為日後對帳之依據。
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    國立高雄餐旅大學 捐款單
    感謝您捐款興學!
    第二聯超商代收留存繳款編號<%= @nkuht_donate.donation_payment_number %>超商代收專用條碼
    繳款項目捐款 + * " > *
    + <%= @barcodes[0] %>
    + + * " > *
    + <%= @barcodes[1] %>
    + + * " > *
    + <%= @barcodes[2] %>
    +
    印單日期<%= @nkuht_donate.donation_serial_date.to_date %>
    繳款期限<%= @nkuht_donate.donation_serial_date.to_date + 14 %>
    應繳金額NT$ <%= @nkuht_donate.donation_amount %>
    *繳款完畢,請保留收據,作為日後對帳之依據。
    +*本繳款單建議以雷射印表機列印,若無法讀取條碼,煩請捐款者以其他方式另行繳款。
    +

    超商代收說明:

    +
      +
    1. 請列印繳款單後至四大超商(統一、全家、萊爾富、OK)進行繳款。
    2. +
    3. 每筆繳款單手續費10元(繳款單每筆繳款上限為2萬元)。
    4. +
    5. 依據系統列印之繳款單,繳款有效日期為14天,未於期限內繳款者,繳款單自動失效。
    6. +
    + +
    + + + + + + +<% else %> +no data +<% end %> \ No newline at end of file diff --git a/app/views/nkuht_donates/print_msg.html.erb b/app/views/nkuht_donates/print_msg.html.erb new file mode 100644 index 0000000..3400db0 --- /dev/null +++ b/app/views/nkuht_donates/print_msg.html.erb @@ -0,0 +1,25 @@ +<% # encoding: utf-8 %> +<% + data = action_data + @nkuht_donate = data["nkuht_donate"] + + # 4: 現金 + # 5: 支票 + # 6: 匯款 +%> + +<% if @nkuht_donate.donation_way == '4' %> + +捐款成功!請本人或委託他人將現金送交總務處出納組,同時開立捐款收據。 + +<% elsif @nkuht_donate.donation_way == '5' %> + +捐款成功!支票抬頭請開立「國立高雄餐旅大學」,加劃橫線,註明「禁止背書轉讓」,以掛號郵寄至高雄市小港區松和路一號 國立高雄餐旅大學秘書室 收。 + +<% elsif @nkuht_donate.donation_way == '6' %> + +捐款成功!請匯入:「第一商業銀行小港分行」,戶名「國立高雄餐旅大學401專戶」,帳號「71430010289」。 + +<% else %> +no data +<% end %> \ No newline at end of file diff --git a/app/views/nkuht_donates/receipt_notice.html.erb b/app/views/nkuht_donates/receipt_notice.html.erb new file mode 100644 index 0000000..3c14ac4 --- /dev/null +++ b/app/views/nkuht_donates/receipt_notice.html.erb @@ -0,0 +1,128 @@ +<% # encoding: utf-8 %> +<% + data = action_data + @nkuht_donate = data["nkuht_donate"] +%> + +<% if @nkuht_donate.donation_way == '4' || @nkuht_donate.donation_way == '5' %> + + + + + + +收款通知書 + + + + + + + + + +
    繳件日期:  年  月  日
    + + + + + + + + + + + + <% + if @nkuht_donate.receipt_title == '1' + @receipt_title = @nkuht_donate.name + elsif @nkuht_donate.receipt_title == '2' + @receipt_title = @nkuht_donate.donors_service_unit + else + @receipt_title = @nkuht_donate.receipt_title_other + end + %> + + + + + + + + + + + + + + + + + + + + + +

    國立高雄餐旅大學收款通知書

    收款事由捐贈收入

    + 用途: + <%= + + if !@nkuht_donate.nkuht_donate_use.blank? + if @nkuht_donate.nkuht_donate_use.title == '其他' || @nkuht_donate.nkuht_donate_use.title == 'Other' + "#{@nkuht_donate.nkuht_donate_use.title}(#{@nkuht_donate.donation_use_other})" + else + @nkuht_donate.nkuht_donate_use.title + end + end + + %> + +
    繳 款 人 + 名稱(即收據抬頭):   <%= @receipt_title %>     +

    + 身份證字號(或統一編號):   <%= @nkuht_donate.receipt_number %>    +
    收款金額 + 金額:   <%= @nkuht_donate.donation_amount %>   元整(阿拉伯數字)

    + 新台幣<%= NkuhtDonateMain.change_cash(@nkuht_donate.donation_amount) %>元整 +
    收款日期 
    收款方式 + + <%= t("nkuht_donate_ways.ways#{@nkuht_donate.donation_way}") if !@nkuht_donate.donation_way.blank? %> + +
    備  註 + + 如需郵寄收據請加註遞送住址。
    +
    + <% if @nkuht_donate.receipt_address == '2' %> + 遞送住址: <%= @nkuht_donate.receipt_address_other %> + <% end %> +
    +
    +

    此   致    

    +   總  務  處  出  納  組
    + +
    經辦人:       + + +
    +
    + + + + + + + +<% else %> +no data +<% end %> diff --git a/app/views/simple_captcha/_simple_captcha.erb b/app/views/simple_captcha/_simple_captcha.erb new file mode 100644 index 0000000..748746f --- /dev/null +++ b/app/views/simple_captcha/_simple_captcha.erb @@ -0,0 +1,33 @@ + + +
    +
    + <%= simple_captcha_options[:image] %> +
    + +
    + <%= simple_captcha_options[:field] %> +
    +
    diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000..426790e --- /dev/null +++ b/bin/rails @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. + +ENGINE_ROOT = File.expand_path('../..', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/nkuht_donate/engine', __FILE__) + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) + +# require 'rails/all' +# require 'rails/engine/commands' +require "action_controller/railtie" +require "action_mailer/railtie" +require "sprockets/railtie" +require "rails/test_unit/railtie" +require 'rails/engine/commands' +require "mongoid/railtie" diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..e73d2fe --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,102 @@ +en: + + simple_captcha: + placeholder: "" + label: "" + + module_name: + nkuht_donate: Donation + + recaptcha: + errors: + verification_failed: Verification Code Error + + nkuht_donate: + export_csv: 匯出CSV + recaptcha: Verification Code + yes_: Yes + no_: No + donate_public_yes_: Agree + donate_public_no_: Disagree + nkuht_donate: Donation + donation_serial_date: 捐贈日期 + name: Donator Name + anonymous: Anonymous + donors_service_unit: Company Title + tel: Tel + email: Email + donation_amount: Donation Amount + nt: NT$ + dollars: Dollars + amount_note: Please fill in with Arabic numerals + donation_way: Donation Method + cheque_number: Cheque Number + donation_unit: Designated department for the donation + donation_use: Designated usage fot the donation + donation_use_other: Other + is_alumni: Alumnus? + department: Department + graduation_department: Department + graduation_year: Graduation Year + has_receipt: 是否開立收據 + receipt_title: Title of the receipt + receipt_number: ID number / Company ID number + receipt_address: Receipt + donate_public: Donator List Page + donator_show: to show my name and donation amount + donation_payment_number: 銷帳編號 + donation_payment_status: 付款 + donation_write_off_status: 銷帳 + receipt_notice: 收款通知書 + note: P.S. + notice: Notice + download_page: download page + notice1: Please make sure you have a ATM card and card reader before you delect donattion by ATM + notice1_1: ". If not, the system will redirect you to card reader driver download page and re-start the whole donation process after you download and install it." + notice2: "Donation amount for ATM method is limited to NT$30,000." + notice3: "Donation amount for paying at convenience stores is limited to NT$20,000." + set_nkuht_donate_units: 設定單位 + set_nkuht_donate_departments: 設定系別 + set_nkuht_donate_uses: 設定用途 + donation_amount_err: Donation amount is greater than 0 + donation_amount_atm: "Donation amount is limited to NT$30,000." + donation_amount_market: "Donation amount is limited to NT$20,000." + + frontend: + nkuht_donate: Donation Frontend + + nkuht_donate_ways: + ways1: Credit Card + ways2: ATM + ways3: Pay at Convenient Stores within Taiwan + ways4: Cash + ways5: Cheque + ways6: Telegraphic transfer + + nkuht_donate_receipt_title: + title1: Same as donator name + title2: Same as company title + title3: Other + + nkuht_donate_receipt_address: + add1: Apply in person + add2: Mail to the Address + + nkuht_donate_unit: + new_unit: 新增單位 + edit_unit: 編輯單位 + set_unit: 設定單位 + del_unit: 刪除單位 + + nkuht_donate_department: + new_department: 新增系別 + edit_department: 編輯系別 + set_department: 設定系別 + del_department: 刪除系別 + + nkuht_donate_use: + new_use: 新增用途 + edit_use: 編輯用途 + set_use: 設定用途 + del_use: 刪除用途 + diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml new file mode 100644 index 0000000..e66e081 --- /dev/null +++ b/config/locales/zh_tw.yml @@ -0,0 +1,105 @@ +zh_tw: + + simple_captcha: + placeholder: "" + label: "" + + restful_actions: + act_signup: 報名資料 + + module_name: + nkuht_donate: 捐贈 + + recaptcha: + errors: + verification_failed: 驗證碼錯誤 + + nkuht_donate: + export_csv: 匯出CSV + recaptcha: 驗證碼 + yes_: 是 + no_: 否 + donate_public_yes_: 同意 + donate_public_no_: 不同意 + nkuht_donate: 捐贈 + donation_serial_date: 捐贈日期 + name: 捐贈者姓名 + anonymous: 匿名者請填寫善心人士 + donors_service_unit: 捐贈者服務單位 + tel: 捐贈者聯絡電話 + email: 捐贈者E-mail + donation_amount: 捐款金額 + nt: 新台幣 + dollars: 元 + amount_note: 請填寫阿拉伯數字,勿填國字 + donation_way: 捐款方式 + cheque_number: 票號 + donation_unit: 指定捐贈單位 + donation_use: 指定捐贈用途 + donation_use_other: 說明 + is_alumni: 是否為系友 + department: 系別 + graduation_department: 畢業系所 + graduation_year: 畢業年 + has_receipt: 是否開立收據 + receipt_title: 收據抬頭 + receipt_number: 統一編號(或身分證號) + receipt_address: 寄送地址 + donate_public: 芳名錄公告 + donator_show: 將姓名及捐款金額公告於芳名錄 + donation_payment_number: 銷帳編號 + donation_payment_status: 付款 + donation_write_off_status: 銷帳 + receipt_notice: 收款通知書 + note: 備註 + download_page: 下載元件 + notice: 注意事項 + notice1: 如點選atm轉帳請先確認電腦是否有安裝讀卡機,若無安裝,網頁將連線至讀卡機元件安裝的頁面 + notice1_1: 。安裝完成後,先前所完成的捐款流程均無效,請再重新一次捐款流程。 + notice2: 如選擇atm轉帳,單筆捐款金額不得大於30000元。 + notice3: 如選擇超商繳款,單筆捐款金額不得大於20000元。 + set_nkuht_donate_units: 設定單位 + set_nkuht_donate_departments: 設定系別 + set_nkuht_donate_uses: 設定用途 + donation_amount_err: 捐款金額要大於0 + donation_amount_atm: 單筆捐款金額不得大於30000元 + donation_amount_market: 單筆捐款金額不得大於20000元 + + frontend: + nkuht_donate: 捐贈前台 + + nkuht_donate_ways: + ways1: 信用卡 + ways2: atm轉帳 + ways3: 超商繳款 + ways4: 現金 + ways5: 支票 + ways6: 匯款 + + nkuht_donate_receipt_title: + title1: 同捐款者姓名 + title2: 同捐款者服務單位 + title3: 其他 + + nkuht_donate_receipt_address: + add1: 親自領取 + add2: 住址 + + nkuht_donate_unit: + new_unit: 新增單位 + edit_unit: 編輯單位 + set_unit: 設定單位 + del_unit: 刪除單位 + + nkuht_donate_department: + new_department: 新增系別 + edit_department: 編輯系別 + set_department: 設定系別 + del_department: 刪除系別 + + nkuht_donate_use: + new_use: 新增用途 + edit_use: 編輯用途 + set_use: 設定用途 + del_use: 刪除用途 + diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..15cd06d --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,36 @@ +Rails.application.routes.draw do + + locales = Site.first.in_use_locales rescue I18n.available_locales + + scope "(:locale)", locale: Regexp.new(locales.join("|")) do + namespace :admin do + resources :nkuht_donates do + collection do + get 'export' + end + member do + get 'set_write_off' + end + end + resources :nkuht_donate_units do + collection do + post 'delete_units' + end + end + resources :nkuht_donate_departments do + collection do + post 'delete_departments' + end + end + resources :nkuht_donate_uses do + collection do + post 'delete_uses' + end + end + end + + resources :nkuht_donates + + end + +end diff --git a/lib/nkuht_donate.rb b/lib/nkuht_donate.rb new file mode 100644 index 0000000..d1db24e --- /dev/null +++ b/lib/nkuht_donate.rb @@ -0,0 +1,4 @@ +require "nkuht_donate/engine" + +module NkuhtDonate +end diff --git a/lib/nkuht_donate/engine.rb b/lib/nkuht_donate/engine.rb new file mode 100644 index 0000000..08d10a9 --- /dev/null +++ b/lib/nkuht_donate/engine.rb @@ -0,0 +1,46 @@ +module NkuhtDonate + class Engine < ::Rails::Engine + initializer "nkuht_donate" do + OrbitApp.registration "NkuhtDonate", :type => "ModuleApp" do + module_label "nkuht_donate.nkuht_donate" + base_url File.expand_path File.dirname(__FILE__) + authorizable + frontend_enabled + + side_bar do + head_label_i18n 'nkuht_donate.nkuht_donate', icon_class: "icon-credit-card" + available_for "managers" + active_for_controllers (['admin/nkuht_donates']) + head_link_path "admin_nkuht_donates_path" + + context_link 'list_', + :link_path=>"admin_nkuht_donates_path" , + :priority=>1, + :active_for_action=>{'admin/nkuht_donates'=>'index'}, + :available_for => 'managers' + context_link 'new_', + :link_path=>"new_admin_nkuht_donate_path" , + :priority=>2, + :active_for_action=>{'admin/nkuht_donates'=>'new'}, + :available_for => 'managers' + context_link 'nkuht_donate.set_nkuht_donate_departments', + :link_path=>"admin_nkuht_donate_departments_path" , + :priority=>3, + :active_for_action=>{'admin/nkuht_donates'=>'nkuht_donate_departments'}, + :available_for => 'managers' + context_link 'nkuht_donate.set_nkuht_donate_units', + :link_path=>"admin_nkuht_donate_units_path" , + :priority=>3, + :active_for_action=>{'admin/nkuht_donates'=>'nkuht_donate_units'}, + :available_for => 'managers' + context_link 'nkuht_donate.set_nkuht_donate_uses', + :link_path=>"admin_nkuht_donate_uses_path" , + :priority=>3, + :active_for_action=>{'admin/nkuht_donates'=>'nkuht_donate_uses'}, + :available_for => 'managers' + end + + end + end + end +end \ No newline at end of file diff --git a/lib/nkuht_donate/version.rb b/lib/nkuht_donate/version.rb new file mode 100644 index 0000000..390f3e8 --- /dev/null +++ b/lib/nkuht_donate/version.rb @@ -0,0 +1,3 @@ +module NkuhtDonate + VERSION = "0.0.1" +end diff --git a/lib/tasks/nkuht_donate_tasks.rake b/lib/tasks/nkuht_donate_tasks.rake new file mode 100644 index 0000000..9cc00e1 --- /dev/null +++ b/lib/tasks/nkuht_donate_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :nkuht_donate do +# # Task goes here +# end diff --git a/nkuht_donate.gemspec b/nkuht_donate.gemspec new file mode 100644 index 0000000..66aec04 --- /dev/null +++ b/nkuht_donate.gemspec @@ -0,0 +1,24 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "nkuht_donate/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "nkuht_donate" + s.version = NkuhtDonate::VERSION + s.authors = ["RulingDigital"] + s.email = ["orbit@rulingcom.com"] + s.homepage = "http://www.rulingcom.com" + s.summary = "NkuhtDonates for Orbit" + s.description = "NkuhtDonates for Orbit" + s.license = "MIT" + + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] + s.test_files = Dir["test/**/*"] + + s.add_dependency "barby", "~> 0.6.2" + s.add_dependency "chunky_png" + s.add_dependency "barby-chunky_png" + s.add_dependency "pack" +end diff --git a/test/controllers/nkuht_donate_controller_test.rb b/test/controllers/nkuht_donate_controller_test.rb new file mode 100644 index 0000000..47948f9 --- /dev/null +++ b/test/controllers/nkuht_donate_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class NkuhtDonateControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/dummy/README.rdoc b/test/dummy/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/test/dummy/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/test/dummy/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/test/dummy/app/assets/images/.keep b/test/dummy/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js new file mode 100644 index 0000000..5bc2e1c --- /dev/null +++ b/test/dummy/app/assets/javascripts/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/test/dummy/app/assets/stylesheets/application.css b/test/dummy/app/assets/stylesheets/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/test/dummy/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/test/dummy/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/test/dummy/app/controllers/concerns/.keep b/test/dummy/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test/dummy/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test/dummy/app/mailers/.keep b/test/dummy/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/.keep b/test/dummy/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/concerns/.keep b/test/dummy/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb new file mode 100644 index 0000000..593a778 --- /dev/null +++ b/test/dummy/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Dummy + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test/dummy/bin/bundle b/test/dummy/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/test/dummy/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails new file mode 100755 index 0000000..728cd85 --- /dev/null +++ b/test/dummy/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake new file mode 100755 index 0000000..1724048 --- /dev/null +++ b/test/dummy/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test/dummy/config.ru b/test/dummy/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/test/dummy/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb new file mode 100644 index 0000000..a5bea75 --- /dev/null +++ b/test/dummy/config/application.rb @@ -0,0 +1,23 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +Bundler.require(*Rails.groups) +require "nkuht_donate" + +module Dummy + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end + diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb new file mode 100644 index 0000000..6266cfc --- /dev/null +++ b/test/dummy/config/boot.rb @@ -0,0 +1,5 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml new file mode 100644 index 0000000..1c1a37c --- /dev/null +++ b/test/dummy/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/test/dummy/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb new file mode 100644 index 0000000..ddf0e90 --- /dev/null +++ b/test/dummy/config/environments/development.rb @@ -0,0 +1,37 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb new file mode 100644 index 0000000..b93a877 --- /dev/null +++ b/test/dummy/config/environments/production.rb @@ -0,0 +1,78 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb new file mode 100644 index 0000000..053f5b6 --- /dev/null +++ b/test/dummy/config/environments/test.rb @@ -0,0 +1,39 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb new file mode 100644 index 0000000..d2f4ec3 --- /dev/null +++ b/test/dummy/config/initializers/assets.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/test/dummy/config/initializers/backtrace_silencers.rb b/test/dummy/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/test/dummy/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test/dummy/config/initializers/cookies_serializer.rb b/test/dummy/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7a06a89 --- /dev/null +++ b/test/dummy/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/test/dummy/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test/dummy/config/initializers/mime_types.rb b/test/dummy/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/test/dummy/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/test/dummy/config/initializers/session_store.rb b/test/dummy/config/initializers/session_store.rb new file mode 100644 index 0000000..e766b67 --- /dev/null +++ b/test/dummy/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_dummy_session' diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/test/dummy/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/test/dummy/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/test/dummy/config/locales/en.yml b/test/dummy/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/test/dummy/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb new file mode 100644 index 0000000..3f66539 --- /dev/null +++ b/test/dummy/config/routes.rb @@ -0,0 +1,56 @@ +Rails.application.routes.draw do + # The priority is based upon order of creation: first created -> highest priority. + # See how all your routes lay out with "rake routes". + + # You can have the root of your site routed with "root" + # root 'welcome#index' + + # Example of regular route: + # get 'products/:id' => 'catalog#view' + + # Example of named route that can be invoked with purchase_url(id: product.id) + # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase + + # Example resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Example resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Example resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Example resource route with more complex sub-resources: + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', on: :collection + # end + # end + + # Example resource route with concerns: + # concern :toggleable do + # post 'toggle' + # end + # resources :posts, concerns: :toggleable + # resources :photos, concerns: :toggleable + + # Example resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end +end diff --git a/test/dummy/config/secrets.yml b/test/dummy/config/secrets.yml new file mode 100644 index 0000000..17c40fb --- /dev/null +++ b/test/dummy/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 59b108e68991041f31612ed88d72cb4b5db2e7a73330ce38322d1ab1868b0382e127ffd7d3a84da1384f439771209942bbb92e790fe57a6078b815deb628283a + +test: + secret_key_base: dacc1a3ac4e979fa27382fce67db69360ea22f83b805e1c9578e6ff56f89bbed3ceea4c29275d7b9616127fdf11d47da4809a685ada1901a77ff46aee0350bca + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/test/dummy/lib/assets/.keep b/test/dummy/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/log/.keep b/test/dummy/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/test/dummy/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
    +
    +

    The page you were looking for doesn't exist.

    +

    You may have mistyped the address or the page may have moved.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/test/dummy/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
    +
    +

    The change you wanted was rejected.

    +

    Maybe you tried to change something you didn't have access to.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/test/dummy/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
    +
    +

    We're sorry, but something went wrong.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/favicon.ico b/test/dummy/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test/helpers/nkuht_donate_helper_test.rb b/test/helpers/nkuht_donate_helper_test.rb new file mode 100644 index 0000000..e995045 --- /dev/null +++ b/test/helpers/nkuht_donate_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class NkuhtDonateHelperTest < ActionView::TestCase +end diff --git a/test/nkuht_donate_test.rb b/test/nkuht_donate_test.rb new file mode 100644 index 0000000..cd813c2 --- /dev/null +++ b/test/nkuht_donate_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class NkuhtDonateTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, NkuhtDonate + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..1e26a31 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,15 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require File.expand_path("../dummy/config/environment.rb", __FILE__) +require "rails/test_help" + +Rails.backtrace_cleaner.remove_silencers! + +# Load support files +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } + +# Load fixtures from the engine +if ActiveSupport::TestCase.method_defined?(:fixture_path=) + ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__) +end