74 lines
2.3 KiB
Ruby
74 lines
2.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class Admin::VenueManagementContractsController < Admin::VenueAdminController
|
|
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
|
|
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)
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
|
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)
|
|
@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
|
|
@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 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
|