From d88199150e26bfc3882154d57bcb849e0d95d821 Mon Sep 17 00:00:00 2001 From: yamin Date: Wed, 23 Aug 2017 18:14:31 +0630 Subject: [PATCH 1/4] CRUDIn_Juties --- .../origami/in_juties_controller.rb | 8 +-- app/models/commissioner.rb | 1 + app/models/dining_facility.rb | 1 + app/models/in_juty.rb | 2 + app/views/origami/commissions/_form.html.erb | 1 + app/views/origami/in_juties/_form.html.erb | 31 ++++++++-- app/views/origami/in_juties/edit.html.erb | 16 ++++-- app/views/origami/in_juties/index.html.erb | 57 ++++++++++++------- app/views/origami/in_juties/new.html.erb | 15 +++-- app/views/origami/in_juties/show.html.erb | 45 ++++++++++++++- 10 files changed, 133 insertions(+), 44 deletions(-) diff --git a/app/controllers/origami/in_juties_controller.rb b/app/controllers/origami/in_juties_controller.rb index d424186b..2f7ff21f 100644 --- a/app/controllers/origami/in_juties_controller.rb +++ b/app/controllers/origami/in_juties_controller.rb @@ -28,7 +28,7 @@ class Origami::InJutiesController < BaseOrigamiController respond_to do |format| if @in_juty.save - format.html { redirect_to @in_juty, notice: 'In juty was successfully created.' } + format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully created.' } format.json { render :show, status: :created, location: @in_juty } else format.html { render :new } @@ -42,7 +42,7 @@ class Origami::InJutiesController < BaseOrigamiController def update respond_to do |format| if @in_juty.update(in_juty_params) - format.html { redirect_to @in_juty, notice: 'In juty was successfully updated.' } + format.html { redirect_to origami_in_juty_path(@in_juty), notice: 'In juty was successfully updated.' } format.json { render :show, status: :ok, location: @in_juty } else format.html { render :edit } @@ -56,7 +56,7 @@ class Origami::InJutiesController < BaseOrigamiController def destroy @in_juty.destroy respond_to do |format| - format.html { redirect_to in_juties_url, notice: 'In juty was successfully destroyed.' } + format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully destroyed.' } format.json { head :no_content } end end @@ -69,6 +69,6 @@ class Origami::InJutiesController < BaseOrigamiController # Never trust parameters from the scary internet, only allow the white list through. def in_juty_params - params.fetch(:in_juty, {}) + params.require(:in_juty).permit(:dinning_id,:commissioner_ids,:in_time,:out_time) end end diff --git a/app/models/commissioner.rb b/app/models/commissioner.rb index ac199468..dd22278a 100644 --- a/app/models/commissioner.rb +++ b/app/models/commissioner.rb @@ -1,5 +1,6 @@ class Commissioner < ApplicationRecord belongs_to :employee, foreign_key: 'emp_id' belongs_to :commission, foreign_key: 'commission_type' + has_many :in_juties scope :active, -> { where(is_active: true) } end diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index f441612a..ba01afb6 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -1,6 +1,7 @@ class DiningFacility < ApplicationRecord belongs_to :zone has_many :dining_charges + has_many :in_juties TABLE_TYPE = "Table" ROOM_TYPE = "Room" diff --git a/app/models/in_juty.rb b/app/models/in_juty.rb index d5ca9685..2f023ff0 100644 --- a/app/models/in_juty.rb +++ b/app/models/in_juty.rb @@ -1,2 +1,4 @@ class InJuty < ApplicationRecord + belongs_to :dining_facility, foreign_key: 'dinning_id' + belongs_to :commissioner, foreign_key: 'commissioner_ids' end diff --git a/app/views/origami/commissions/_form.html.erb b/app/views/origami/commissions/_form.html.erb index 1f7fee4a..5077f946 100644 --- a/app/views/origami/commissions/_form.html.erb +++ b/app/views/origami/commissions/_form.html.erb @@ -8,6 +8,7 @@ <%= f.input :amount %> <%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %> +
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %> diff --git a/app/views/origami/in_juties/_form.html.erb b/app/views/origami/in_juties/_form.html.erb index 5259b903..d67df51b 100644 --- a/app/views/origami/in_juties/_form.html.erb +++ b/app/views/origami/in_juties/_form.html.erb @@ -1,10 +1,33 @@ -<%= simple_form_for(@in_juty) do |f| %> +
+<%= simple_form_for([:origami,@in_juty]) do |f| %> <%= f.error_notification %>
-
- + <%= f.label :dinning_id %> + <%= f.collection_select :dinning_id, DiningFacility.all, :id, :name, {prompt: 'Select Dining Facilities'}, {class: 'form-control'} %>
+ <%= f.label :commissioner_ids %> + <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>
+ + <%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
+ + <%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%> +

