From f56b7ab26e09465d92b5d493fec58f9e11f2d866 Mon Sep 17 00:00:00 2001 From: Phyo Date: Tue, 5 Sep 2017 10:44:33 +0630 Subject: [PATCH 1/6] Promotion Destory Bug Fix --- app/controllers/settings/promotions_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb index af8bedc1..4ab33dba 100644 --- a/app/controllers/settings/promotions_controller.rb +++ b/app/controllers/settings/promotions_controller.rb @@ -69,6 +69,9 @@ class Settings::PromotionsController < ApplicationController # DELETE /promotions/1 # DELETE /promotions/1.json def destroy + @promotion.promotion_products.each do |pp| + pp.destroy + end @promotion.destroy respond_to do |format| format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully destroyed.' } From 31021813b02e8a80f90231df853591eff7dcf2eb Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Tue, 5 Sep 2017 16:47:50 +0630 Subject: [PATCH 2/6] inventory list and stock check --- .idea/workspace.xml | 997 +++++++++++------- .../stylesheets/inventory_definitions.scss | 275 ++++- .../inventory_definitions_controller.rb | 2 +- .../inventory/stock_checks_controller.rb | 1 + .../inventory/_inventory_list.html.erb | 2 +- .../inventory_definitions/_form.html.erb | 123 ++- .../inventory/stock_checks/index.html.erb | 96 +- app/views/layouts/_header_inventory.html.erb | 38 + app/views/layouts/inventory.html.erb | 4 +- config/initializers/assets.rb | 3 + 10 files changed, 1038 insertions(+), 503 deletions(-) create mode 100644 app/views/layouts/_header_inventory.html.erb diff --git a/.idea/workspace.xml b/.idea/workspace.xml index cd4a6736..467886cf 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,13 +3,14 @@ - - + + + + - - - - + + + @@ -24,7 +25,7 @@ - + @@ -50,100 +51,180 @@ @@ -380,7 +524,7 @@ - + @@ -779,12 +923,12 @@ - + - @@ -797,7 +941,6 @@ - @@ -806,8 +949,8 @@ - - + + @@ -875,225 +1018,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1109,14 +1038,6 @@ - - - - - - - - @@ -1157,38 +1078,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1197,40 +1086,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1263,5 +1118,331 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/assets/stylesheets/inventory_definitions.scss b/app/assets/stylesheets/inventory_definitions.scss index 538c2918..e7fc208e 100644 --- a/app/assets/stylesheets/inventory_definitions.scss +++ b/app/assets/stylesheets/inventory_definitions.scss @@ -1,3 +1,272 @@ -// Place all the styles related to the inventory_definitions controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ +@import "bootstrap"; +@import "font-awesome"; +@import "theme"; +@import "jquery-ui"; +@import "bootstrap-datepicker3"; +@import "select2"; +@import "jquery.datetimepicker"; + +/* Show it is fixed to the top */ +// body { +// min-height: 75rem; +// padding-top: 4.5rem; +// } +.card-columns { + font-size: 18px !important; +} + +.others-payment{ + line-height:100px; + text-align:center; + color:white; + width:300px; + height:100px; + font-size:18px; +} + +.orders-table { + cursor: pointer; +} + +.cashier_number{ + width: 33%; + height:70px; + line-height:70px; + text-align:center; + background:#54A5AF; + // float:left; + // margin:2px; + font-size:20px; + color:white; + // cursor:pointer; +} + +.del_cashier_number{ + opacity:0.6, +} + +.pay{ + width: 98%; + height:211px; + line-height:211px; + text-align:center; + font-size:20px; + color:white; +} + +.payment{ + height:70px;line-height:70px; + align:center; + color:white; + font-size:16px; + margin-top:5px; +} + +.cash-color{ + background-color:#80CBC4; +} + +.credit-color{ + background-color:#FFCCBC; +} + +.other-payment-color{ + background-color:#E1BEE7; +} + +.cashier_number:hover{ + background:#A9F5F2; +} + +.action-btn { + white-space: normal !important; + height: 60px; + margin-bottom: 5px; +} + +.bottom-5 { + margin-bottom: 5px; +} + +.fluid { + width: 100%; +} + +.style2 { + border-top: 3px double #8c8b8b; +} + +.long{ + width:49%; +} + +.sold { + background-color: red; +} + +.paid { + background-color: green; +} + +.selected-item { + color: #fff !important; + background-color: blue !important; +} + +.selected-account { + color: #fff !important; + background-color: blue !important; +} + +/* Reciept Style */ +#order-charges-table td { + border-top: none !important; +} + +.charges-name { + width: 80%; + text-align: left; +} + +.item-name { + width: 60%; + text-align: left; +} + +.item-attr { + width: 20%; + text-align: right; +} + +.item-attr-edit{ + width: 10%; + text-align: left; +} + +.display-none{ + display: none; +} + +.text-white{ + color: #fff; +} + +/* Colors */ +.purple { + background-color:#7a62d3; +} + +.orange{ + background-color:#FF7F50; +} + +.red { + background-color:#ff0000; +} + +.green{ + background-color: #009900; +} + +.orange{ + background-color: #FF8C00; +} + +.blue{ + background-color: blue; +} + +/* End Colors */ + +.left{ + margin-left:1px; +} + +.bottom{ + margin-bottom: 1px; +} + +/*----- Reset -----*/ + +select.form-control { + height: inherit !important; +} + +.form-horizontal .form-group { + margin-right: 0px !important; +} + +/* Discount */ + +.discount-item-row { + cursor: pointer; +} + +tr.discount-item-row:hover { + background-color: #e3e3e3 !important; +} +.required abbr{ + color: red !important; +} + +/* Jquery Confirm */ + +.jconfirm-box-container{ + margin-left:-40px !important; + margin-top:-40px !important; +} + +#sxModal { + display: none; + overflow: auto; + width: 100%; + height: 100%; + background-color: #000; + background-color: rgba(0,0,0,0.4); + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 1100; +} + +#sxModal-Content { + position: relative; + left: 42%; + top: 30%; + background-color: #d9534f; + color: #fff; + text-align: center; + width: 200px; + height: 200px; + padding-top: 5%; + border-radius: 100px; + z-index: 1101; +} + +/*Loading gif for payment*/ + +#loading_wrapper{ + + position: fixed; + background-color: #C8C8C8 ; + height: 100%; + width: 100%; + left: 0; + opacity: 0.6; + top: 0; + z-index: 9999999; +} +#loading{ + position: relative; + height: 100%; + width: 100%; + background-image: url('../../../image/loading-ajax.gif'); + background-position: center center; + background-repeat: no-repeat; + opacity: 1; + filter: alpha(opacity=100); /* ie */ + -moz-opacity: 1; /* mozilla */ + +} diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb index 7a8f17e1..33b7dd75 100644 --- a/app/controllers/inventory/inventory_definitions_controller.rb +++ b/app/controllers/inventory/inventory_definitions_controller.rb @@ -25,7 +25,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController # POST /inventory_definitions.json def create @inventory_definition = InventoryDefinition.new(inventory_definition_params) - + @inventory_definition.created_by = current_user.id respond_to do |format| if @inventory_definition.save format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' } diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index 9ff9fce7..b47e716f 100644 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -2,6 +2,7 @@ class Inventory::StockChecksController < BaseInventoryController def index @check = StockCheck.new + @inventory_definitions = InventoryDefinition.active.all end def create diff --git a/app/views/inventory/inventory/_inventory_list.html.erb b/app/views/inventory/inventory/_inventory_list.html.erb index 115c80c5..e071f7ea 100644 --- a/app/views/inventory/inventory/_inventory_list.html.erb +++ b/app/views/inventory/inventory/_inventory_list.html.erb @@ -25,7 +25,7 @@ <%= item.item_code rescue ""%> <%= item.min_order_level %> <%= item.max_stock_level %> - <%= item.created_by%> + <%= item.created_by %> <%= item.created_at%> <% end %> diff --git a/app/views/inventory/inventory_definitions/_form.html.erb b/app/views/inventory/inventory_definitions/_form.html.erb index 66c073ad..3c96f21d 100644 --- a/app/views/inventory/inventory_definitions/_form.html.erb +++ b/app/views/inventory/inventory_definitions/_form.html.erb @@ -1,56 +1,83 @@ +<%= simple_form_for([:inventory, @inventory_definition]) do |f| %> + <%= f.error_notification %> -<%= simple_form_for([:inventory,@inventory_definition]) do |f| %> - <%= f.error_notification %> - -
- <%= f.input :item_code %> - -
- <% arr = MenuItem.active.order("name desc").pluck(:name,:item_code) %> - <% Product.order("name desc").pluck(:name,:item_code).each do |p| %> - <% arr.push(p) %> - <% end %> -
- - +
+
+ <% arr = MenuItem.active.order("name desc").pluck(:name, :item_code) %> + <% Product.order("name desc").pluck(:name, :item_code).each do |p| %> + <% arr.push(p) %> + <% end %> +
+ + +
+ <% sample = [] %> + <% if @inventory_definition.item_code.nil? %> + <% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %> + <% sample = MenuItemInstance.where("item_instance_code=?", @inventory_definition.item_code).pluck(:item_instance_name, :item_instance_code) %> + <% else %> + <% sample = Product.where("item_code=?", @inventory_definition.item_code).pluck(:name, :item_code) %> + <% end %> + <% end %> +
<%= f.input :item_code, collection: sample %>
- <% sample = [] %> - <% if @inventory_definition.item_code.nil? %> - <% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %> - <% sample = MenuItemInstance.where("item_instance_code=?",@inventory_definition.item_code).pluck(:item_instance_name,:item_instance_code)%> - <% else %> - <% sample = Product.where("item_code=?",@inventory_definition.item_code).pluck(:name,:item_code)%> - <% end %> - <% end %> -
<%= f.input :item_code, collection: sample %>
- -
<%= f.input :min_qty %>
+ <%= f.input :min_order_level %> + <%= f.input :max_stock_level %>
- <%= f.input :min_order_level %> - <%= f.input :max_stock_level %> -
- -
- <%= f.button :submit %> -
+
+ <%= f.button :submit %> +
<% end %> + + \ No newline at end of file diff --git a/app/views/inventory/stock_checks/index.html.erb b/app/views/inventory/stock_checks/index.html.erb index 812d4409..a6d33204 100644 --- a/app/views/inventory/stock_checks/index.html.erb +++ b/app/views/inventory/stock_checks/index.html.erb @@ -7,17 +7,23 @@
- -
+ +

