diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e58b34db..2cb0533a 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,11 @@ + + + + @@ -19,81 +23,53 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -151,13 +127,11 @@ @@ -234,6 +211,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -591,22 +605,21 @@ - + - - - + @@ -633,8 +646,6 @@ - - @@ -765,13 +776,6 @@ - - - - - - - @@ -786,13 +790,6 @@ - - - - - - - @@ -836,13 +833,6 @@ - - - - - - - @@ -930,14 +920,6 @@ - - - - - - - - @@ -962,14 +944,6 @@ - - - - - - - - @@ -986,10 +960,68 @@ + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/controllers/origami/commissions_controller.rb b/app/controllers/origami/commissions_controller.rb index 3e4f3301..f5a91ad9 100644 --- a/app/controllers/origami/commissions_controller.rb +++ b/app/controllers/origami/commissions_controller.rb @@ -76,6 +76,11 @@ class Origami::CommissionsController < BaseOrigamiController sale_item_id = params[:sale_item_id] @sale_item = SaleItem.find_by_sale_item_id(sale_item_id) @commissioners = Commissioner.active.all + + respond_to do |format| + format.json {render json: @commissioners} + # format.html {render @commissioners} + end end private diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb index 94f095ec..ef972df9 100644 --- a/app/controllers/settings/promotions_controller.rb +++ b/app/controllers/settings/promotions_controller.rb @@ -4,7 +4,7 @@ class Settings::PromotionsController < ApplicationController # GET /promotions # GET /promotions.json def index - @promotions = Promotion.all + @promotions = Promotion.all.order("created_at asc") end # GET /promotions/1 @@ -85,6 +85,6 @@ class Settings::PromotionsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def promotion_params params.require(:promotion).permit(:promo_code, :promo_start_date, :promo_end_date, :promo_start_hour,:promo_end_hour ,:promo_day, :promo_type,:original_product ,:min_qty ,:created_by, - :promotion_products_attributes => [:item_code, :min_qty, :net_off, :net_price, :percentage, :_destroy]) + :promotion_products_attributes => [:id,:item_code, :min_qty, :net_off, :net_price, :percentage, :_destroy]) end end diff --git a/app/models/promotion.rb b/app/models/promotion.rb index ed727038..87b90613 100644 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -3,7 +3,7 @@ class Promotion < ApplicationRecord has_many :promotion_products - accepts_nested_attributes_for :promotion_products , :allow_destroy => true + accepts_nested_attributes_for :promotion_products , :allow_destroy => true , update_only: true PROMO_TYPE1 = "Quantity" PROMO_TYPE2 = "Net_off" # 3000 => - 500 => 2500 [total] @@ -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/models/promotion_product.rb b/app/models/promotion_product.rb index c853ebdc..e97445ea 100644 --- a/app/models/promotion_product.rb +++ b/app/models/promotion_product.rb @@ -1,3 +1,4 @@ class PromotionProduct < ApplicationRecord + validates_presence_of :item_code belongs_to :promotion end diff --git a/app/views/origami/commissioners/_commissioners_form.html.erb b/app/views/origami/commissions/_commissioners.html.erb similarity index 72% rename from app/views/origami/commissioners/_commissioners_form.html.erb rename to app/views/origami/commissions/_commissioners.html.erb index 10637a82..ed9da369 100644 --- a/app/views/origami/commissioners/_commissioners_form.html.erb +++ b/app/views/origami/commissions/_commissioners.html.erb @@ -3,7 +3,7 @@
COMMISSIONERS
-
+
<% @commissioners.each do |commissioner| %>
diff --git a/app/views/origami/commissions/load_commissioners.html.erb b/app/views/origami/commissions/load_commissioners.html.erb index 5252b1bd..748fb4ef 100644 --- a/app/views/origami/commissions/load_commissioners.html.erb +++ b/app/views/origami/commissions/load_commissioners.html.erb @@ -1,7 +1,7 @@
- <%= render 'origami/commissioners/commissioners_form', commissioners: @commissioners %> + <%= render 'origami/commissions/commissioners', commissioners: @commissioners %>
@@ -210,7 +210,11 @@ url: ajax_url, data: 'sale_item_id=' + sale_item_id, success: function (result) { -// window.location.href = '/origami/table/' + table_id; + $('#commissioners').empty(); + result.forEach(function (t) { + sale_item = "
" + "
" + t.name + "
" + "
" + $('#commissioners').append(sale_item); + }) } }); }) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index dfaa9e45..e08f5d3d 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -310,39 +310,40 @@
- -
- + +
+ - - - <% if @dining.bookings.length >= 1 %> - <% if @status_order == 'order' && @status_sale != 'sale' %> - - - - - - - - - - <% else %> - - - - - - - - - - <% end %> - + + + <% if @dining.bookings.length >= 1 %> + <% if @status_order == 'order' && @status_sale != 'sale' %> + + + + + + + + + + <% else %> + + + + + + + + + + + <% end %> + - - <% end %> -
+ + <% end %> +