diff --git a/app/controllers/admin/client_managements_controller.rb b/app/controllers/admin/client_managements_controller.rb index 73b0e7d..4327c90 100644 --- a/app/controllers/admin/client_managements_controller.rb +++ b/app/controllers/admin/client_managements_controller.rb @@ -8,5 +8,22 @@ class Admin::ClientManagementsController < OrbitAdminController @site_request = SiteRequest.find(params[:id]) @user = @site_request.c_panel_user end + + def make_contract + @site_request = SiteRequest.find(params[:id]) + @user = @site_request.c_panel_user + @new_contract = RequestContract.new + end + + def create_contract + RequestContract.create(contract_params) + redirect_to admin_client_managements_path + end + + private + + def contract_params + params.require(:request_contract).permit! + end end \ No newline at end of file diff --git a/app/models/request_contract.rb b/app/models/request_contract.rb index 1ff9ec8..f6a1405 100644 --- a/app/models/request_contract.rb +++ b/app/models/request_contract.rb @@ -2,5 +2,14 @@ class RequestContract include Mongoid::Document include Mongoid::Timestamps + field :new_site_cost, type: Integer, :default => 0 + field :hosting_with_rulingdigital_cost, type: Integer, :default => 0 + field :service_cost, type: Integer, :default => 0 + field :option_module_cost, type: Integer, :default => 0 + field :customized_module_cost, type: Integer, :default => 0 + field :template_cost, type: Integer, :default => 0 + field :customized_template_cost, type: Integer, :default => 0 + field :rwd_cost, type: Integer, :default => 0 + has_one :site_request end \ No newline at end of file diff --git a/app/views/admin/client_managements/_site_spec.html.erb b/app/views/admin/client_managements/_site_spec.html.erb index 03ef524..345bd31 100644 --- a/app/views/admin/client_managements/_site_spec.html.erb +++ b/app/views/admin/client_managements/_site_spec.html.erb @@ -66,4 +66,4 @@ RWD : Yes -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/admin/client_managements/_site_spec_form.html.erb b/app/views/admin/client_managements/_site_spec_form.html.erb new file mode 100644 index 0000000..4ebc67d --- /dev/null +++ b/app/views/admin/client_managements/_site_spec_form.html.erb @@ -0,0 +1,98 @@ +<% if @site_request.type == "existing" %> +
+ +
+ <%= @site_request.get_site.title %> +
+
+
+ +
+ <%= @site_request.get_site.site_domain %> +
+
+<% else %> +
+ <%= f.label :new_site_cost, "New Site Cost:", :class => "control-label" %> +
+ <%= f.number_field :new_site_cost, :min => "0" %> +
+
+ <% if @site_request.host_with_rulingdigital %> +
+ <%= f.label :hosting_with_rulingdigital_cost, "Host with RulingDigital:", :class => "control-label" %> +
+ <%= f.number_field :hosting_with_rulingdigital_cost, :min => "0" %> +
+
+ <% end %> +<% end %> +
+ <%= f.label :service_cost, "Maintainance Cost:", :class => "control-label" %> +
+ <%= f.number_field :service_cost, :min => "0" %> +
+
+<% if !@site_request.optional_modules.blank? %> +
+ <%= f.label :option_module_cost, "Optional Modules Cost:", :class => "control-label" %> + <% rsm = RegisteredModule.find(@site_request.optional_modules) %> +
+ + <%= f.number_field :option_module_cost, :min => "0" %> +
+
+<% end %> +<% if @site_request.custom_module %> +
+ <%= f.label :customized_module_cost, "Optional Module Cost:", :class => "control-label" %> +
+ <%= f.number_field :customized_module_cost, :min => "0" %> +
+
+<% end %> +<% if !@site_request.template_number.empty? %> +
+ <%= f.label :template_cost, "Template Cost:", :class => "control-label" %> +
+ <%= f.number_field :template_cost, :min => "0" %> +
+
+<% end %> +<% if @site_request.custom_template %> +
+ <%= f.label :customized_template_cost, "Customized Template Cost:", :class => "control-label" %> +
+ <%= f.number_field :customized_template_cost, :min => "0" %> +
+
+<% end %> +<% if @site_request.rwd %> +
+ <%= f.label :rwd_cost, "RWD Cost:", :class => "control-label" %> +
+ <%= f.number_field :rwd_cost, :min => "0" %> +
+
+<% end %> +
+

Total Amount : 0 NTD.

+
+<%= f.hidden_field :site_request, :value => @site_request.id.to_s %> +<%= f.submit "Submit", :class => "btn btn-primary" %> + \ No newline at end of file diff --git a/app/views/admin/client_managements/index.html.erb b/app/views/admin/client_managements/index.html.erb index a143952..b10da7e 100644 --- a/app/views/admin/client_managements/index.html.erb +++ b/app/views/admin/client_managements/index.html.erb @@ -25,6 +25,9 @@ <%= request.created_at.strftime("%y-%m-%d %H:%M") %> Details + <% if request.request_contract != nil %> + Contract + <% end %> <% end %> diff --git a/app/views/admin/client_managements/make_contract.html.erb b/app/views/admin/client_managements/make_contract.html.erb new file mode 100644 index 0000000..0015034 --- /dev/null +++ b/app/views/admin/client_managements/make_contract.html.erb @@ -0,0 +1,48 @@ + +

Site Id : <%= @site_request.uid %>

+

Site type : <%= @site_request.get_site_type %>

+ + + <% if !@user.fullname.nil? %> + + + + + <% end %> + + + + + <% if !@user.phone_number.nil? %> + + + + + <% end %> + <% if !@user.address.nil? %> + + + + + <% end %> + <% if !@user.registered_site_ids.empty? %> + + + + + <% end %> +

User Details

Name :<%= @user.fullname %>
Email :<%= @site_request.c_panel_user.email %>
Phone Number :<%= @user.phone_number %>
Address :<%= @user.address %>
Registered Sites : + <% @user.registered_sites.each do |rs| %> + <%= rs.title %> + <% end %> +
+
+<%= form_for @new_contract, :url => {:action => :create_contract}, :html => {:class => "form-horizontal contract-form"} do |f| %> +

Request Specifications

+ <%= render :partial => "site_spec_form", :locals => {:f => f} %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/client_managements/show.html.erb b/app/views/admin/client_managements/show.html.erb index 1d44840..b51f489 100644 --- a/app/views/admin/client_managements/show.html.erb +++ b/app/views/admin/client_managements/show.html.erb @@ -52,4 +52,13 @@ <% when "addsites" %> <%= render :partial => "add_site_spec" %> <% end %> - \ No newline at end of file + + +<% case @site_request.type %> +<% when "newsite" %> + Make Contract +<% when "existing" %> + Make Contract +<% when "addsites" %> + <%= render :partial => "add_site_spec" %> +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 53b6a99..f1a8c2a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,12 @@ Rails.application.routes.draw do locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales scope "(:locale)", locale: Regexp.new(locales.join("|")) do namespace :admin do - resources :client_managements + resources :client_managements do + member do + get "make_contract" + post "create_contract" + end + end end scope :cpanel do