- <%= f.button :submit %> + <%= link_to 'Back', origami_in_juties_path, class: 'btn btn-success' %> + <%= f.button :submit, class: 'btn btn-info' %>
<% end %> +
+ + \ No newline at end of file diff --git a/app/views/origami/in_juties/edit.html.erb b/app/views/origami/in_juties/edit.html.erb index 45addcc2..3a6fc774 100644 --- a/app/views/origami/in_juties/edit.html.erb +++ b/app/views/origami/in_juties/edit.html.erb @@ -1,6 +1,10 @@ -

Editing In Juty

- -<%= render 'form', in_juty: @in_juty %> - -<%= link_to 'Show', @in_juty %> | -<%= link_to 'Back', in_juties_path %> +
+ + <%= render 'form', in_juty: @in_juty %> +
\ No newline at end of file diff --git a/app/views/origami/in_juties/index.html.erb b/app/views/origami/in_juties/index.html.erb index d407bb94..6efeb999 100644 --- a/app/views/origami/in_juties/index.html.erb +++ b/app/views/origami/in_juties/index.html.erb @@ -1,25 +1,38 @@ -

<%= notice %>

- -

In Juties

- - - - - - - - - - <% @in_juties.each do |in_juty| %> - - - - - - <% end %> - -
<%= link_to 'Show', in_juty %><%= link_to 'Edit', edit_in_juty_path(in_juty) %><%= link_to 'Destroy', in_juty, method: :delete, data: { confirm: 'Are you sure?' } %>
+
+
+ + + + + + + + + + -<%= link_to 'New In Juty', new_in_juty_path %> + + <% @in_juties.each do |in_juty| %> + + + + + + + + + + <% end %> + +
Dining Facility NameCommissioner IdsIn timeOut 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 'Show', origami_in_juty_path(in_juty) %><%= link_to 'Edit', edit_origami_in_juty_path(in_juty) %><%= link_to 'Destroy', origami_in_juty_path(in_juty), method: :delete, data: {confirm: 'Are you sure?'} %>
+
diff --git a/app/views/origami/in_juties/new.html.erb b/app/views/origami/in_juties/new.html.erb index cf54d27f..eb34f01c 100644 --- a/app/views/origami/in_juties/new.html.erb +++ b/app/views/origami/in_juties/new.html.erb @@ -1,5 +1,10 @@ -

New In Juty

- -<%= render 'form', in_juty: @in_juty %> - -<%= link_to 'Back', in_juties_path %> +
+ + <%= render 'form', in_juty: @in_juty %> +
diff --git a/app/views/origami/in_juties/show.html.erb b/app/views/origami/in_juties/show.html.erb index c5d6379a..34d72071 100644 --- a/app/views/origami/in_juties/show.html.erb +++ b/app/views/origami/in_juties/show.html.erb @@ -1,4 +1,43 @@ -

<%= notice %>

+ +
+
+

In Juty

