-
-
-
+
+
@@ -189,13 +173,8 @@
-
-
-
-
-
@@ -232,14 +211,19 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -266,8 +250,8 @@
-
-
+
+
@@ -312,14 +296,22 @@
-
-
+
+
+
+
+
+
+
+
+
+
@@ -336,6 +328,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -741,12 +756,12 @@
-
+
-
+
@@ -759,18 +774,19 @@
+
-
+
-
+
-
+
@@ -788,54 +804,11 @@
-
-
- file://$PROJECT_DIR$/app/controllers/reports/commission_controller.rb
- 4
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -860,14 +833,6 @@
-
-
-
-
-
-
-
-
@@ -1030,14 +995,6 @@
-
-
-
-
-
-
-
-
@@ -1054,14 +1011,6 @@
-
-
-
-
-
-
-
-
@@ -1126,26 +1075,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -1160,14 +1093,6 @@
-
-
-
-
-
-
-
-
@@ -1176,28 +1101,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -1205,5 +1111,113 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index 91e29a6e..93b245eb 100644
--- a/Gemfile
+++ b/Gemfile
@@ -34,7 +34,7 @@ gem 'simple_form'
gem 'nested_form'
gem 'bootstrap', '~> 4.0.0.alpha3'
gem 'tether-rails'
-gem "font-awesome-rails"
+gem 'font-awesome-rails', '~> 4.7', '>= 4.7.0.2'
gem 'rack-cors'
# image upload
@@ -53,7 +53,6 @@ gem 'to_xls-rails'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
-gem 'jquery-datatables-rails', '~> 3.4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
@@ -112,13 +111,8 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'httparty', '~> 0.15.5'
-gem 'momentjs-rails', :git => 'git://github.com/derekprior/momentjs-rails.git'
-gem 'bootstrap-daterangepicker-rails'
-# # gem 'momentjs-rails', '>= 2.9.0'
-# gem 'bootstrap3-datetimepicker-rails'
-# gem 'momentjs-rails', '>= 2.9.0'
-# gem 'bootstrap3-datetimepicker-rails'
-gem 'datetimepicker-rails', github: 'zpaulovics/datetimepicker-rails', branch: 'master', submodules: true
-gem 'bootstrap-datepicker-rails'
+gem 'momentjs-rails' # for date-range selector
+gem 'bootstrap-daterangepicker-rails' # date-range picker
+gem 'bootstrap-datepicker-rails' # date picker
gem 'jquery-datetimepicker-rails'
-gem 'select2-rails'
+gem 'select2-rails' # for multi-select and auto-complete select box
diff --git a/Gemfile.lock b/Gemfile.lock
index b567932e..b2a6e59c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,19 +1,3 @@
-GIT
- remote: git://github.com/derekprior/momentjs-rails.git
- revision: ea58a20b7b2c901831dd01f34e0054ef6c75bde8
- specs:
- momentjs-rails (2.17.1)
- railties (>= 3.1)
-
-GIT
- remote: https://github.com/zpaulovics/datetimepicker-rails.git
- revision: 36d21cec5da7f5b214925804f60e63c61c747023
- branch: master
- submodules: true
- specs:
- datetimepicker-rails (4.7.16)
- momentjs-rails (>= 2.9.0)
-
GEM
remote: https://rubygems.org/
specs:
@@ -107,11 +91,6 @@ GEM
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
- jquery-datatables-rails (3.4.0)
- actionpack (>= 3.1)
- jquery-rails
- railties (>= 3.1)
- sass-rails
jquery-datetimepicker-rails (2.4.1.0)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
@@ -144,6 +123,8 @@ GEM
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0)
minitest (5.10.3)
+ momentjs-rails (2.17.1)
+ railties (>= 3.1)
multi_json (1.12.1)
multi_xml (0.6.0)
mysql2 (0.4.6)
@@ -286,20 +267,18 @@ DEPENDENCIES
coffee-rails (~> 4.2)
cups (~> 0.0.7)
database_cleaner
- datetimepicker-rails!
factory_girl_rails (~> 4.0)
faker
filterrific
- font-awesome-rails
+ font-awesome-rails (~> 4.7, >= 4.7.0.2)
httparty (~> 0.15.5)
jbuilder (~> 2.5)
- jquery-datatables-rails (~> 3.4.0)
jquery-datetimepicker-rails
jquery-rails
jquery-ui-rails
kaminari (~> 1.0.1)
listen (~> 3.0.5)
- momentjs-rails!
+ momentjs-rails
mysql2 (>= 0.3.18, < 0.5)
nested_form
pg
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 87ca5d6d..b1879bba 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -20,13 +20,10 @@
//= require settings/processing_items
//= require jquery-ui
//= require bootstrap-datepicker
-//= require jquery.datetimepicker
-//= require dataTables/jquery.dataTables
//= require moment
//= require daterangepicker
//= require select2
-//= require bootstrap-datetimepicker
-//= require pickers
+//= require jquery.datetimepicker
$(document).on('turbolinks:load', function() {
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index 1cc201dd..4aabe81b 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -4,11 +4,9 @@
@import "theme";
@import "jquery-ui";
@import "bootstrap-datepicker3";
-@import "jquery.datetimepicker";
-@import "dataTables/jquery.dataTables";
@import "daterangepicker-bs3";
@import "select2";
-@import "bootstrap-datetimepicker";
+@import "jquery.datetimepicker";
/* Show it is fixed to the top */
// body {
diff --git a/app/controllers/origami/in_juties_controller.rb b/app/controllers/origami/in_juties_controller.rb
index 5903ace3..6ac04659 100644
--- a/app/controllers/origami/in_juties_controller.rb
+++ b/app/controllers/origami/in_juties_controller.rb
@@ -12,7 +12,6 @@ class Origami::InJutiesController < BaseOrigamiController
@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
@@ -60,10 +59,10 @@ class Origami::InJutiesController < BaseOrigamiController
def create_for_in_juty
@in_juty = InJuty.new
- @in_juty.dinning_id = in_juty_params[:dinning_id]
- @in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
- @in_juty.in_time = in_juty_params[:in_time]
- @in_juty.out_time = in_juty_params[:out_time]
+ @in_juty.dinning_id = in_juty_params[:dinning_id]
+ @in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
+ @in_juty.in_time = in_juty_params[:in_time]
+ @in_juty.out_time = in_juty_params[:out_time]
respond_to do |format|
@@ -75,7 +74,7 @@ class Origami::InJutiesController < BaseOrigamiController
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
-
+
end
# PATCH/PUT /in_juties/1
@@ -93,9 +92,9 @@ class Origami::InJutiesController < BaseOrigamiController
end
- def update_for_in_juty
- @in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
- @in_juty.in_time = in_juty_params[:in_time]
+ def update_for_in_juty
+ @in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
+ @in_juty.in_time = in_juty_params[:in_time]
@in_juty.out_time = in_juty_params[:out_time]
respond_to do |format|
if @in_juty.save
@@ -121,7 +120,7 @@ class Origami::InJutiesController < BaseOrigamiController
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 destroyed.' }
format.json { head :no_content }
diff --git a/app/controllers/reports/commission_controller.rb b/app/controllers/reports/commission_controller.rb
index df484589..98f98457 100644
--- a/app/controllers/reports/commission_controller.rb
+++ b/app/controllers/reports/commission_controller.rb
@@ -2,9 +2,15 @@ class Reports::CommissionController < BaseReportController
# authorize_resource :class => false
def index
- from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
- to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
+ from_date = DateTime.now.beginning_of_day.utc.getlocal
+ to_date = DateTime.now.end_of_day.utc.getlocal
+ unless params[:daterange].blank?
+ from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
+ to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
+ @daterange = params[:daterange]
+ end
commissioner = params[:commissioner].to_i
+ @com_id = commissioner
@commissioner = Commissioner.active.all
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
diff --git a/app/models/promotion.rb b/app/models/promotion.rb
index dfcfc105..d60f25a9 100644
--- a/app/models/promotion.rb
+++ b/app/models/promotion.rb
@@ -28,7 +28,8 @@ class Promotion < ApplicationRecord
end
def self.combine_item(saleObj)
- itemList = saleObj.sale_items.group(:product_code).sum(:qty)
+ order_id = saleObj.sale_orders[0].order_id
+ itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty)
end
def self.is_promo_day(promoList, day, orderitemList, sale_id)
@@ -44,7 +45,8 @@ class Promotion < ApplicationRecord
end
def self.find_promo_item(promo, orderitem, sale_id)
- if promo.original_product.to_s == orderitem[0].to_s
+ item_code = OrderItem.find_by_item_instance_code(orderitem[0]).item_code
+ if promo.original_product.to_s == item_code
if promo.min_qty.to_i > orderitem[1].to_i
return false
else
@@ -75,7 +77,7 @@ class Promotion < ApplicationRecord
def self.check_giveaway_product(promo, orderitem)
promo.promotion_products.each do |promo_product|
- if promo_product.item_code == orderitem
+ if promo_product.item_code == OrderItem.find_by_item_instance_code(orderitem).item_code
return true, promo_product
else
return false, promo_product
@@ -110,7 +112,13 @@ class Promotion < ApplicationRecord
else
charge_qty += qty
end
- item = OrderItem.find_by_item_code(orderitem[0])
+ item = OrderItem.find_by_item_instance_code(orderitem[0])
+ byebug
+ # if promo_product == OrderItem.find_by_item_instance_code(orderitem[0]).item_code
+ # item = OrderItem.find_by_item_instance_code(orderitem[0])
+ # else
+ # item = OrderItem.find_by_item_code(promo_product)
+ # end
update_existing_item(foc_qty, item, sale_id, "promotion", item.price)
puts "Charged - " + charge_qty.to_s
@@ -124,7 +132,7 @@ class Promotion < ApplicationRecord
if (foc_qty < promotion_qty)
promotion_qty = foc_qty
end
- item = OrderItem.find_by_item_code(promo_product)
+ item = OrderItem.find_by_item_instance_code(promo_product,orderID)
update_existing_item(promotion_qty, item, sale_id, "promotion", item.price)
end
@@ -156,11 +164,11 @@ class Promotion < ApplicationRecord
if same
foc_qty = orderitem[1].to_i / foc_min_qty
- item = OrderItem.find_by_item_code(orderitem[0])
+ item = OrderItem.find_by_item_instance_code(orderitem[0])
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off)
else
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
- item = OrderItem.find_by_item_code(promo_product.item_code)
+ item = OrderItem.find_by_item_instance_code(promo_product.item_code)
update_existing_item(foc_qty, item, sale_id, "promotion nett off", promo_product.net_off)
end
end
@@ -170,12 +178,12 @@ class Promotion < ApplicationRecord
if same
foc_qty = orderitem[1].to_i / foc_min_qty
- item = OrderItem.find_by_item_code(orderitem[0]) # need to specify with menu item instance
+ item = OrderItem.find_by_item_instance_code(orderitem[0]) # need to specify with menu item instance
price = item.price.to_i - promo_product.net_price.to_i
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price)
else
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
- item = OrderItem.find_by_item_code(promo_product.item_code)
+ item = OrderItem.find_by_item_instance_code(promo_product.item_code)
price = item.price - promo_product.net_price
update_existing_item(foc_qty, item, sale_id, "promotion nett price", price)
end
@@ -186,14 +194,14 @@ class Promotion < ApplicationRecord
if same
foc_qty = orderitem[1].to_i / foc_min_qty
- item = OrderItem.find_by_item_code(orderitem[0])
+ item = OrderItem.find_by_item_instance_code(orderitem[0])
# total = orderitem[1].to_i * item.price
total = item.price
price = calculate_discount(total, promo_product.percentage)
update_existing_item(foc_qty, item, sale_id, "promotion discount", price)
else
foc_qty = find_second_item_qty(sale_id, promo_product.item_code)
- item = OrderItem.find_by_item_code(promo_product.item_code)
+ item = OrderItem.find_by_item_instance_code(promo_product.item_code)
# total = item.price * foc_qty
total = item.price
price = calculate_discount(total, promo_product.percentage)
@@ -205,7 +213,7 @@ class Promotion < ApplicationRecord
saleObj = Sale.find_by_sale_id(sale_id)
itemList = combine_item(saleObj)
itemList.each do |item|
- if item[0] == promo_item
+ if OrderItem.find_by_item_instance_code(item[0]).item_code == promo_item
return item[1]
end
end
diff --git a/app/views/origami/in_juties/_assign_in_juty.html.erb b/app/views/origami/in_juties/_assign_in_juty.html.erb
index 81af7d29..62531529 100644
--- a/app/views/origami/in_juties/_assign_in_juty.html.erb
+++ b/app/views/origami/in_juties/_assign_in_juty.html.erb
@@ -1,46 +1,43 @@
-<%= simple_form_for @in_juty,:url => origami_index_in_juty_path(@table.id), :method => :post do |f| %>
-
- <%= f.error_notification %>
- <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
-
-
+<%= simple_form_for @in_juty, :url => origami_index_in_juty_path(@table.id), :method => :post do |f| %>
+
+ <%= f.error_notification %>
+ <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
- <%= f.hidden_field :dinning_id,:value => @table.id, :class => "form-control col-md-6 " %>
+
+
+ <%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %>
+
+ Dining Name:
+ <%= @table.name %>
+
+
+
+ Commissioner Name:
+ <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>
+
+
+ <%= f.input :in_time, :placeholder => "From Date", :class => "form-control" %>
+
+ <%= f.input :out_time, :placeholder => "From Date", :class => "form-control" %>
+
+
+
+
+ <%= f.button :submit, "Create", :class => 'btn btn-primary ', :id => 'create' %>
+ <%= f.button :submit, "Update", :class => 'btn btn-primary ', :disabled => '', :id => 'update' %>
+ <%= f.button :button, "Reset", :class => 'btn btn-danger ', :id => 'reset' %>
+
-
Dining Name:
- <%= @table.name %>
-
-
-
-
Commissioner Name:
- <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>
-
- <%= f.input :in_time, :placeholder => "From Date" , :class => "form-control", :as => :datetime_picker%>
-
- <%= f.input :out_time, :placeholder => "From Date" , :class => "form-control", :as => :datetime_picker%>
-
-
-
- <%= f.button :submit, "Create",:class => 'btn btn-primary ', :id => 'create' %>
- <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update' %>
- <%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
-
-
<% end %>
\ No newline at end of file
+
diff --git a/app/views/origami/in_juties/index_in_juty.html.erb b/app/views/origami/in_juties/index_in_juty.html.erb
index 2ac1048e..bbb9912b 100644
--- a/app/views/origami/in_juties/index_in_juty.html.erb
+++ b/app/views/origami/in_juties/index_in_juty.html.erb
@@ -1,5 +1,5 @@
-
+
@@ -16,74 +16,67 @@
<% @juties_in.each do |in_juty| %>
-
-
+
+
<%= 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?'} %>
+ <%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id, in_juty), method: :delete, data: {confirm: 'Are you sure?'} %>
<% end %>
<%= paginate @juties_in %>
-
+
- <%= render 'assign_in_juty', in_juty: @in_juty ,table: @table %>
+ <%= render 'assign_in_juty', in_juty: @in_juty, table: @table %>
-Back
+ Back
\ No newline at end of file
+
diff --git a/app/views/reports/commission/_commission_report_filter.html.erb b/app/views/reports/commission/_commission_report_filter.html.erb
index acfcef25..b7ac154e 100644
--- a/app/views/reports/commission/_commission_report_filter.html.erb
+++ b/app/views/reports/commission/_commission_report_filter.html.erb
@@ -6,20 +6,31 @@
Select Date Range
-
+ <% if @daterange %>
+
+ <% else %>
+
+ <% end %>
Commissioner
<% @commissioner.each do |c| %>
- <%= c.name %>
+ <% if @com_id == c.id %>
+ <%= c.name %>
+ <% else %>
+ <%= c.name %>
+ <% end %> %>
<% end %>
+
+
+
<% end %>
@@ -35,21 +46,26 @@
placeholder: 'Select Commissioner'
});
+ $('#clear_filter').click(function () {
+ $('#daterange').val('');
+ $('#commissioner').val('').text('');
+ });
+
$('input[name="daterange"]').daterangepicker({
- autoUpdateInput: false,
- ranges: {
- 'Today': [moment(), moment()],
- 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
- 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
- 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
- 'This Month': [moment().startOf('month'), moment().endOf('month')],
- 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
+ autoUpdateInput: false,
+ ranges: {
+ 'Today': [moment(), moment()],
+ 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
+ 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
+ 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
+ 'This Month': [moment().startOf('month'), moment().endOf('month')],
+ 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
+ },
+ locale: {
+ format: 'YYYY-MM-DD'
+ }
},
- locale: {
- format: 'YYYY-MM-DD'
- }
- },
- function(start, end, label) {
+ function (start, end, label) {
$('input[name="daterange"]').val(start.format('YYYY-MM-DD') + ' - ' + end.format('YYYY-MM-DD'));
});
diff --git a/app/views/settings/promotions/new.html.erb b/app/views/settings/promotions/new.html.erb
index c7748bb6..321aa4d1 100644
--- a/app/views/settings/promotions/new.html.erb
+++ b/app/views/settings/promotions/new.html.erb
@@ -13,5 +13,4 @@
$("#promotion_promo_code").val(Math.random().toString(36).slice(5) + Math.random().toString(36).slice(5));
// $( "#fromtime" ).timepicker();
// $( "#totime" ).timepicker({ 'scrollDefault': 'now' });
-$('#scrollDefaultExample').timepicker({ 'scrollDefault': 'now' });
diff --git a/dump.rdb b/dump.rdb
index 56908672..332310c7 100644
Binary files a/dump.rdb and b/dump.rdb differ