- Product + Item
- +

@@ -27,14 +33,14 @@ Qty
- +

- +
@@ -47,6 +53,7 @@ # Product Balance + @@ -54,49 +61,58 @@
- +
diff --git a/app/views/layouts/_header_inventory.html.erb b/app/views/layouts/_header_inventory.html.erb new file mode 100644 index 00000000..17a8e764 --- /dev/null +++ b/app/views/layouts/_header_inventory.html.erb @@ -0,0 +1,38 @@ +
+
+
+ Inventory - +
+
+ <% if current_login_employee %> + <%= current_login_employee.name %> | <%= link_to 'Logout', logout_path, method: :delete, data: { confirm: 'Are you sure?' } %> + <% end %> +
+
+
+ +
diff --git a/app/views/layouts/inventory.html.erb b/app/views/layouts/inventory.html.erb index d6bbf436..8982d546 100644 --- a/app/views/layouts/inventory.html.erb +++ b/app/views/layouts/inventory.html.erb @@ -9,14 +9,14 @@ SmartSales : Restaurant <%= csrf_meta_tags %> - <%= stylesheet_link_tag 'origami', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag 'inventory_definitions', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <%= stylesheet_link_tag 'jquery-confirm', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'jquery-confirm', 'data-turbolinks-track': 'reload' %> - <%= render 'layouts/header_orgiami' %> + <%= render 'layouts/header_inventory' %>
<% flash.each do |type, message| %> <% if !flash["errors"]%> diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index adb297d1..66b8d4c0 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -32,3 +32,6 @@ Rails.application.config.assets.precompile += %w( jquery-confirm.js ) # --- Image Uploader ---- Rails.application.config.assets.precompile += %w( fileinput.min.js ) + +# --- Inventory Definition ---- +Rails.application.config.assets.precompile += %w( inventory_definitions.css ) From 784e740da3844422a3de4f38c3fd780b2b215b2d Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Wed, 6 Sep 2017 11:18:02 +0630 Subject: [PATCH 3/6] rename in_juty to in_duty --- .idea/workspace.xml | 683 ++++++++++-------- .../origami/in_duties_controller.rb | 170 +++++ .../origami/in_juties_controller.rb | 170 ----- app/helpers/origami/in_duties_helper.rb | 2 + app/helpers/origami/in_juties_helper.rb | 2 - app/models/{in_juty.rb => in_duty.rb} | 2 +- app/views/origami/home/show.html.erb | 6 +- .../_assign_in_duty.html.erb} | 0 .../_edit_in_duty.html.erb} | 2 +- .../{in_juties => in_duties}/_form.html.erb | 2 +- .../origami/in_duties/_in_duty.json.jbuilder | 2 + .../assign_in_duty.html.erb} | 20 +- .../{in_juties => in_duties}/edit.html.erb | 4 +- .../origami/in_duties/edit_in_duty.html.erb | 6 + .../{in_juties => in_duties}/index.html.erb | 46 +- .../origami/in_duties/index.json.jbuilder | 1 + .../index_in_duty.html.erb} | 48 +- .../{in_juties => in_duties}/new.html.erb | 4 +- .../{in_juties => in_duties}/show.html.erb | 18 +- .../origami/in_duties/show.json.jbuilder | 1 + .../origami/in_juties/_in_juty.json.jbuilder | 2 - .../origami/in_juties/edit_in_juty.html.erb | 6 - .../origami/in_juties/index.json.jbuilder | 1 - .../origami/in_juties/show.json.jbuilder | 1 - config/routes.rb | 16 +- ....rb => 20170823081748_create_in_duties.rb} | 6 +- ...r_spec.rb => in_duties_controller_spec.rb} | 4 +- .../{in_juty_spec.rb => in_duty_spec.rb} | 2 +- 28 files changed, 640 insertions(+), 587 deletions(-) create mode 100644 app/controllers/origami/in_duties_controller.rb delete mode 100644 app/controllers/origami/in_juties_controller.rb create mode 100644 app/helpers/origami/in_duties_helper.rb delete mode 100644 app/helpers/origami/in_juties_helper.rb rename app/models/{in_juty.rb => in_duty.rb} (78%) rename app/views/origami/{in_juties/_assign_in_juty.html.erb => in_duties/_assign_in_duty.html.erb} (100%) rename app/views/origami/{in_juties/_edit_in_juty.html.erb => in_duties/_edit_in_duty.html.erb} (87%) rename app/views/origami/{in_juties => in_duties}/_form.html.erb (95%) create mode 100644 app/views/origami/in_duties/_in_duty.json.jbuilder rename app/views/origami/{in_juties/assign_in_juty.html.erb => in_duties/assign_in_duty.html.erb} (76%) rename app/views/origami/{in_juties => in_duties}/edit.html.erb (61%) create mode 100644 app/views/origami/in_duties/edit_in_duty.html.erb rename app/views/origami/{in_juties => in_duties}/index.html.erb (54%) create mode 100644 app/views/origami/in_duties/index.json.jbuilder rename app/views/origami/{in_juties/index_in_juty.html.erb => in_duties/index_in_duty.html.erb} (58%) rename app/views/origami/{in_juties => in_duties}/new.html.erb (58%) rename app/views/origami/{in_juties => in_duties}/show.html.erb (59%) create mode 100644 app/views/origami/in_duties/show.json.jbuilder delete mode 100644 app/views/origami/in_juties/_in_juty.json.jbuilder delete mode 100644 app/views/origami/in_juties/edit_in_juty.html.erb delete mode 100644 app/views/origami/in_juties/index.json.jbuilder delete mode 100644 app/views/origami/in_juties/show.json.jbuilder rename db/migrate/{20170823081747_create_in_juties.rb => 20170823081748_create_in_duties.rb} (54%) rename spec/controllers/origami/{in_juties_controller_spec.rb => in_duties_controller_spec.rb} (97%) rename spec/models/{in_juty_spec.rb => in_duty_spec.rb} (68%) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 467886cf..3ddc5623 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,15 +2,28 @@ + + + + + + + + + + + + + + + + + + + - - - - - - - - + + @@ -25,7 +38,7 @@ - + @@ -54,68 +67,104 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - + + - - - + + + + + + + + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -124,40 +173,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -166,7 +181,7 @@ - + @@ -176,7 +191,7 @@ - + @@ -186,7 +201,7 @@ - + @@ -196,7 +211,7 @@ - + @@ -206,7 +221,7 @@ - + @@ -252,7 +267,19 @@ custom_excel load promotion_original_product + in_juti + Juty + Juti + Juties + juties + juty + + Duties + Duty + duty + duties + - @@ -946,6 +994,7 @@ + @@ -958,7 +1007,6 @@ - @@ -1023,196 +1071,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1290,7 +1148,7 @@ - + @@ -1315,7 +1173,7 @@ - + @@ -1333,7 +1191,7 @@ - + @@ -1341,7 +1199,7 @@ - + @@ -1357,7 +1215,7 @@ - + @@ -1365,7 +1223,7 @@ - + @@ -1381,7 +1239,7 @@ - + @@ -1389,18 +1247,16 @@ - + - - - - - + + + @@ -1436,10 +1292,205 @@ + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/controllers/origami/in_duties_controller.rb b/app/controllers/origami/in_duties_controller.rb new file mode 100644 index 00000000..eaf23c5a --- /dev/null +++ b/app/controllers/origami/in_duties_controller.rb @@ -0,0 +1,170 @@ +class Origami::InDutiesController < BaseOrigamiController + before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty] + + # GET /in_duties + # GET /in_duties.json + def index + @in_duties = InDuty.all + end + + def index_in_duty + @duty_in = InDuty.where('dinning_id=?', params[:table_id]) + @table = DiningFacility.find(params[:table_id]) + @in_duty = InDuty.new + @duties_in = Kaminari.paginate_array(@duty_in).page(params[:page]).per(10) + end + + # GET /in_duties/1 + # GET /in_duties/1.json + def show; end + + # GET /in_duties/new + def new + # this one use for new + @in_duty = InDuty.new + @table = DiningFacility.find(params[:table_id]) + @commissioner = @in_duty.commissioner + render partial: 'form' + end + + # GET /in_duties/1/edit + def edit; end + + def edit_in_duty + @in_duty = InDuty.find(params[:id]) + @table = DiningFacility.find(params[:table_id]) + @commissioner = @in_duty.commissioner + + # render json: {in_duty: @in_duty, commissioner: @commissioner} + render partial: 'form' + end + + def assign_in_duty + @in_duty = InDuty.new + @table = DiningFacility.find(params[:table_id]) + end + + # POST /in_duties + # POST /in_duties.json + def create + @in_duty = InDuty.new(in_duty_params) + + respond_to do |format| + if @in_duty.save + format.html { redirect_to origami_in_duties_path, notice: 'In duty was successfully created.' } + format.json { render :show, status: :created, location: @in_duty } + else + format.html { render :new } + format.json { render json: @in_duty.errors, status: :unprocessable_entity } + end + end + end + + def create_for_in_duty + # this one use for create and update + in_duty = in_duty_params + in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i + in_time = in_time.change(offset: '+06:30') + out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i + out_time = out_time.change(offset: '+06:30') + @in_duty = InDuty.new + in_duty_id = in_duty[:id] + unless in_duty_id.empty? + @in_duty = InDuty.find(in_duty_id.to_i) + end + + @in_duty.dinning_id = in_duty_params[:dinning_id] + @in_duty.commissioner_ids = in_duty_params[:commissioner_ids] + @in_duty.in_time = in_time + @in_duty.out_time = out_time + + respond_to do |format| + if @in_duty.save + if in_duty_id.nil? + format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully created.' } + format.json { render :show, status: :created, location: @in_duty } + else + format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' } + format.json { render :show, status: :created, location: @in_duty } + end + else + format.html { render :new } + format.json { render json: @in_duty.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /in_duties/1 + # PATCH/PUT /in_duties/1.json + def update + in_duty = in_duty_params + in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i + in_time = in_time.change(offset: '+06:30') + out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i + out_time = out_time.change(offset: '+06:30') + @in_duty.commissioner_ids = in_duty_params[:commissioner_ids] + @in_duty.in_time = in_time + @in_duty.out_time = out_time + respond_to do |format| + if @in_duty.save + format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' } + format.json { render :show, status: :ok, location: @in_duty } + else + format.html { render :edit } + format.json { render json: @in_duty.errors, status: :unprocessable_entity } + end + end + end + + def update_for_in_duty + in_duty = in_duty_params + in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i + in_time = in_time.change(offset: '+06:30') + out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i + out_time = out_time.change(offset: '+06:30') + @in_duty.commissioner_ids = in_duty_params[:commissioner_ids] + @in_duty.in_time = in_time + @in_duty.out_time = out_time + respond_to do |format| + if @in_duty.save + format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' } + format.json { render :show, status: :ok, location: @in_duty } + else + format.html { render :edit } + format.json { render json: @in_duty.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /in_duties/1 + # DELETE /in_duties/1.json + def destroy + @in_duty.destroy + respond_to do |format| + format.html { redirect_to origami_in_duties_path, notice: 'In duty was successfully removed.' } + format.json { head :no_content } + end + end + + def destroy_in_duty + @table_id = params[:table_id] + @in_duty.destroy + + respond_to do |format| + format.html { redirect_to origami_index_in_duty_path(@table_id), notice: 'In duty was successfully removed.' } + format.json { head :no_content } + end + end + + private + + # Use callbacks to share common setup or constraints between actions. + def set_in_duty + @in_duty = InDuty.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def in_duty_params + params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time) + end +end diff --git a/app/controllers/origami/in_juties_controller.rb b/app/controllers/origami/in_juties_controller.rb deleted file mode 100644 index d78ef348..00000000 --- a/app/controllers/origami/in_juties_controller.rb +++ /dev/null @@ -1,170 +0,0 @@ -class Origami::InJutiesController < BaseOrigamiController - before_action :set_in_juty, only: %i[show edit update edit_in_juty update_for_in_juty destroy destroy_in_juty] - - # GET /in_juties - # GET /in_juties.json - def index - @in_juties = InJuty.all - end - - def index_in_juty - @juty_in = InJuty.where('dinning_id=?', params[:table_id]) - @table = DiningFacility.find(params[:table_id]) - @in_juty = InJuty.new - @juties_in = Kaminari.paginate_array(@juty_in).page(params[:page]).per(10) - end - - # GET /in_juties/1 - # GET /in_juties/1.json - def show; end - - # GET /in_juties/new - def new - # this one use for new - @in_juty = InJuty.new - @table = DiningFacility.find(params[:table_id]) - @commissioner = @in_juty.commissioner - render partial: 'form' - end - - # GET /in_juties/1/edit - def edit; end - - def edit_in_juty - @in_juty = InJuty.find(params[:id]) - @table = DiningFacility.find(params[:table_id]) - @commissioner = @in_juty.commissioner - - # render json: {in_juty: @in_juty, commissioner: @commissioner} - render partial: 'form' - 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 - @in_juty = InJuty.new(in_juty_params) - - respond_to do |format| - if @in_juty.save - 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 } - format.json { render json: @in_juty.errors, status: :unprocessable_entity } - end - end - end - - def create_for_in_juty - # this one use for create and update - in_juty = in_juty_params - in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i - in_time = in_time.change(offset: '+06:30') - out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i - out_time = out_time.change(offset: '+06:30') - @in_juty = InJuty.new - in_juty_id = in_juty[:id] - unless in_juty_id.empty? - @in_juty = InJuty.find(in_juty_id.to_i) - end - - @in_juty.dinning_id = in_juty_params[:dinning_id] - @in_juty.commissioner_ids = in_juty_params[:commissioner_ids] - @in_juty.in_time = in_time - @in_juty.out_time = out_time - - respond_to do |format| - if @in_juty.save - if in_juty_id.nil? - format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully created.' } - format.json { render :show, status: :created, location: @in_juty } - else - format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' } - format.json { render :show, status: :created, location: @in_juty } - end - else - format.html { render :new } - format.json { render json: @in_juty.errors, status: :unprocessable_entity } - end - end - end - - # PATCH/PUT /in_juties/1 - # PATCH/PUT /in_juties/1.json - def update - in_juty = in_juty_params - in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i - in_time = in_time.change(offset: '+06:30') - out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i - out_time = out_time.change(offset: '+06:30') - @in_juty.commissioner_ids = in_juty_params[:commissioner_ids] - @in_juty.in_time = in_time - @in_juty.out_time = out_time - respond_to do |format| - if @in_juty.save - format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' } - format.json { render :show, status: :ok, location: @in_juty } - else - format.html { render :edit } - format.json { render json: @in_juty.errors, status: :unprocessable_entity } - end - end - end - - def update_for_in_juty - in_juty = in_juty_params - in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i - in_time = in_time.change(offset: '+06:30') - out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i - out_time = out_time.change(offset: '+06:30') - @in_juty.commissioner_ids = in_juty_params[:commissioner_ids] - @in_juty.in_time = in_time - @in_juty.out_time = out_time - respond_to do |format| - if @in_juty.save - format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' } - format.json { render :show, status: :ok, location: @in_juty } - else - format.html { render :edit } - format.json { render json: @in_juty.errors, status: :unprocessable_entity } - end - end - end - - # DELETE /in_juties/1 - # DELETE /in_juties/1.json - def destroy - @in_juty.destroy - respond_to do |format| - format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully removed.' } - format.json { head :no_content } - end - end - - def destroy_in_juty - @table_id = params[:table_id] - @in_juty.destroy - - respond_to do |format| - format.html { redirect_to origami_index_in_juty_path(@table_id), notice: 'In juty was successfully removed.' } - format.json { head :no_content } - end - end - - private - - # Use callbacks to share common setup or constraints between actions. - def set_in_juty - @in_juty = InJuty.find(params[:id]) - end - - # Never trust parameters from the scary internet, only allow the white list through. - def in_juty_params - params.require(:in_juty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time) - end -end diff --git a/app/helpers/origami/in_duties_helper.rb b/app/helpers/origami/in_duties_helper.rb new file mode 100644 index 00000000..afd35e07 --- /dev/null +++ b/app/helpers/origami/in_duties_helper.rb @@ -0,0 +1,2 @@ +module Origami::InDutiesHelper +end diff --git a/app/helpers/origami/in_juties_helper.rb b/app/helpers/origami/in_juties_helper.rb deleted file mode 100644 index 2792da8d..00000000 --- a/app/helpers/origami/in_juties_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Origami::InJutiesHelper -end diff --git a/app/models/in_juty.rb b/app/models/in_duty.rb similarity index 78% rename from app/models/in_juty.rb rename to app/models/in_duty.rb index 2f023ff0..485787c7 100644 --- a/app/models/in_juty.rb +++ b/app/models/in_duty.rb @@ -1,4 +1,4 @@ -class InJuty < ApplicationRecord +class InDuty < ApplicationRecord belongs_to :dining_facility, foreign_key: 'dinning_id' belongs_to :commissioner, foreign_key: 'commissioner_ids' end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 680894ff..c0fd2ff5 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -333,7 +333,7 @@ - + @@ -580,9 +580,9 @@ window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/load_commissioners"; }); - $('#in_juties').on('click', function () { + $('#in_duties').on('click', function () { var dining_id = "<%= @dining.id %>" - window.location.href = '/origami/assign_in_juty/'+ dining_id; + window.location.href = '/origami/assign_in_duty/'+ dining_id; }); $('#void').on('click', function () { diff --git a/app/views/origami/in_juties/_assign_in_juty.html.erb b/app/views/origami/in_duties/_assign_in_duty.html.erb similarity index 100% rename from app/views/origami/in_juties/_assign_in_juty.html.erb rename to app/views/origami/in_duties/_assign_in_duty.html.erb diff --git a/app/views/origami/in_juties/_edit_in_juty.html.erb b/app/views/origami/in_duties/_edit_in_duty.html.erb similarity index 87% rename from app/views/origami/in_juties/_edit_in_juty.html.erb rename to app/views/origami/in_duties/_edit_in_duty.html.erb index a297ac65..41a492eb 100644 --- a/app/views/origami/in_juties/_edit_in_juty.html.erb +++ b/app/views/origami/in_duties/_edit_in_duty.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for([:origami, @in_juty]) do |f| %> +<%= simple_form_for([:origami, @in_duty]) do |f| %> <%= f.error_notification %>
diff --git a/app/views/origami/in_juties/_form.html.erb b/app/views/origami/in_duties/_form.html.erb similarity index 95% rename from app/views/origami/in_juties/_form.html.erb rename to app/views/origami/in_duties/_form.html.erb index 61342d7b..3351dbd3 100644 --- a/app/views/origami/in_juties/_form.html.erb +++ b/app/views/origami/in_duties/_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for @in_juty, :url => origami_index_in_juty_path(@table.id), :method => :post do |f| %> +<%= simple_form_for @in_duty, :url => origami_index_in_duty_path(@table.id), :method => :post do |f| %> <%= f.error_notification %> <%= f.hidden_field :id, :class => "form-control col-md-6 " %> diff --git a/app/views/origami/in_duties/_in_duty.json.jbuilder b/app/views/origami/in_duties/_in_duty.json.jbuilder new file mode 100644 index 00000000..6b13c2f9 --- /dev/null +++ b/app/views/origami/in_duties/_in_duty.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! in_duty, :id, :created_at, :updated_at +json.url in_duty_url(in_duty, format: :json) diff --git a/app/views/origami/in_juties/assign_in_juty.html.erb b/app/views/origami/in_duties/assign_in_duty.html.erb similarity index 76% rename from app/views/origami/in_juties/assign_in_juty.html.erb rename to app/views/origami/in_duties/assign_in_duty.html.erb index 7176dea6..31e95a50 100644 --- a/app/views/origami/in_juties/assign_in_juty.html.erb +++ b/app/views/origami/in_duties/assign_in_duty.html.erb @@ -1,9 +1,9 @@
- <%= simple_form_for([:origami,@in_juty]) do |f| %> + <%= simple_form_for([:origami,@in_duty]) do |f| %> <%= f.error_notification %>
@@ -22,10 +22,10 @@
- <%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %> + <%= link_to 'Back', origami_index_in_duty_path(@table.id), class: 'btn btn-success' %>
- +
@@ -45,18 +45,18 @@ $(function() { $('.datepicker').css('cursor','pointer'); }); - $('#in_juty').on('click', function () { - var ajax_url = "/origami/assign_in_juty"; - var commissioner_ids = $('#in_juty_commissioner_ids').val(); - var in_time = $('#in_juty_in_time').val(); - var out_time = $('#in_juty_out_time').val(); + $('#in_duty').on('click', function () { + var ajax_url = "/origami/assign_in_duty"; + var commissioner_ids = $('#in_duty_commissioner_ids').val(); + var in_time = $('#in_duty_in_time').val(); + var out_time = $('#in_duty_out_time').val(); var dining_id = '<%= @table.id %>' $.ajax({ type: "POST", url: ajax_url, data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time, success: function (result) { - window.location.href = '/origami/assign_in_juty/'+ dining_id; + window.location.href = '/origami/assign_in_duty/'+ dining_id; } }); }) diff --git a/app/views/origami/in_juties/edit.html.erb b/app/views/origami/in_duties/edit.html.erb similarity index 61% rename from app/views/origami/in_juties/edit.html.erb rename to app/views/origami/in_duties/edit.html.erb index 3a6fc774..3e64b2f2 100644 --- a/app/views/origami/in_juties/edit.html.erb +++ b/app/views/origami/in_duties/edit.html.erb @@ -2,9 +2,9 @@ - <%= render 'form', in_juty: @in_juty %> + <%= render 'form', in_duty: @in_duty %>
\ No newline at end of file diff --git a/app/views/origami/in_duties/edit_in_duty.html.erb b/app/views/origami/in_duties/edit_in_duty.html.erb new file mode 100644 index 00000000..bcc984aa --- /dev/null +++ b/app/views/origami/in_duties/edit_in_duty.html.erb @@ -0,0 +1,6 @@ +
+ + <%= render 'edit_in_duty', in_duty: @in_duty %> +
\ No newline at end of file diff --git a/app/views/origami/in_juties/index.html.erb b/app/views/origami/in_duties/index.html.erb similarity index 54% rename from app/views/origami/in_juties/index.html.erb rename to app/views/origami/in_duties/index.html.erb index ff5a0fd3..355a7afb 100644 --- a/app/views/origami/in_juties/index.html.erb +++ b/app/views/origami/in_duties/index.html.erb @@ -14,27 +14,27 @@ - <% @juties_in.each do |in_juty| %> - + <% @duties_in.each do |in_duty| %> + - <%= 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 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id, in_juty), method: :delete, data: {confirm: 'Are you sure?'} %> + <%= in_duty.dining_facility.name rescue '-' %> + <%= in_duty.commissioner.name rescue '-' %> + <%= in_duty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> + <%= in_duty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> + <%= link_to 'Destroy', origami_destroy_in_duty_path(in_duty.dining_facility.id, in_duty), method: :delete, data: {confirm: 'Are you sure?'} %> <% end %> - <%= paginate @juties_in %> + <%= paginate @duties_in %>
- <%= render 'form', in_juty: @in_juty, table: @table %> + <%= render 'form', in_duty: @in_duty, table: @table %>
- <%= link_to t('.new', :default => t("helpers.links.new")), new_origami_in_juty_path, :class => 'btn btn-primary btn-sm' %> + <%= link_to t('.new', :default => t("helpers.links.new")), new_origami_in_duty_path, :class => 'btn btn-primary btn-sm' %>
@@ -43,13 +43,13 @@
diff --git a/config/routes.rb b/config/routes.rb index 8dcdb956..18f3c0b5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -299,6 +299,7 @@ Rails.application.routes.draw do resources :promotion_products end get '/find_item_instance' => 'promotions#find_item_instance', as:'find_item_instance' + get '/find_parent_item' => 'promotions#find_parent_item', as:'find_parent_item' # commission resources :commissions From 9d4741429252894d6aec0a593071a67d67c5d18d Mon Sep 17 00:00:00 2001 From: Phyo Date: Wed, 6 Sep 2017 18:03:53 +0630 Subject: [PATCH 5/6] Timepicker Bug Fix --- app/views/settings/promotions/_form.html.erb | 30 ++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/app/views/settings/promotions/_form.html.erb b/app/views/settings/promotions/_form.html.erb index 477731a1..1760f894 100644 --- a/app/views/settings/promotions/_form.html.erb +++ b/app/views/settings/promotions/_form.html.erb @@ -42,14 +42,14 @@
- <%= f.hidden_field :promo_day, :value => "", :class => "form-control" %> -
Sun
-
Mon
-
Tue
-
Wed
-
Thu
-
Fri
-
Sat
+ <%= f.hidden_field :promo_day, :class => "form-control" %> +
+
+
+
+
+
+

@@ -168,6 +168,19 @@ $(document).ready(function(){ format:'H:m' }); + $('#promotion_promo_start_hour').on('change', function(event) { + $('#promotion_promo_start_hour').val($('#promotion_promo_start_hour').val().split(":")[0]+":00"); + }); + + $('#promotion_promo_end_hour').on('change', function(event) { + $('#promotion_promo_end_hour').val($('#promotion_promo_end_hour').val().split(":")[0]+":00"); + }); + + var dayy = $("#promotion_promo_day").val().replace("[","").replace("]",""); + jQuery.each( dayy.split(","), function( i, d ) { + $("input.selectDay[value='"+d+"']").prop( "checked", true ); + }); + var form = document.getElementById("new_promotion"); var inputs = $("input"); var arr = []; @@ -227,6 +240,7 @@ $(".selectDay").click(function() { }, 0); }); + // for promotion products data showing var promopdt = $(".promo_product"); jQuery.each( promopdt, function( i, ppdt ) { var ajax_url = "<%= settings_find_parent_item_path %>"; From 5e1e0cd5b96d6db6dbb3997e79670780dc0bc6b8 Mon Sep 17 00:00:00 2001 From: Zin Lin Phyo Date: Wed, 6 Sep 2017 18:27:58 +0630 Subject: [PATCH 6/6] stock_check report template --- .idea/workspace.xml | 1015 +++++++---------- .../inventory/stock_checks_controller.rb | 146 ++- .../reports/stock_check_controller.rb | 50 + app/models/menu_item_instance.rb | 14 +- app/models/stock_check.rb | 2 +- app/pdf/stock_result_pdf.rb | 90 +- .../inventory/_inventory_list.html.erb | 14 +- app/views/inventory/inventory/index.html.erb | 31 +- .../inventory_definitions/_form.html.erb | 3 +- .../inventory_definitions/edit.html.erb | 16 +- .../inventory/stock_checks/index.html.erb | 35 +- .../inventory/stock_checks/show.html.erb | 117 +- .../_stock_check_report_filter.html.erb | 89 ++ app/views/reports/stock_check/index.html.erb | 79 ++ app/views/reports/stock_check/index.xls.erb | 52 + config/routes.rb | 1 + 16 files changed, 940 insertions(+), 814 deletions(-) create mode 100644 app/controllers/reports/stock_check_controller.rb create mode 100644 app/views/reports/stock_check/_stock_check_report_filter.html.erb create mode 100644 app/views/reports/stock_check/index.html.erb create mode 100644 app/views/reports/stock_check/index.xls.erb diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3ddc5623..74609c4e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,27 +2,17 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + @@ -38,7 +28,7 @@ - + @@ -64,187 +54,111 @@ <% @inventory_definitions.each do |id| %> - <% item_name = MenuItemInstance.find_by_item_instance_code(id.item_code) %> - + <% end %>
@@ -50,7 +56,7 @@
- + @@ -61,6 +67,7 @@
+
@@ -80,13 +87,13 @@ count += 1; product_sku = $('#product_sku').val(); product_qty = $('#product_qty').val(); - product_name = $("#product_sku option:selected").text(); + product_name = $("#product_sku").find("option:selected").text(); var tr = '' - + '' + //+ '' + '' + + product_name + '' + '' - + '' + + '' + ''; $('#stock_item').append(tr); // $('#product_sku').val(''); @@ -101,7 +108,9 @@ for (var i = 1; i <= count; i++) { itemname = $('#item_sku_' + i).val(); itemqty = $('#item_qty_' + i).val(); - arr.push({sku: itemname, qty: itemqty}); + if(itemname !== undefined){ + arr.push({sku: itemname, qty: itemqty}); + } jsonStr = JSON.stringify(arr); } console.log(jsonStr); @@ -113,6 +122,14 @@ window.location.href = '/inventory/stock_checks/' + data['stock_id']; } }) - }) + }); + + $('#back').on('click', function () { + window.location.href = '/inventory'; + }); + + function remove_row(row) { + $("#item_remove_"+row).parent().parent().remove(); + } diff --git a/app/views/inventory/stock_checks/show.html.erb b/app/views/inventory/stock_checks/show.html.erb index 4d0e83d0..f4af6db0 100644 --- a/app/views/inventory/stock_checks/show.html.erb +++ b/app/views/inventory/stock_checks/show.html.erb @@ -3,81 +3,96 @@
- Check by + Check by
- <%= @check.check_by %> + <%= Employee.find(@check.check_by).name rescue '' %>
- Check At + Check At
- <%= @check.created_at %>
+ <%= @check.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %>
- Reason + Reason
- <%= @check.reason %> + <%= @check.reason %>

