Dining Charges CRUD
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
class DiningChargesController < ApplicationController
|
||||
class Settings::DiningChargesController < ApplicationController
|
||||
before_action :set_dining_charge, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
before_action :set_settings_facility
|
||||
before_action :set_settings_zone
|
||||
# GET /dining_charges
|
||||
# GET /dining_charges.json
|
||||
def index
|
||||
@@ -25,10 +26,10 @@ class DiningChargesController < ApplicationController
|
||||
# POST /dining_charges.json
|
||||
def create
|
||||
@dining_charge = DiningCharge.new(dining_charge_params)
|
||||
|
||||
@dining_charge.dining_facility_id = @settings_dining_facility.id
|
||||
respond_to do |format|
|
||||
if @dining_charge.save
|
||||
format.html { redirect_to @dining_charge, notice: 'Dining charge was successfully created.' }
|
||||
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @dining_charge }
|
||||
else
|
||||
format.html { render :new }
|
||||
@@ -41,8 +42,9 @@ class DiningChargesController < ApplicationController
|
||||
# PATCH/PUT /dining_charges/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
@dining_charge.dining_facility_id = @settings_dining_facility.id
|
||||
if @dining_charge.update(dining_charge_params)
|
||||
format.html { redirect_to @dining_charge, notice: 'Dining charge was successfully updated.' }
|
||||
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @dining_charge }
|
||||
else
|
||||
format.html { render :edit }
|
||||
@@ -67,8 +69,23 @@ class DiningChargesController < ApplicationController
|
||||
@dining_charge = DiningCharge.find(params[:id])
|
||||
end
|
||||
|
||||
def set_settings_facility
|
||||
if params[:table_id]
|
||||
@table = true
|
||||
@settings_dining_facility = Table.find(params[:table_id])
|
||||
elsif params[:room_id]
|
||||
@room = true
|
||||
@settings_dining_facility = Room.find(params[:room_id])
|
||||
end
|
||||
end
|
||||
|
||||
def set_settings_zone
|
||||
@zone = Zone.find(params[:zone_id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def dining_charge_params
|
||||
params.fetch(:dining_charge, {})
|
||||
# params.fetch(:dining_charge, {})
|
||||
params.require(:dining_charge).permit(:item_code, :unit_price, :taxable, :charge_type,:minimum_free_time ,:charge_block,:time_rounding,:time_rounding_block, :zone_id)
|
||||
end
|
||||
end
|
||||
@@ -1,2 +1,4 @@
|
||||
class DiningCharge < ApplicationRecord
|
||||
belongs_to :table
|
||||
belongs_to :room
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class DiningFacility < ApplicationRecord
|
||||
belongs_to :zone
|
||||
has_many :dining_charges
|
||||
|
||||
TABLE_TYPE = "Table"
|
||||
ROOM_TYPE = "Room"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<%= simple_form_for(@dining_charge) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,6 +0,0 @@
|
||||
<h1>Editing Dining Charge</h1>
|
||||
|
||||
<%= render 'form', dining_charge: @dining_charge %>
|
||||
|
||||
<%= link_to 'Show', @dining_charge %> |
|
||||
<%= link_to 'Back', dining_charges_path %>
|
||||
@@ -1,5 +0,0 @@
|
||||
<h1>New Dining Charge</h1>
|
||||
|
||||
<%= render 'form', dining_charge: @dining_charge %>
|
||||
|
||||
<%= link_to 'Back', dining_charges_path %>
|
||||
18
app/views/settings/dining_charges/_form.html.erb
Normal file
18
app/views/settings/dining_charges/_form.html.erb
Normal file
@@ -0,0 +1,18 @@
|
||||
<%= simple_form_for([:settings,@zone,@settings_dining_facility,@dining_charge]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :item_code %>
|
||||
<%= f.input :unit_price %>
|
||||
<%= f.input :taxable %>
|
||||
<%= f.input :charge_type %>
|
||||
<%= f.input :minimum_free_time %>
|
||||
<%= f.input :charge_block %>
|
||||
<%= f.input :time_rounding %>
|
||||
<%= f.input :time_rounding_block %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
19
app/views/settings/dining_charges/edit.html.erb
Normal file
19
app/views/settings/dining_charges/edit.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<!-- <h1>Editing Dining Charge</h1>
|
||||
|
||||
<%= render 'form', dining_charge: @dining_charge %>-->
|
||||
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_zone_path(@zone) %>">Zone</a></li>
|
||||
<% if @table %>
|
||||
<li><a href="<%= edit_settings_zone_table_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
|
||||
<% elsif @room %>
|
||||
<li><a href="<%= edit_settings_zone_room_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
|
||||
<% end %>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', dining_charge: @dining_charge %>
|
||||
</div>
|
||||
18
app/views/settings/dining_charges/new.html.erb
Normal file
18
app/views/settings/dining_charges/new.html.erb
Normal file
@@ -0,0 +1,18 @@
|
||||
<!-- <h1>New Dining Charge</h1>
|
||||
|
||||
<%= render 'form', dining_charge: @dining_charge %> -->
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= settings_zone_path(@zone) %>">Zone</a></li>
|
||||
<% if @table %>
|
||||
<li><a href="<%= edit_settings_zone_table_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
|
||||
<% elsif @room %>
|
||||
<li><a href="<%= edit_settings_zone_room_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
|
||||
<% end %>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', dining_charge: @dining_charge %>
|
||||
</div>
|
||||
@@ -7,6 +7,26 @@
|
||||
<%= f.input :seater %>
|
||||
<%= f.input :order_by %>
|
||||
<%= f.input :is_active %>
|
||||
<% if @settings_table.dining_charges.length == 0 %>
|
||||
<div class="div-border">
|
||||
<div class="col-md-10">
|
||||
<%= link_to 'Add For Extra Charges', new_settings_zone_table_dining_charge_path(@zone,@settings_table),:class => 'btn btn-primary' %>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<% @settings_table.dining_charges.each do |dc| %>
|
||||
<div class="div-border">
|
||||
<div class="col-md-10"><b><u>Dining Charge</u></b></div>
|
||||
<div class="col-md-10">item code : <%= dc.item_code %></div>
|
||||
<div class="col-md-10">Unit price : <%= dc.unit_price %></div>
|
||||
<div class="col-md-10">Charge type : <%= dc.charge_type %></div>
|
||||
<div class="col-md-10">
|
||||
<%= link_to 'Edit Charges', edit_settings_zone_table_dining_charge_path(@zone,@settings_table,dc),:class => 'btn btn-primary' %>
|
||||
<!-- <button class="btn btn-primary" src="<%= edit_settings_zone_table_dining_charge_path(@zone,@settings_table,dc) %>">Edit Charge</button> -->
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
@@ -2,7 +2,6 @@ require 'sidekiq/web'
|
||||
|
||||
Rails.application.routes.draw do
|
||||
|
||||
resources :dining_charges
|
||||
root 'home#index'
|
||||
mount Sidekiq::Web => '/kiq'
|
||||
|
||||
@@ -146,6 +145,7 @@ Rails.application.routes.draw do
|
||||
get 'sale/:sale_id/payment/others_payment/Master' => "master#index"
|
||||
get 'sale/:sale_id/payment/others_payment/JCB' => "jcb#index"
|
||||
get 'sale/:sale_id/payment/others_payment/Redeem' => "redeem_payments#index"
|
||||
get 'sale/:sale_id/payment/others_payment/Voucher' => "voucher#index"
|
||||
|
||||
#---------Void --------------#
|
||||
post 'sale/:sale_id/void' => 'void#overall_void'
|
||||
@@ -254,9 +254,13 @@ Rails.application.routes.draw do
|
||||
#zones
|
||||
resources :zones do
|
||||
#tables
|
||||
resources :tables
|
||||
resources :tables do
|
||||
resources :dining_charges
|
||||
end
|
||||
#rooms
|
||||
resources :rooms
|
||||
resources :rooms do
|
||||
resources :dining_charges
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user