diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1dfe31e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+.bundle/
+log/*.log
+pkg/
+test/dummy/db/*.sqlite3
+test/dummy/log/*.log
+test/dummy/tmp/
+test/dummy/.sass-cache
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..17f7400
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,17 @@
+source "http://rubygems.org"
+
+# Declare your gem's dependencies in ask.gemspec.
+# Bundler will treat runtime dependencies like base dependencies, and
+# development dependencies will be added by default to the :development group.
+gemspec
+
+# jquery-rails is used by the dummy application
+gem "jquery-rails"
+
+# 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/MIT-LICENSE b/MIT-LICENSE
new file mode 100644
index 0000000..5146945
--- /dev/null
+++ b/MIT-LICENSE
@@ -0,0 +1,20 @@
+Copyright 2013 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..9ca9e14
--- /dev/null
+++ b/README.rdoc
@@ -0,0 +1,3 @@
+= Ask
+
+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..fca490a
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,38 @@
+#!/usr/bin/env rake
+begin
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+begin
+ require 'rdoc/task'
+rescue LoadError
+ require 'rdoc/rdoc'
+ require 'rake/rdoctask'
+ RDoc::Task = Rake::RDocTask
+end
+
+RDoc::Task.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Ask'
+ 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/controllers/application_controller.rb b/app/controllers/application_controller.rb
new file mode 100644
index 0000000..b4ffa3a
--- /dev/null
+++ b/app/controllers/application_controller.rb
@@ -0,0 +1,23 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+ before_filter :set_locale
+
+ # Set I18n.locale
+ def set_locale
+ # update session if passed
+ session[:locale] = params[:locale] if params[:locale]
+
+ # set locale based on session or default
+ begin
+ # check if locale is valid for non site pages
+ if !VALID_LOCALES.include?(session[:locale])
+ I18n.locale = I18n.default_locale
+ else
+ I18n.locale = session[:locale]
+ end
+ rescue
+ I18n.locale = I18n.default_locale
+ end
+ end
+
+end
diff --git a/app/controllers/panel/ask/back_end/ask_acknowledgements_controller.rb b/app/controllers/panel/ask/back_end/ask_acknowledgements_controller.rb
new file mode 100644
index 0000000..58f2ef4
--- /dev/null
+++ b/app/controllers/panel/ask/back_end/ask_acknowledgements_controller.rb
@@ -0,0 +1,23 @@
+class Panel::Ask::BackEnd::AskAcknowledgementsController < OrbitBackendController
+ include AdminHelper
+ include OrbitControllerLib::DivisionForDisable
+
+ before_filter :for_app_manager
+
+ def initialize
+ super
+ @app_title = 'ask_acknowledgement'
+ end
+
+ def index
+ @ask_acknowledgement = AskAcknowledgement.first || AskAcknowledgement.create
+ @url = panel_ask_back_end_ask_acknowledgement_path(@ask_acknowledgement)
+ end
+
+ def update
+ @ask_acknowledgement = AskAcknowledgement.first
+ @ask_acknowledgement.update_attributes(params[:ask_acknowledgement])
+ redirect_to panel_ask_back_end_ask_acknowledgements_path, notice: t('ask.save_success')
+ end
+
+end
diff --git a/app/controllers/panel/ask/back_end/ask_admins_controller.rb b/app/controllers/panel/ask/back_end/ask_admins_controller.rb
new file mode 100644
index 0000000..b6994da
--- /dev/null
+++ b/app/controllers/panel/ask/back_end/ask_admins_controller.rb
@@ -0,0 +1,56 @@
+class Panel::Ask::BackEnd::AskAdminsController < OrbitBackendController
+
+ include AdminHelper
+ include OrbitControllerLib::DivisionForDisable
+
+ before_filter :for_app_manager
+
+ def initialize
+ super
+ @app_title = 'ask_admins'
+ end
+
+ def index
+ @ask_admins = AskAdmin.all
+ @ask_admin = AskAdmin.new
+ @url = panel_ask_back_end_ask_admins_path
+ end
+
+ def create
+ @ask_admin = AskAdmin.new(params[:ask_admin])
+ @ask_admin.save
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def edit
+ @ask_admin = AskAdmin.find(params[:id])
+ @url = panel_ask_back_end_ask_admin_path(@ask_admin)
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def update
+ @ask_admin = AskAdmin.find(params[:id])
+ @url = panel_ask_back_end_ask_admin_path(@ask_admin)
+ @ask_admin.update_attributes(params[:ask_admin])
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def destroy
+ @ask_admin = AskAdmin.find(params[:id])
+ @ask_admin.destroy
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
+end
diff --git a/app/controllers/panel/ask/back_end/ask_categories_controller.rb b/app/controllers/panel/ask/back_end/ask_categories_controller.rb
new file mode 100644
index 0000000..2ee4b6a
--- /dev/null
+++ b/app/controllers/panel/ask/back_end/ask_categories_controller.rb
@@ -0,0 +1,57 @@
+class Panel::Ask::BackEnd::AskCategoriesController < OrbitBackendController
+
+ include AdminHelper
+ include OrbitControllerLib::DivisionForDisable
+
+ before_filter :for_app_manager
+
+ def initialize
+ super
+ @app_title = 'ask_categories'
+ end
+
+ def index
+ @ask_categories = AskCategory.admin_manager_all
+ @ask_category = AskCategory.new
+ @url = panel_ask_back_end_ask_categories_path
+ end
+
+ def create
+ @ask_category = AskCategory.new(params[:ask_category])
+ @ask_category.save!
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def edit
+ @ask_category = AskCategory.find(params[:id])
+ @url = panel_ask_back_end_ask_category_path(@ask_category)
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def update
+ @ask_category = AskCategory.find(params[:id])
+ @url = panel_ask_back_end_ask_category_path(@ask_category)
+ @ask_category.update_attributes(params[:ask_category])
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def destroy
+ @ask_category = AskCategory.find(params[:id])
+ @ask_category.disable = !@ask_category.disable
+ @ask_category.save!
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
+end
diff --git a/app/controllers/panel/ask/back_end/ask_questions_controller.rb b/app/controllers/panel/ask/back_end/ask_questions_controller.rb
new file mode 100644
index 0000000..cf8180c
--- /dev/null
+++ b/app/controllers/panel/ask/back_end/ask_questions_controller.rb
@@ -0,0 +1,85 @@
+require 'csv'
+
+class Panel::Ask::BackEnd::AskQuestionsController < OrbitBackendController
+
+ def initialize
+ super
+ @app_title = 'ask_questions'
+ end
+
+ def index
+ @ask_questions = AskQuestion.all
+
+ respond_to do |format|
+ format.html
+ format.js
+ end
+ end
+
+ def edit
+ @ask_question = AskQuestion.find(params[:id])
+ @ask_reply = @ask_question.ask_reply
+ if @ask_reply
+ @url = panel_ask_back_end_ask_question_ask_reply_path(@ask_question, @ask_question.ask_reply)
+ @method = 'put'
+ else
+ @ask_reply = AskReply.new
+ @url = panel_ask_back_end_ask_question_ask_replies_path(@ask_question)
+ @method = 'post'
+ end
+ end
+
+ def destroy
+ @ask_question = AskQuestion.find(params[:id])
+ @ask_question.destroy
+
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def delete
+ if params[:ids]
+ ask_questions = AskQuestion.any_in(:_id => params[:ids]).destroy_all
+ end
+ redirect_to panel_ask_back_end_ask_questions_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
+ end
+
+ def export
+
+ end
+
+ def do_export
+ Rails.application.config.mongoid.use_activesupport_time_zone = true
+ date_start = "#{params[:export]['start(1i)']}-#{params[:export]['start(2i)']}-#{params[:export]['start(3i)']}"
+ date_end = "#{params[:export]['end(1i)']}-#{params[:export]['end(2i)']}-#{params[:export]['end(3i)']}"
+ @ask_questions = AskQuestion.includes(:ask_category).includes(:ask_reply).where(:created_at.gte => date_start, :created_at.lte => date_end)
+
+ csv = CSV.generate do |csv|
+ csv << [ t('category'),
+ AskQuestion.human_attribute_name(:name),
+ AskQuestion.human_attribute_name(:identity),
+ AskQuestion.human_attribute_name(:email),
+ AskQuestion.human_attribute_name(:phone),
+ AskQuestion.human_attribute_name(:tax),
+ AskQuestion.human_attribute_name(:title),
+ AskQuestion.human_attribute_name(:content),
+ AskReply.human_attribute_name(:content),
+ AskReply.human_attribute_name(:comment)]
+ @ask_questions.each do |ask_question|
+ ask_question.ask_reply ||= AskReply.new
+ csv << [ ask_question.ask_category.name,
+ ask_question.name,
+ ask_question.identity,
+ ask_question.email,
+ ask_question.phone,
+ ask_question.tax,
+ ask_question.title,
+ ask_question.content,
+ ask_question.ask_reply.content,
+ ask_question.ask_reply.comment ]
+ end
+ end
+ send_data csv.encode('Big5'), type: 'text/csv', filename: "Questions-#{date_start}-#{date_end}.csv"
+ end
+end
diff --git a/app/controllers/panel/ask/back_end/ask_replies_controller.rb b/app/controllers/panel/ask/back_end/ask_replies_controller.rb
new file mode 100644
index 0000000..86219b7
--- /dev/null
+++ b/app/controllers/panel/ask/back_end/ask_replies_controller.rb
@@ -0,0 +1,31 @@
+class Panel::Ask::BackEnd::AskRepliesController < OrbitBackendController
+
+ include AdminHelper
+ include OrbitControllerLib::DivisionForDisable
+
+ before_filter :for_app_manager
+
+ def initialize
+ super
+ @app_title = 'ask_replies'
+ end
+
+ def create
+ @ask_question = AskQuestion.find(params[:ask_question_id])
+ @ask_question.ask_reply = AskReply.new(params[:ask_reply])
+ @ask_question.save
+ if @ask_question.ask_reply.send_email?
+ Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id)
+ end
+ redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success')
+ end
+
+ def update
+ @ask_reply = AskReply.find(params[:id])
+ @ask_reply.update_attributes(params[:ask_reply])
+ if @ask_reply.send_email?
+ Resque.enqueue(SendAskReplyMail, @ask_reply.ask_question.id)
+ end
+ redirect_to panel_ask_back_end_ask_questions_path, notice: t('ask.reply_success')
+ end
+end
diff --git a/app/controllers/panel/ask/front_end/ask_questions_controller.rb b/app/controllers/panel/ask/front_end/ask_questions_controller.rb
new file mode 100644
index 0000000..3c94542
--- /dev/null
+++ b/app/controllers/panel/ask/front_end/ask_questions_controller.rb
@@ -0,0 +1,52 @@
+class Panel::Ask::FrontEnd::AskQuestionsController < OrbitWidgetController
+
+ layout false
+
+ def initialize
+ super
+ @app_title = 'ask'
+ end
+
+ def index
+ @ask_question = AskQuestion.new
+ @categories = @module_app.categories.enabled
+ end
+
+ def create
+ @ask_question = AskQuestion.new(params[:ask_question])
+ if gotcha_valid? && @ask_question.save
+ @acknowledgement = AskAcknowledgement.last
+ @ask_acknowledgement = AskAcknowledgement.first || AskAcknowlegement.new
+
+ AskAdmin.all.each do |ask_admin|
+ AskMailer.notice(ask_admin, @ask_question).deliver
+ Resque.enqueue(SendAskNoticeMail, ask_admin.id, @ask_question.id)
+ end
+
+ # Render to create.js.erb
+ respond_to do |format|
+ format.js
+ end
+ else
+ # Render to index.js.erb
+ respond_to do |format|
+ format.js { render :index }
+ end
+ end
+ end
+
+
+ def thank_you
+ @acknowledgement = AskAcknowledgement.last
+ @item = Page.find(params[:page_id]) rescue nil
+ if @item
+ if @item.frontend_data_count
+ @page_num = @item.frontend_data_count
+ else
+ @page_num = 15
+ end
+ @frontend_style = @item.frontend_style
+ end
+ @item = Page.find(params[:page_id]) rescue nil
+ end
+end
diff --git a/app/mailers/ask_mailer.rb b/app/mailers/ask_mailer.rb
new file mode 100644
index 0000000..daa121b
--- /dev/null
+++ b/app/mailers/ask_mailer.rb
@@ -0,0 +1,14 @@
+class AskMailer < ActionMailer::Base
+ default from: 'orbit_test@rulingcom.com'
+
+ def reply(ask_question)
+ @ask_question = ask_question
+ mail(:to => @ask_question.email, :subject => "#{t('ask.reply')}:#{@ask_question.title}")
+ end
+
+ def notice(ask_admin, ask_question)
+ @ask_admin = ask_admin
+ @ask_question = ask_question
+ mail(:to => @ask_admin.email, :subject => "#{t('ask.new_question')}:#{@ask_question.title}")
+ end
+end
diff --git a/app/models/ask_acknowledgement.rb b/app/models/ask_acknowledgement.rb
new file mode 100644
index 0000000..6ba7f7b
--- /dev/null
+++ b/app/models/ask_acknowledgement.rb
@@ -0,0 +1,6 @@
+class AskAcknowledgement
+ include Mongoid::Document
+ include Mongoid::Timestamps
+
+ field :content, type: String
+end
diff --git a/app/models/ask_admin.rb b/app/models/ask_admin.rb
new file mode 100644
index 0000000..3d2b6fc
--- /dev/null
+++ b/app/models/ask_admin.rb
@@ -0,0 +1,6 @@
+class AskAdmin
+ include Mongoid::Document
+ include Mongoid::Timestamps
+
+ field :email, type: String
+end
diff --git a/app/models/ask_category.rb b/app/models/ask_category.rb
new file mode 100644
index 0000000..079afbf
--- /dev/null
+++ b/app/models/ask_category.rb
@@ -0,0 +1,10 @@
+class AskCategory
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include OrbitCoreLib::ObjectDisable
+
+ field :name, localize: true
+ field :key
+
+ has_many :ask_questions
+end
diff --git a/app/models/ask_question.rb b/app/models/ask_question.rb
new file mode 100644
index 0000000..28ab66a
--- /dev/null
+++ b/app/models/ask_question.rb
@@ -0,0 +1,24 @@
+class AskQuestion
+ include Mongoid::Document
+ include ActiveModel::Validations
+ include ActiveModel::Conversion
+ extend ActiveModel::Naming
+
+ include OrbitCategory::Categorizable
+ include OrbitModel::Approval
+ include Mongoid::Document
+ include Mongoid::Timestamps
+
+ field :name, type: String
+ field :identity, type: String
+ field :email, type: String
+ field :phone, type: String
+ field :tax, type: String
+ field :title, type: String
+ field :content, type: String
+
+ validates_presence_of :name, :identity, :email, :title, :content
+
+ has_one :ask_reply, dependent: :destroy
+
+end
diff --git a/app/models/ask_reply.rb b/app/models/ask_reply.rb
new file mode 100644
index 0000000..54112aa
--- /dev/null
+++ b/app/models/ask_reply.rb
@@ -0,0 +1,11 @@
+class AskReply
+ include Mongoid::Document
+ include Mongoid::Timestamps
+
+ field :content, type: String
+ field :comment, type: String
+ field :status, type: String
+ field :send_email, type: Boolean, detault: false
+
+ belongs_to :ask_question
+end
diff --git a/app/views/ask_mailer/notice.html.erb b/app/views/ask_mailer/notice.html.erb
new file mode 100644
index 0000000..7841989
--- /dev/null
+++ b/app/views/ask_mailer/notice.html.erb
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+ <%= @ask_question.title %>
+
+
+ <%= AskQuestion.human_attribute_name(:name) %>: |
+ <%= @ask_question.name %> |
+
+
+ <%= AskQuestion.human_attribute_name(:identity) %>: |
+ <%= @ask_question.identity %> |
+
+
+ <%= AskQuestion.human_attribute_name(:email) %>: |
+ <%= @ask_question.email %> |
+
+
+ <%= AskQuestion.human_attribute_name(:phone) %>: |
+ <%= @ask_question.phone %> |
+
+
+ <%= AskQuestion.human_attribute_name(:tax) %>: |
+ <%= @ask_question.tax %> |
+
+
+ <%= AskQuestion.human_attribute_name(:content) %>: |
+ <%= @ask_question.content %> |
+
+
+ 此為系統自動發信,請勿直接回覆
+
+
diff --git a/app/views/ask_mailer/reply.html.erb b/app/views/ask_mailer/reply.html.erb
new file mode 100644
index 0000000..cfe6796
--- /dev/null
+++ b/app/views/ask_mailer/reply.html.erb
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+ <%= @ask_question.content %>
+
+ 此為系統自動發信,請勿直接回覆
+
+
diff --git a/app/views/panel/ask/back_end/ask_acknowledgements/index.html.erb b/app/views/panel/ask/back_end/ask_acknowledgements/index.html.erb
new file mode 100644
index 0000000..e1583b3
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_acknowledgements/index.html.erb
@@ -0,0 +1,14 @@
+
+ <%= form_for @ask_acknowledgement, url: @url, html: { class: 'form-horizontal' } do |f| %>
+
+ <%= f.label :content, t('ask.acknowledgement'), class: 'control-label' %>
+
+ <%= f.text_area :content, rows: 10 %>
+
+
+
+ <%= f.submit t('submit'), class: 'btn btn-primary' %>
+ <%= f.button t('cancel'), type: 'reset', class: 'btn' %>
+
+ <% end %>
+
diff --git a/app/views/panel/ask/back_end/ask_admins/_ask_admin.html.erb b/app/views/panel/ask/back_end/ask_admins/_ask_admin.html.erb
new file mode 100644
index 0000000..a0afbe7
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_admins/_ask_admin.html.erb
@@ -0,0 +1,13 @@
+
+
+ <%= ask_admin.email %>
+ <%if at_least_module_manager %>
+
+
+ - <%= link_to t(:edit), edit_panel_ask_back_end_ask_admin_path(ask_admin), :remote => true %>
+ - <%= link_to t(:delete), panel_ask_back_end_ask_admin_path(ask_admin), :confirm => t(:sure?), :method => :delete, :remote => true ,:class=> "archive_toggle"%>
+
+
+ <% end -%>
+ |
+
diff --git a/app/views/panel/ask/back_end/ask_admins/_form.html.erb b/app/views/panel/ask/back_end/ask_admins/_form.html.erb
new file mode 100644
index 0000000..c2cea3f
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_admins/_form.html.erb
@@ -0,0 +1,19 @@
+<%= form_for(@ask_admin, :remote => true, :url => @url) do |f| %>
+
+ <%= @ask_admin.new_record? ? t(:add) : t(:edit) %>
+
+
+
+
+ <%= f.submit t(:submit), class: 'btn btn-primary' %>
+
+
+<% end %>
+
diff --git a/app/views/panel/ask/back_end/ask_admins/create.js.erb b/app/views/panel/ask/back_end/ask_admins/create.js.erb
new file mode 100644
index 0000000..ff74c73
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_admins/create.js.erb
@@ -0,0 +1,2 @@
+$('<%= j render :partial => 'ask_admin', :collection => [@ask_admin] %>').appendTo('#ask-admins').hide().fadeIn();
+$("#new_ask_admin")[0].reset();
diff --git a/app/views/panel/ask/back_end/ask_admins/destroy.js.erb b/app/views/panel/ask/back_end/ask_admins/destroy.js.erb
new file mode 100644
index 0000000..338cc2f
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_admins/destroy.js.erb
@@ -0,0 +1 @@
+$("#<%= dom_id @ask_admin %>").fadeOut();
diff --git a/app/views/panel/ask/back_end/ask_admins/edit.js.erb b/app/views/panel/ask/back_end/ask_admins/edit.js.erb
new file mode 100644
index 0000000..40061b9
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_admins/edit.js.erb
@@ -0,0 +1 @@
+$("#form > form").replaceWith("<%= j render "form" %>");
diff --git a/app/views/panel/ask/back_end/ask_admins/index.html.erb b/app/views/panel/ask/back_end/ask_admins/index.html.erb
new file mode 100644
index 0000000..c73aaea
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_admins/index.html.erb
@@ -0,0 +1,23 @@
+<%= flash_messages %>
+
+
+
+
+ <%= render :partial => 'ask_admin', :collection => @ask_admins %>
+
+
+
+<%= render :partial => "form" if at_least_module_manager%>
+
diff --git a/app/views/panel/ask/back_end/ask_admins/update.js.erb b/app/views/panel/ask/back_end/ask_admins/update.js.erb
new file mode 100644
index 0000000..83abbfa
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_admins/update.js.erb
@@ -0,0 +1,4 @@
+$("#<%= dom_id @ask_admin %>").replaceWith("<%= j render :partial => 'ask_admin', :collection => [@ask_admin] %>");
+<% @ask_admin = AskAdmin.new(:display => 'List') # reset for new form %>
+$(".edit_ask_admin").replaceWith("<%= j render "form" %>")
+$(".new_ask_admin")[0].reset();
diff --git a/app/views/panel/ask/back_end/ask_categories/_ask_category.html.erb b/app/views/panel/ask/back_end/ask_categories/_ask_category.html.erb
new file mode 100644
index 0000000..fd39498
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_categories/_ask_category.html.erb
@@ -0,0 +1,17 @@
+
+
+ <%= ask_category.key %>
+ <%if at_least_module_manager %>
+
+
+ - <%= link_to t(:edit), edit_panel_ask_back_end_ask_category_path(ask_category), :remote => true %>
+ - <%= link_to show_toggle_archive_btn(ask_category), panel_ask_back_end_ask_category_path(ask_category), :confirm => t(:sure?), :method => :delete, :remote => true ,:class=> "archive_toggle"%>
+ - <%#= show_ask_permission_link ask_category %>
+
+
+ <% end -%>
+ |
+ <% @site_in_use_locales.each do |locale| %>
+ <%= ask_category.name_translations[locale] rescue nil %> |
+ <% end %>
+
diff --git a/app/views/panel/ask/back_end/ask_categories/_form.html.erb b/app/views/panel/ask/back_end/ask_categories/_form.html.erb
new file mode 100644
index 0000000..ed9f759
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_categories/_form.html.erb
@@ -0,0 +1,28 @@
+<%= form_for(@ask_category, :remote => true, :url => @url) do |f| %>
+
+ <%= (@ask_category.new_record? ? t(:add) : t(:edit)) %>
+
+
+ <%= f.label :key, t(:key) %>
+ <%= f.text_field :key %>
+
+
+
+
+
+ <%= f.submit t(:submit), :class=>'btn btn-primary' %>
+
+
+<% end %>
+
diff --git a/app/views/panel/ask/back_end/ask_categories/create.js.erb b/app/views/panel/ask/back_end/ask_categories/create.js.erb
new file mode 100644
index 0000000..a60c2c0
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_categories/create.js.erb
@@ -0,0 +1,2 @@
+$('<%= j render :partial => 'ask_category', :collection => [@ask_category] %>').appendTo('#ask_categories').hide().fadeIn();
+$("#new_ask_category")[0].reset();
diff --git a/app/views/panel/ask/back_end/ask_categories/destroy.js.erb b/app/views/panel/ask/back_end/ask_categories/destroy.js.erb
new file mode 100644
index 0000000..7e07c1a
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_categories/destroy.js.erb
@@ -0,0 +1 @@
+$("#<%= dom_id @ask_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@ask_category) %> ");
diff --git a/app/views/panel/ask/back_end/ask_categories/edit.js.erb b/app/views/panel/ask/back_end/ask_categories/edit.js.erb
new file mode 100644
index 0000000..40061b9
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_categories/edit.js.erb
@@ -0,0 +1 @@
+$("#form > form").replaceWith("<%= j render "form" %>");
diff --git a/app/views/panel/ask/back_end/ask_categories/index.html.erb b/app/views/panel/ask/back_end/ask_categories/index.html.erb
new file mode 100644
index 0000000..1050218
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_categories/index.html.erb
@@ -0,0 +1,34 @@
+<%= flash_messages %>
+
+
+
+
+
+ |
+ <% @site_in_use_locales.each do |locale| %>
+ |
+ <% end %>
+
+
+
+ <%= render :partial => 'ask_category', :collection => @ask_categories %>
+
+
+
+<%= render :partial => "form" if at_least_module_manager%>
+
diff --git a/app/views/panel/ask/back_end/ask_categories/update.js.erb b/app/views/panel/ask/back_end/ask_categories/update.js.erb
new file mode 100644
index 0000000..b0c5036
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_categories/update.js.erb
@@ -0,0 +1,4 @@
+$("#<%= dom_id @ask_category %>").replaceWith("<%= j render :partial => 'ask_category', :collection => [@ask_category] %>");
+<% @ask_category = QaCategory.new(:display => 'List') # reset for new form %>
+$(".edit_ask_category").replaceWith("<%= j render "form" %>")
+$(".new_ask_category")[0].reset();
diff --git a/app/views/panel/ask/back_end/ask_questions/_ask_question.html.erb b/app/views/panel/ask/back_end/ask_questions/_ask_question.html.erb
new file mode 100644
index 0000000..6a13dac
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_questions/_ask_question.html.erb
@@ -0,0 +1,27 @@
+
+
+ <%= check_box_tag 'to_delete[]', ask_question.id, false, :class => "checkbox_in_list" %>
+ |
+
+ <%= ask_question.ask_reply ? ask_question.ask_reply.status : t('ask.pending') %>
+ |
+
+
+ <%= ask_question.title %>
+
+
+ <%if at_least_module_manager || ask_question.ask_category.cur_user_is_sub_manager_of(:edit)%>
+ - <%= link_to t('edit'), edit_panel_ask_back_end_ask_question_path(ask_question, :page => params[:page]) %>
+ - <%= link_to t(:delete_), panel_ask_back_end_ask_question_path(ask_question), :confirm => t('sure?'), :method => :delete, :remote => true %>
+ <% end -%>
+
+
+ |
+
+ <%= ask_question.name %>
+ |
+
+ <%= ask_question.created_at.strftime "%Y-%m-%d %H:%M:%S" %>
+ |
+
+
diff --git a/app/views/panel/ask/back_end/ask_questions/_filter.html.erb b/app/views/panel/ask/back_end/ask_questions/_filter.html.erb
new file mode 100644
index 0000000..54df3c1
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_questions/_filter.html.erb
@@ -0,0 +1,11 @@
+
+
+<% content_for :page_specific_javascript do %>
+ <%= javascript_include_tag 'sort_header' %>
+<% end %>
diff --git a/app/views/panel/ask/back_end/ask_questions/_sort_headers.html.erb b/app/views/panel/ask/back_end/ask_questions/_sort_headers.html.erb
new file mode 100644
index 0000000..e69de29
diff --git a/app/views/panel/ask/back_end/ask_questions/destroy.js.erb b/app/views/panel/ask/back_end/ask_questions/destroy.js.erb
new file mode 100644
index 0000000..ad5be1c
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_questions/destroy.js.erb
@@ -0,0 +1 @@
+$("#<%= dom_id @ask_question %>").remove();
diff --git a/app/views/panel/ask/back_end/ask_questions/edit.html.erb b/app/views/panel/ask/back_end/ask_questions/edit.html.erb
new file mode 100644
index 0000000..7225f69
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_questions/edit.html.erb
@@ -0,0 +1,55 @@
+
+ <%= form_for @ask_reply, url: @url, method: @method do |f| %>
+
+
+ <%= AskQuestion.human_attribute_name(:name) %>:<%= @ask_question.name %> |
+ <%= AskQuestion.human_attribute_name(:identity) %>:<%= @ask_question.identity %> |
+ <%= AskQuestion.human_attribute_name(:email) %>:<%= @ask_question.email %> |
+ <%= AskQuestion.human_attribute_name(:phone) %>:<%= @ask_question.phone %> |
+ <%= AskQuestion.human_attribute_name(:tax) %>:<%= @ask_question.tax %> |
+
+
+ <%= AskQuestion.human_attribute_name(:title) %>:<%= @ask_question.title %> |
+
+
+ <%= AskQuestion.human_attribute_name(:content) %>: <%= @ask_question.content %> |
+
+
+
+ <%= f.label :content %>
+ <%= f.text_area :content, rows: 10, style: 'width: 500px' %>
+ |
+
+
+
+ <%= f.label :comment %>
+ <%= f.text_field :comment, style: 'width: 500px' %> |
+
+
+ <%= f.label :status %> <%= f.select :status, [
+ ['待處理', '待處理'],
+ ['已處理', '已處理'],
+ ['轉介其他單位', '轉介其他單位']
+ ] %> |
+
+
+
+ <%= f.label :send_email %><%= f.radio_button :send_email, 1, checked: @ask_reply.send_email? %><%= t('ask.yes') %>
+
+
+
+
+ <%= f.radio_button :send_email, 0, checked: !@ask_reply.send_email? %><%= t('ask.no') %>
+ |
+
+
+
+
+ <%= f.submit t('submit'), class: 'btn btn-primary' %>
+ <%= f.button t('cancel'), type: 'reset', class: 'btn' %>
+
+ |
+
+
+ <% end %>
+
diff --git a/app/views/panel/ask/back_end/ask_questions/export.html.erb b/app/views/panel/ask/back_end/ask_questions/export.html.erb
new file mode 100644
index 0000000..d5f28ed
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_questions/export.html.erb
@@ -0,0 +1,21 @@
+
+ <%= form_tag export_panel_ask_back_end_ask_questions_path, method: 'post' do |f| %>
+
+
+ <%= t('date_') %> |
+ <%= date_select 'export', :start %> <%= t('ask.to') %> |
+
+
+ |
+ <%= date_select 'export', :end %> |
+
+
+
+
+ <%= submit_tag t('submit'), class: 'btn btn-primary' %>
+
+ |
+
+
+ <% end %>
+
diff --git a/app/views/panel/ask/back_end/ask_questions/index.html.erb b/app/views/panel/ask/back_end/ask_questions/index.html.erb
new file mode 100644
index 0000000..66212b2
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_questions/index.html.erb
@@ -0,0 +1,19 @@
+
+
+
+ |
+ <%= t('ask.status') %> |
+ <%= t('ask.question') %> |
+ <%= t('ask.sender') %> |
+ <%= t('ask.created_at') %> |
+
+
+
+ <%= render :partial => 'ask_question', :collection => @ask_questions %>
+
+
+
+
diff --git a/app/views/panel/ask/back_end/ask_questions/index.js.erb b/app/views/panel/ask/back_end/ask_questions/index.js.erb
new file mode 100644
index 0000000..85a93de
--- /dev/null
+++ b/app/views/panel/ask/back_end/ask_questions/index.js.erb
@@ -0,0 +1,4 @@
+$("#delete_all").attr("action", "<%= delete_panel_ask_back_end_ask_questions_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]) %>");
+$("#sort_headers").html("<%= j render 'sort_headers' %>");
+$("#tbody_surveys").html("<%= j render :partial => 'ask_question', :collection => @ask_questions %>");
+$("#ask_questions_pagination").html("<%= j paginate @ask_questions %>");
diff --git a/app/views/panel/ask/front_end/ask_questions/create.js.erb b/app/views/panel/ask/front_end/ask_questions/create.js.erb
new file mode 100644
index 0000000..b9e03a5
--- /dev/null
+++ b/app/views/panel/ask/front_end/ask_questions/create.js.erb
@@ -0,0 +1 @@
+window.location.href= "<%= panel_ask_front_end_thank_you_path %>"
diff --git a/app/views/panel/ask/front_end/ask_questions/index.html.erb b/app/views/panel/ask/front_end/ask_questions/index.html.erb
new file mode 100644
index 0000000..30ea643
--- /dev/null
+++ b/app/views/panel/ask/front_end/ask_questions/index.html.erb
@@ -0,0 +1,118 @@
+
+
+
+
+
+ Sending Mail <%= image_tag 'loading.gif', :id => "img-spinner"%>
+
+
+
+ <%= form_for @ask_question, url: panel_ask_front_end_ask_questions_path(standalone: true), html: {class: 'form-horizontal'} do |f| %>
+
+ <%= f.label :ask_category_id, class: 'control-label required' %>
+
+ <%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %>
+
+
+
+ <%= f.label :name, class: 'control-label required' %>
+
+ <%= f.text_field :name %>
+
+
+
+ <%= f.label :identity, class: 'control-label required' %>
+
+ <%= f.select :identity, options_for_select( [t('ask.teacher'),
+ t('ask.stuff'),
+ t('ask.student'),
+ t('ask.schoolfellow'),
+ t('ask.others')].map{|i| [i, i]} ) %>
+
+
+
+ <%= f.label :email, class: 'control-label required' %>
+
+ <%= f.text_field :email %>
+
+
+
+ <%= f.label :phone, class: 'control-label' %>
+
+ <%= f.text_field :phone %>
+
+
+
+ <%= f.label :tax, class: 'control-label' %>
+
+ <%= f.text_field :tax %>
+
+
+
+ <%= f.label :title, class: 'control-label required' %>
+
+ <%= f.text_field :title %>
+
+
+
+ <%= f.label :content, class: 'control-label required' %>
+
+ <%= f.text_area :content, rows: 8, class: 'input-xlarge' %>
+
+
+
+
+ <%= gotcha_error %>
+ <%= gotcha%>
+
+
+
+
+ <%= f.submit t('submit'), class: 'btn btn-primary', :id => 'button-mail' %>
+ <%= f.button t('cancel'), type: 'reset', class: 'btn' %>
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/panel/ask/front_end/ask_questions/index.js.erb b/app/views/panel/ask/front_end/ask_questions/index.js.erb
new file mode 100644
index 0000000..bc272ab
--- /dev/null
+++ b/app/views/panel/ask/front_end/ask_questions/index.js.erb
@@ -0,0 +1 @@
+window.location.href = "<%= panel_ask_front_end_sorry_path %>";
\ No newline at end of file
diff --git a/app/views/panel/ask/front_end/ask_questions/sorry.html.erb b/app/views/panel/ask/front_end/ask_questions/sorry.html.erb
new file mode 100644
index 0000000..674de72
--- /dev/null
+++ b/app/views/panel/ask/front_end/ask_questions/sorry.html.erb
@@ -0,0 +1 @@
+<%= t(:ask_fail, :scope => :ask) %> !
\ No newline at end of file
diff --git a/app/views/panel/ask/front_end/ask_questions/thank_you.html.erb b/app/views/panel/ask/front_end/ask_questions/thank_you.html.erb
new file mode 100644
index 0000000..cdcae0b
--- /dev/null
+++ b/app/views/panel/ask/front_end/ask_questions/thank_you.html.erb
@@ -0,0 +1 @@
+<%= @acknowledgement.content.html_safe%>
\ No newline at end of file
diff --git a/ask.gemspec b/ask.gemspec
new file mode 100644
index 0000000..4cb05a3
--- /dev/null
+++ b/ask.gemspec
@@ -0,0 +1,22 @@
+$:.push File.expand_path("../lib", __FILE__)
+
+# Maintain your gem's version:
+require "ask/version"
+
+# Describe your gem and declare its dependencies:
+Gem::Specification.new do |s|
+ s.name = "ask"
+ s.version = Ask::VERSION
+ s.authors = ["RulingDigital"]
+ s.email = ["service@rulingcom.com"]
+ s.homepage = "http://www.rulingcom.com"
+ s.summary = ""
+ s.description = "Orbit Ask module"
+
+ s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
+ s.test_files = Dir["test/**/*"]
+
+ # s.add_dependency "rails", "~> 3.2.16"
+
+ s.add_development_dependency "sqlite3"
+end
diff --git a/ask.json b/ask.json
new file mode 100644
index 0000000..4c97d7b
--- /dev/null
+++ b/ask.json
@@ -0,0 +1,12 @@
+{
+ "title": "ask",
+ "version": "0.1",
+ "organization": "Rulingcom",
+ "author": "RD dep",
+ "intro": "ask",
+ "update_info": "Some info",
+ "create_date": "05-23-2013",
+ "widgets": ["index"],
+ "category": ["gallery_categories"],
+ "enable_frontend": true
+}
diff --git a/config/locales/en.yml b/config/locales/en.yml
new file mode 100644
index 0000000..a4aeaca
--- /dev/null
+++ b/config/locales/en.yml
@@ -0,0 +1,24 @@
+en:
+ ask:
+ ask: Ask
+ export: Export
+ reply: Reply
+ reply_success: Reply success
+ to: To
+ widget:
+ index: Form
+ save_success: Successfully saved
+ teacher: Teacher
+ stuff: Stuff
+ student: Student
+ schoolfellow: Schoolfellow
+ others: Others
+ acknowledgement: Acknowledgement
+ admin: Administrator
+ new_question: New question
+ pending: Pending
+ mongoid:
+ attributes:
+ ask_question:
+ ask_category_id: Ask Category
+
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
new file mode 100644
index 0000000..0b8109b
--- /dev/null
+++ b/config/locales/zh_tw.yml
@@ -0,0 +1,42 @@
+zh_tw:
+ recaptcha:
+ errors:
+ verification_failed: 驗證碼錯誤
+ ask:
+ ask: 發問
+ export: 匯出
+ reply: 回覆
+ reply_success: 回覆成功
+ to: 至
+ yes: 是
+ no: 否
+ widget:
+ index: 表單
+ save_success: 儲存成功
+ teacher: 教師
+ stuff: 職員
+ student: 學生
+ schoolfellow: 校友
+ others: 其他
+ acknowledgement: 感謝詞
+ admin: 管理者
+ new_question: 新的發問
+ pending: 待處理
+ mongoid:
+ attributes:
+ ask_question:
+ ask_category_id: 諮詢類別
+ name: 姓名
+ identity: 身份
+ email: Email
+ phone: 聯絡電話
+ tax: 傳真
+ title: 主旨
+ content: 內容
+ created_at: 日期
+ ask_reply:
+ content: 回覆
+ comment: 備註
+ status: 狀態
+ send_email: 是否回信
+
diff --git a/config/routes.rb b/config/routes.rb
new file mode 100644
index 0000000..df2ffe9
--- /dev/null
+++ b/config/routes.rb
@@ -0,0 +1,29 @@
+Rails.application.routes.draw do
+
+ namespace :panel do
+ namespace :ask do
+ namespace :back_end do
+ resources :ask_questions do
+ collection do
+ get 'delete'
+ get 'export'
+ post 'export', to: 'ask_questions#do_export'
+ end
+ resources :ask_replies
+ end
+
+ resources :ask_categories
+ resources :ask_acknowledgements
+ resources :ask_admins
+ end
+
+ namespace :front_end do
+ match "ask_questions/thank_you" => "ask_questions#thank_you", :as => 'thank_you'
+ match "ask_questions/sorry" => "ask_questions#sorry", :as => 'sorry'
+ resources :ask_questions
+ end
+
+ end
+ end
+
+end
diff --git a/lib/ask.rb b/lib/ask.rb
new file mode 100644
index 0000000..d8d391f
--- /dev/null
+++ b/lib/ask.rb
@@ -0,0 +1,63 @@
+module Ask
+ class Engine < Rails::Engine
+ initializer "ask" do
+ OrbitApp.registration "Ask",:type=> 'ModuleApp' do
+ module_label 'ask.ask'
+ base_url File.expand_path File.dirname(__FILE__)
+ # personal_plugin :enable => true,:path=>"panel/faq/plugin/profile",:i18n=>'admin.faq'
+
+ version "0.1"
+ organization "Rulingcom"
+ author "RD dep"
+ intro "I am intro"
+ update_info 'some update_info'
+
+ front_end do
+ app_page 'ask_questions' do
+ frontend_i18n 'ask.ask'
+ end
+ app_page 'thank_you' do
+ frontend_i18n "ask.thank_you"
+ end
+ end
+
+ widgets do
+ default_widget do
+ end
+ categories_query 'Category.all'
+ end
+
+ authorizable
+ approvable
+ categorizable
+
+ side_bar do
+ head_label_i18n 'ask.ask', icon_class: 'icons-light-bulb'
+ available_for [:admin,:manager,:sub_manager]
+ active_for_controllers ({:private=>['ask_questions', 'ask_admins', 'ask_ackowledgements']})
+ active_for_controllers({ private: ['ask_questions'] })
+ head_link_path "panel_ask_back_end_ask_questions_path"
+
+ context_link 'announcement.categories',
+ :link_path=>"admin_module_app_categories_path(get_module_app)" ,
+ :priority=>3,
+ :active_for_category => 'Ask',
+ :available_for => [:admin]
+
+ context_link 'ask.acknowledgement', link_path: 'panel_ask_back_end_ask_acknowledgements_path',
+ priority: 1,
+ available_for: [:all]
+
+ context_link 'ask.admin', link_path: 'panel_ask_back_end_ask_admins_path',
+ priority: 1,
+ available_for: [:all]
+
+ context_link 'ask.export', link_path: 'export_panel_ask_back_end_ask_questions_path',
+ priority: 1,
+ available_for: [:all]
+ end
+
+ end
+ end
+ end
+end
diff --git a/lib/ask/version.rb b/lib/ask/version.rb
new file mode 100644
index 0000000..a87c4ad
--- /dev/null
+++ b/lib/ask/version.rb
@@ -0,0 +1,3 @@
+module Ask
+ VERSION = "0.0.1"
+end
diff --git a/lib/tasks/ask_tasks.rake b/lib/tasks/ask_tasks.rake
new file mode 100644
index 0000000..441822c
--- /dev/null
+++ b/lib/tasks/ask_tasks.rake
@@ -0,0 +1,4 @@
+# desc "Explaining what the task does"
+# task :ask do
+# # Task goes here
+# end