-
# Product Balance
' + count + '' + count + '' - + '
- - - - - - - - - <% - count = 0 - @check.stock_check_items.each do |item| - count += 1 - %> +
#ProductStock CountStock BalanceDifferentRemark
- - - - - - + + + + + + - <% end %> -
<%= count %><%= item.item_code %><%= item.stock_count %><%= item.stock_balance %><%= item.different %><%= item.remark %>#ProductStock CountStock BalanceDifferentRemark
+ <% + count = 0 + @check.stock_check_items.each do |item| + count += 1 + %> + + <%= count %> + + <% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%> + <% if menu_item.nil? %> + <%= Product.find_by_item_code(item.item_code).name rescue "-" %> + <% else %> + <%= menu_item.menu_item.name rescue "-" %> + - <%= menu_item.item_instance_name rescue "-" %> + <% end %> + + <%= item.stock_count %> + <%= item.stock_balance %> + <%= item.different %> + <%= item.remark %> + + <% end %> + +
-
- - - + + +
diff --git a/app/views/reports/stock_check/_stock_check_report_filter.html.erb b/app/views/reports/stock_check/_stock_check_report_filter.html.erb new file mode 100644 index 00000000..1bd00b7b --- /dev/null +++ b/app/views/reports/stock_check/_stock_check_report_filter.html.erb @@ -0,0 +1,89 @@ +
+
+ <%= form_tag report_path, :method => :get, :id => "frm_report", :class => "form" do %> + <% if period_type != false %> +
+ +
+ + <% if @daterange %> + + <% else %> + + <% end %> +
+
+ + +
+
+ +
+
+ +
+
+ <% end %> + + <% end %> +
+
+ + diff --git a/app/views/reports/stock_check/index.html.erb b/app/views/reports/stock_check/index.html.erb new file mode 100644 index 00000000..07008de8 --- /dev/null +++ b/app/views/reports/stock_check/index.html.erb @@ -0,0 +1,79 @@ + + +
+ <%= render :partial => 'stock_check_report_filter', + :locals => {:period_type => true, :shift_name => true, :report_path => reports_stock_check_index_path} %> +
+
+ +
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + <% total_qty = 0 %> + <% total_price = 0 %> + <% total_amount = 0 %> + + <% @transaction.each do |result| %> + + + + + + + + + + + <% total_qty += result.qty.to_f %> + <% total_price += result.price.to_f %> + <% total_amount += result.amount.to_f %> + <% end %> + + + + + + + + + +
From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
SaleSale ItemCommissioner NameProduct NameQtyCommission PriceCommission AmountDate
<%= result.sale_id rescue '-' %><%= result.sale_item_id rescue '-' %><%= result.commissioner.name rescue '-' %><%= result.commission.menu_item.name rescue '-' %><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %>
<%= sprintf("%.2f", total_qty) rescue '-' %><%= sprintf("%.2f", total_price) rescue '-' %><%= sprintf("%.2f", total_amount) rescue '-' %>
+
+
+
+ \ No newline at end of file diff --git a/app/views/reports/stock_check/index.xls.erb b/app/views/reports/stock_check/index.xls.erb new file mode 100644 index 00000000..4ea1f2f0 --- /dev/null +++ b/app/views/reports/stock_check/index.xls.erb @@ -0,0 +1,52 @@ +
+
+
+ + + + + + + + + + + + + + + + <% total_qty = 0 %> + <% total_price = 0 %> + <% total_amount = 0 %> + + <% @transaction.each do |result| %> + + + + + + + + + <% total_qty += result.qty.to_f %> + <% total_price += result.price.to_f %> + <% total_amount += result.amount.to_f %> + <% end %> + + + + + + + + + +
From Date : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - To Date : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
Commissioner NameProduct NameQtyCommission PriceCommission AmountDate
+ <%= result.commissioner.name rescue '-' %> + + <%= result.commission.menu_item.name rescue '-' %> + <%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %><%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %>
<%= sprintf("%.2f", total_qty) rescue '-' %><%= sprintf("%.2f", total_price) rescue '-' %><%= sprintf("%.2f", total_amount) rescue '-' %>
+
+
+
diff --git a/config/routes.rb b/config/routes.rb index 226b7dd5..e979ac5d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -328,6 +328,7 @@ Rails.application.routes.draw do resources :credit_payment, :only => [:index, :show] resources :void_sale, :only => [:index, :show] resources :commission, :only => [:index, :show] + resources :stock_check, :only => [:index, :show] get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date" end