diff --git a/app/controllers/admin/venue_management_contracts_controller.rb b/app/controllers/admin/venue_management_contracts_controller.rb new file mode 100644 index 0000000..8a57e0d --- /dev/null +++ b/app/controllers/admin/venue_management_contracts_controller.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +class Admin::VenueManagementContractsController < OrbitAdminController + include Admin::VenueManagementsHelper + before_action ->(module_app = @app_title) { set_variables module_app } + before_action :set_venue_management_contract, only: [:edit, :update, :destroy] + + def initialize + super + @app_title = 'venue_management' + end + + def index + @table_fields = [ + 'venue_management.title', + 'vm_contract.case_no', + 'vm_contract.vendor', + 'vm_contract.start_end', + 'vm_contract.renewal_permission', + 'vm_contract.note', + ] + @contracts = VenueManagementContract.order(updated_at: :desc).page(params[:page]).per(10) + end + + def new + @venue_management = VenueManagementMain.find(params[:id]) + @venue_management_contract = @venue_management.venue_management_contracts.build + end + + def create + @venue_management_contract = VenueManagementContract.new(venue_management_contract_params) + inviting = VenueManagementInviting.find_by(id: venue_management_contract_params[:venue_management_inviting_id]) + assign_inviting_attrs(@venue_management_contract, inviting) + @venue_management_contract.save + + redirect_to params['referer_url'] + end + + def edit + @venue_management = VenueManagementMain.find(@venue_management_contract.venue_management_main_id) + end + + def update + inviting = VenueManagementInviting.find_by(id: venue_management_contract_params[:venue_management_inviting_id]) + assign_inviting_attrs(@venue_management_contract, inviting) + @venue_management_contract.update_attributes(venue_management_contract_params) + + redirect_to venue_management_contracts_admin_venue_management_path(@venue_management_contract.venue_management_main_id) + end + + def destroy + @venue_management_main_id = @venue_management_contract.venue_management_main_id + @venue_management_contract.destroy + + redirect_to venue_management_contracts_admin_venue_management_path(@venue_management_main_id) + end + + private + + def assign_inviting_attrs(contract, inviting) + %i(case_no publish_times start_date end_date close_date bid_date evaluation_date early_rent operation_rent royalty contractor_manager house_tax_payer land_tax_payer bid_result details).each do |attr| + contract[attr] = inviting.send(attr) + end + end + + def set_venue_management_contract + @venue_management_contract = VenueManagementContract.find(params[:id]) + end + + def venue_management_contract_params + params.require(:venue_management_contract).permit! + end +end diff --git a/app/controllers/admin/venue_managements_controller.rb b/app/controllers/admin/venue_managements_controller.rb index 226054a..081596a 100644 --- a/app/controllers/admin/venue_managements_controller.rb +++ b/app/controllers/admin/venue_managements_controller.rb @@ -4,7 +4,7 @@ class Admin::VenueManagementsController < OrbitAdminController require 'axlsx' helper Admin::VenueManagementsFieldHelper before_action ->(module_app = @app_title) { set_variables module_app } - before_action :set_venue_management, only: [:edit, :set_write_off, :venue_management_signup, :destroy, :venue_management_invitings, :venue_management_memorabilias] + before_action :set_venue_management, only: [:edit, :set_write_off, :venue_management_signup, :destroy, :venue_management_invitings, :venue_management_memorabilias, :venue_management_contracts] def initialize super @@ -20,7 +20,15 @@ class Admin::VenueManagementsController < OrbitAdminController def index @categories = @module_app.categories.enabled @filter_fields = filter_fields(@categories) - @table_fields = [:category, 'venue_management.title', 'venue_management.event_during', 'venue_management.signup_during', 'venue_management.signup_count', 'venue_management.inviting_hostory', 'venue_management.memorabilia','venue_management.export'] + @table_fields = [ :category, + 'venue_management.title', + 'venue_management.event_during', + 'venue_management.signup_during', + 'venue_management.contract_history', + 'venue_management.inviting_history', + 'venue_management.memorabilia', + 'venue_management.export' + ] if !params[:sort].blank? if params[:sort] == 'event_during' @@ -263,6 +271,17 @@ class Admin::VenueManagementsController < OrbitAdminController @memorabilias = @venue_management.venue_management_memorabilias.page(params[:page]).per(10) end + def venue_management_contracts + @table_fields = [ + 'vm_contract.case_no', + 'vm_contract.vendor', + 'vm_contract.start_end', + 'vm_contract.renewal_permission', + 'vm_contract.note', + ] + @contracts = @venue_management.venue_management_contracts.page(params[:page]).per(10) + end + private def set_venue_management diff --git a/app/models/venue_management_contract.rb b/app/models/venue_management_contract.rb new file mode 100644 index 0000000..3613f6e --- /dev/null +++ b/app/models/venue_management_contract.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +require 'orbit_form_helper' + +class VenueManagementContract + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::Enum + + PAYERS = [ :school, :vendor ].freeze + BID_RESULTS = [ :failure, :abandoned, :qualified ].freeze + + # Copy from Inviting + field :case_no, type: String + field :publish_times, type: Integer + field :start_date, type: Date, default: Time.now + field :end_date, type: Date + field :close_date, type: Date + field :bid_date, type: Date + field :evaluation_date, type: Date + field :early_rent, type: Integer + field :operation_rent, type: Integer + field :royalty, type: Integer + field :contractor_manager # save user_id + enum :house_tax_payer, PAYERS + enum :land_tax_payer, PAYERS + enum :bid_result, BID_RESULTS + field :details, localize: true + + # Other fields + field :vendor # save user_id + field :contract_start_date, type: Date + field :contract_end_date, type: Date + field :construction_start_date, type: Date + field :construction_end_date, type: Date + field :operation_start_date, type: Date + field :operation_end_date, type: Date + field :free_period_start_date, type: Date + field :free_period_end_date, type: Date + field :renewal_permission, type: Boolean + field :sign_date, type: Date + field :handover_date, type: Date + field :deposit_payment_date, type: Date + field :deposit_type, type: String + field :deposit_exp_date, type: Date + field :insurance_type, type: String + field :insurance_payment_deadline, type: Date + field :insurance_payment_date, type: Date + field :other_commitment, localize: true + field :note, localize: true + + + belongs_to :venue_management_main + belongs_to :venue_management_inviting + has_many :venue_management_links, :as => :venue_object, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :venue_management_links, :allow_destroy => true + +end diff --git a/app/models/venue_management_inviting.rb b/app/models/venue_management_inviting.rb index 1b40638..58336ef 100644 --- a/app/models/venue_management_inviting.rb +++ b/app/models/venue_management_inviting.rb @@ -13,10 +13,10 @@ class VenueManagementInviting field :case_no, type: String field :publish_times, type: Integer field :start_date, type: Date, default: Time.now - field :end_date, type: Date, default: Time.now - field :close_date, type: Date, default: Time.now - field :bid_date, type: Date, default: Time.now - field :evaluation_date, type: Date, default: Time.now + field :end_date, type: Date + field :close_date, type: Date + field :bid_date, type: Date + field :evaluation_date, type: Date field :early_rent, type: Integer field :operation_rent, type: Integer field :royalty, type: Integer diff --git a/app/models/venue_management_main.rb b/app/models/venue_management_main.rb index 628f7cd..4537bbc 100644 --- a/app/models/venue_management_main.rb +++ b/app/models/venue_management_main.rb @@ -38,6 +38,7 @@ class VenueManagementMain has_many :venue_management_links, :autosave => true, :dependent => :destroy has_many :venue_management_invitings, :autosave => true, :dependent => :destroy has_many :venue_management_memorabilias, :autosave => true, :dependent => :destroy + has_many :venue_management_contracts, :autosave => true, :dependent => :destroy has_many :venue_management_files, :autosave => true, :dependent => :destroy has_many :venue_management_item_contents, :autosave => true, :dependent => :destroy has_many :venue_management_signups, :autosave => true, :dependent => :destroy diff --git a/app/views/admin/venue_management_contracts/_form.html.erb b/app/views/admin/venue_management_contracts/_form.html.erb new file mode 100644 index 0000000..145fc63 --- /dev/null +++ b/app/views/admin/venue_management_contracts/_form.html.erb @@ -0,0 +1,204 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + +
+ <%= hidden_field_tag 'venue_management_link_field_count', @venue_management_contract.venue_management_links.count %> + <%= t(:add) %> +
+<%= contract.venue_management_main.title %> | + <% end %> +
+ <%= link_to contract.case_no, admin_venue_management_contract_path(contract.id), :target => '_blank' %>
+
+
+
+
+ |
+ <%= contract.vendor %> | +<%= "#{contract.contract_start_date} / #{contract.contract_end_date}" %> | +<%= t("vm_contract.renewal.#{contract.renewal_permission}") if contract.renewal_permission.present? %> | +<%= contract.note %> | +