diff --git a/app/controllers/origami/in_juties_controller.rb b/app/controllers/origami/in_juties_controller.rb index 2f7ff21f..f13c6fb6 100644 --- a/app/controllers/origami/in_juties_controller.rb +++ b/app/controllers/origami/in_juties_controller.rb @@ -1,5 +1,5 @@ class Origami::InJutiesController < BaseOrigamiController - before_action :set_in_juty, only: [:show, :edit, :update, :destroy] + before_action :set_in_juty, only: [:show, :edit, :update,:edit_in_juty, :update_for_in_juty , :destroy ,:destroy_in_juty] # GET /in_juties # GET /in_juties.json @@ -7,6 +7,9 @@ class Origami::InJutiesController < BaseOrigamiController @in_juties = InJuty.all end + def index_in_juty + @juties_in= InJuty.where("dinning_id=?",params[:table_id]) + end # GET /in_juties/1 # GET /in_juties/1.json def show @@ -21,6 +24,14 @@ class Origami::InJutiesController < BaseOrigamiController def edit end + def edit_in_juty + @table = DiningFacility.find(params[:table_id]) + end + + def assign_in_juty + @in_juty = InJuty.new + @table = DiningFacility.find(params[:table_id]) + end # POST /in_juties # POST /in_juties.json def create @@ -37,6 +48,15 @@ class Origami::InJutiesController < BaseOrigamiController end end + def create_for_in_juty + + @in_juty.dinning_id = params[:dining_id] + @in_juty.commissioner_ids = params[:commissioner_ids] + @in_juty.in_time = params[:in_time] + @in_juty.out_time = params[:out_time] + @in_juty.save + end + # PATCH/PUT /in_juties/1 # PATCH/PUT /in_juties/1.json def update @@ -51,6 +71,15 @@ class Origami::InJutiesController < BaseOrigamiController end end + + def update_for_in_juty + @in_juty.dinning_id = params[:dining_id] + @in_juty.commissioner_ids = params[:commissioner_ids] + @in_juty.in_time = params[:in_time] + @in_juty.out_time = params[:out_time] + @in_juty.update + end + # DELETE /in_juties/1 # DELETE /in_juties/1.json def destroy @@ -61,6 +90,14 @@ class Origami::InJutiesController < BaseOrigamiController end end + def destroy_in_juty + @in_juty.destroy + respond_to do |format| + format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully destroyed.' } + format.json { head :no_content } + end + end + private # Use callbacks to share common setup or constraints between actions. def set_in_juty diff --git a/app/models/promotion.rb b/app/models/promotion.rb index ed727038..77e282b4 100644 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -204,6 +204,6 @@ class Promotion < ApplicationRecord end def self.calculate_discount(total, discount) - self (total.to_i * discount.to_i) / 100 + return (total.to_i * discount.to_i) / 100 end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index e08f5d3d..680894ff 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -333,6 +333,7 @@ + @@ -579,6 +580,11 @@ window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/load_commissioners"; }); + $('#in_juties').on('click', function () { + var dining_id = "<%= @dining.id %>" + window.location.href = '/origami/assign_in_juty/'+ dining_id; + }); + $('#void').on('click', function () { var sure = confirm("Are you sure want to Void"); if (sure == true) { diff --git a/app/views/origami/in_juties/_assign_in_juty.html.erb b/app/views/origami/in_juties/_assign_in_juty.html.erb new file mode 100644 index 00000000..14469fde --- /dev/null +++ b/app/views/origami/in_juties/_assign_in_juty.html.erb @@ -0,0 +1,58 @@ +
| Dining Facility Name | +Commissioner Ids | +In time | +Out time | ++ | |
|---|---|---|---|---|---|
| <%= in_juty.dining_facility.name rescue '-' %> | +<%= in_juty.commissioner.name rescue '-' %> | +<%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> | +<%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> | +<%= link_to 'Edit', origami_edit_in_juty_path(in_juty) %> | +<%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty), method: :delete, data: {confirm: 'Are you sure?'} %> | +