venue_management/app/controllers/admin/venue_management_contracts_...

81 lines
2.6 KiB
Ruby
Raw Normal View History

2020-07-30 17:30:14 +00:00
# frozen_string_literal: true
2020-08-04 09:04:04 +00:00
class Admin::VenueManagementContractsController < Admin::VenueAdminController
2020-07-30 17:30:14 +00:00
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 fetch_inviting
invitings = VenueManagementInviting.where(id: params[:id])
data = {}
if !invitings.first.nil?
key = [:early_rent,:operation_rent,:royalty,:house_tax_payer,:land_tax_payer]
invitings.pluck(*key)[0].each_with_index do |v,i|
data[key[i]] = v
end
end
render :json => data
end
2020-07-30 17:30:14 +00:00
def index
@table_fields = [
'venue_management.title',
'vm_contract.case_no',
'vm_inviting.type',
2020-07-30 17:30:14 +00:00
'vm_contract.vendor',
'vm_inviting.rents',
'vm_inviting.royalty',
2020-07-30 17:30:14 +00:00
'vm_contract.start_end',
'vm_contract.renewal_permission',
'vm_contract.note',
]
@contracts = VenueManagementContract.order(updated_at: :desc).page(params[:page]).per(10)
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
2020-07-30 17:30:14 +00:00
end
def new
@venue_management = VenueManagementMain.find(params[:id])
@venue_management_contract = @venue_management.venue_management_contracts.build
end
def create
2020-09-22 15:19:59 +00:00
OrbitHelper.set_params(params,current_user)
2020-07-30 17:30:14 +00:00
@venue_management_contract = VenueManagementContract.new(venue_management_contract_params)
@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
2020-09-22 15:19:59 +00:00
OrbitHelper.set_params(params,current_user)
2020-08-02 13:33:41 +00:00
@venue_management_contract.update_attributes!(venue_management_contract_params)
2020-07-30 17:30:14 +00:00
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 set_venue_management_contract
@venue_management_contract = VenueManagementContract.find(params[:id])
end
def venue_management_contract_params
contract_params = params.require(:venue_management_contract).permit!
contract_params["contractor_ids"] = [] if contract_params["contractor_ids"].nil?
return contract_params
2020-07-30 17:30:14 +00:00
end
end