+ + + + + + + + + + + + + + + + + + + + + +
Dining Facility Name<%= @in_juty.dining_facility.name%>
Commissioner Name + <%= @in_juty.commissioner.name rescue '-' %> +
In Time<%= @in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %>
Out Time<%= @in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %>
+ <%= link_to 'Back', origami_in_juties_path, class: 'btn btn-success' %> + <%= link_to 'Edit', edit_origami_in_juty_path(@in_juty), class: 'btn btn-info' %> + <%= link_to 'Destroy', origami_in_juty_path(@in_juty), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %> +
+
+ + From 857fcd419f3264b3ab0f3c411ab346102387628a Mon Sep 17 00:00:00 2001 From: Phyo Date: Wed, 23 Aug 2017 19:09:44 +0630 Subject: [PATCH 2/4] Promotion Time Fixed --- Gemfile | 1 + Gemfile.lock | 2 + app/assets/javascripts/application.js | 1 + app/assets/stylesheets/application.scss | 3 +- .../settings/promotions_controller.rb | 13 +++ app/views/settings/promotions/_form.html.erb | 90 ++++++++++++++++--- app/views/settings/promotions/index.html.erb | 4 +- app/views/settings/promotions/show.html.erb | 4 +- 8 files changed, 100 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index 7b2cdca5..44a85e51 100644 --- a/Gemfile +++ b/Gemfile @@ -116,3 +116,4 @@ gem 'httparty', '~> 0.15.5' # # gem 'momentjs-rails', '>= 2.9.0' # gem 'bootstrap3-datetimepicker-rails'z gem 'bootstrap-datepicker-rails' +gem 'jquery-datetimepicker-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 912f79ef..f2d875dd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,6 +89,7 @@ GEM jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) + jquery-datetimepicker-rails (2.4.1.0) jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -265,6 +266,7 @@ DEPENDENCIES font-awesome-rails httparty (~> 0.15.5) jbuilder (~> 2.5) + jquery-datetimepicker-rails jquery-rails jquery-ui-rails kaminari (~> 1.0.1) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index cd056d1c..675bca2e 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -20,6 +20,7 @@ //= require settings/processing_items //= require jquery-ui //= require bootstrap-datepicker +//= require jquery.datetimepicker $(document).on('turbolinks:load', function() { $('.datepicker').datepicker({ diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 2db849ab..6ff7113c 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -4,6 +4,7 @@ @import "theme"; @import "jquery-ui"; @import "bootstrap-datepicker3"; +@import "jquery.datetimepicker"; /* Show it is fixed to the top */ // body { @@ -75,5 +76,3 @@ select.form-control { } /*--- Reset --- */ - - diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb index 246bd51b..94f095ec 100644 --- a/app/controllers/settings/promotions_controller.rb +++ b/app/controllers/settings/promotions_controller.rb @@ -28,8 +28,14 @@ class Settings::PromotionsController < ApplicationController def create @promotion = Promotion.new(promotion_params) @promotion.created_by = current_login_employee.id + @promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30) + @promotion.promo_end_hour = @promotion.promo_end_hour.to_datetime.advance(hours: +6, minutes: +30) respond_to do |format| if @promotion.save + promo_pros = @promotion.promotion_products + promo_pros.each do |promo_pro| + promo_pro.save + end format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully created.' } format.json { render :show, status: :created, location: @promotion } else @@ -44,6 +50,13 @@ class Settings::PromotionsController < ApplicationController def update respond_to do |format| if @promotion.update(promotion_params) + @promotion.promo_start_hour = @promotion.promo_start_hour.to_datetime.advance(hours: +6, minutes: +30) + @promotion.promo_end_hour = @promotion.promo_end_hour.to_datetime.advance(hours: +6, minutes: +30) + @promotion.save + promo_pros = @promotion.promotion_products + promo_pros.each do |promo_pro| + promo_pro.save + end format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully updated.' } format.json { render :show, status: :ok, location: @promotion } else diff --git a/app/views/settings/promotions/_form.html.erb b/app/views/settings/promotions/_form.html.erb index 474dcb3d..c3953f32 100644 --- a/app/views/settings/promotions/_form.html.erb +++ b/app/views/settings/promotions/_form.html.erb @@ -1,3 +1,4 @@ + <%= simple_nested_form_for([:settings,@promotion]) do |f| %> <%= f.error_notification %> @@ -20,11 +21,23 @@
- <%= f.input :promo_start_hour %> + + <% if !@promotion.promo_start_hour.nil?%> + <%= f.input :promo_start_hour, as: :string, input_html: { :value => @promotion.promo_start_hour.utc.strftime('%H:%M') } %> + <% else %> + <%= f.input :promo_start_hour, as: :string, input_html: { } %> + <% end %>
-
<%= f.input :promo_end_hour %>
+
+ + <% if !@promotion.promo_end_hour.nil?%> + <%= f.input :promo_end_hour, as: :string, input_html: {:value => @promotion.promo_end_hour.utc.strftime('%H:%M') } %> + <% else %> + <%= f.input :promo_end_hour, as: :string, input_html: {} %> + <% end %> +
<%= f.input :promo_day %>
@@ -40,19 +53,52 @@
<%= f.input :min_qty %>

-

<%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %>


- <%= f.fields_for :promotion_products do |p| %> + + + + + + + + + + + -
-
<%= p.input :item_code , :class => "form-control" %>
-
<%= p.input :min_qty , :class => "form-control" %>
-
<%= p.input :net_off , :class => "form-control" %>
-
<%= p.input :net_price , :class => "form-control" %>
-
<%= p.input :percentage , :class => "form-control" %>
-
<%= p.link_to_remove "X"%>
-
+ + +
Item CodeMin QtyNet offNet PricePercentage
+ <%= f.fields_for :promotion_products do |pro| %> + + + + + + + + + + + + + +
<%= pro.input :item_code, label: false%><%= pro.input :min_qty , label: false%><%= pro.input :net_off , label: false %><%= pro.input :net_price , label: false %><%= pro.input :percentage , label: false %><%= pro.link_to_remove "X" %>
<% end %> + <%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %> @@ -61,3 +107,23 @@ <%= f.button :submit %> <% end %> + diff --git a/app/views/settings/promotions/index.html.erb b/app/views/settings/promotions/index.html.erb index 606b138b..7914c6af 100644 --- a/app/views/settings/promotions/index.html.erb +++ b/app/views/settings/promotions/index.html.erb @@ -35,8 +35,8 @@ <%= link_to pro.promo_code, settings_promotion_path(pro) %> <%= pro.promo_start_date %> <%= pro.promo_end_date %> - <%= pro.promo_start_hour.strftime("%I:%M %P") rescue "-" %> - <%= pro.promo_end_hour.strftime("%I:%M %P") rescue "-" %> + <%= pro.promo_start_hour.utc.strftime("%I:%M %P") rescue "-" %> + <%= pro.promo_end_hour.utc.strftime("%I:%M %P") rescue "-" %> <%= pro.promo_day %> <% if MenuItem.exists?(pro.original_product) %> diff --git a/app/views/settings/promotions/show.html.erb b/app/views/settings/promotions/show.html.erb index 170ba4bf..4a994919 100644 --- a/app/views/settings/promotions/show.html.erb +++ b/app/views/settings/promotions/show.html.erb @@ -17,8 +17,8 @@ Promotion code<%= @promotion.promo_code %> Promotion Start Date<%= @promotion.promo_start_date %> Promotion End Date<%= @promotion.promo_end_date %> - Promotion Start Hour<%= @promotion.promo_start_hour %> - Promotion Start Hour<%= @promotion.promo_end_hour %> + Promotion Start Hour<%= @promotion.promo_start_hour.utc.strftime("%I:%M %P") rescue "-" %> + Promotion Start Hour<%= @promotion.promo_end_hour.utc.strftime("%I:%M %P") rescue "-" %> <%= link_to 'Edit', edit_settings_promotion_path(@promotion) %><%= link_to 'Destroy', settings_promotion_path(@promotion), method: :delete, data: { confirm: 'Are you sure?' } %> From f2ddcb9e4bcf019530cbf90e4fcb2cc24e2cf7d1 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Thu, 24 Aug 2017 10:05:07 +0630 Subject: [PATCH 3/4] readded commission --- .idea/workspace.xml | 258 ++++++++++-------- .../origami/commissions_controller.rb | 5 + .../_commissioners.html.erb} | 2 +- .../commissions/load_commissioners.html.erb | 8 +- app/views/origami/home/show.html.erb | 63 ++--- 5 files changed, 189 insertions(+), 147 deletions(-) rename app/views/origami/{commissioners/_commissioners_form.html.erb => commissions/_commissioners.html.erb} (72%) 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/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 %> +