"
+ +set_option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>"
+'| '+rowCount+' | '
- +'' + item_name+ ' ' + name +'-' + option +' | '
+ +'' + item_name+ ' ' + name +' ' + set_option +' | '
+'' + qty + ' | '
+''
+ parseFloat(total).toFixed(2)
@@ -659,7 +662,6 @@ $(function() {
attribute_arr = get_selected_attributes('selected-attribute');
option_arr = get_selected_attributes('selected-option');
-
if (item_row.length>0) {
var instances = jQuery.parseJSON(item_row.attr('data-instances'));
@@ -700,7 +702,7 @@ $(function() {
var item_data = $(this);
item = get_item(item_data);
customer_display_view(item,"add");
- show_item_detail(item_data);
+ show_item_detail(item_data,"add_to_order");
calculate_sub_total();
}); //End add order Click
@@ -710,11 +712,11 @@ $(function() {
var item_data = $(this);
item = get_item(item_data);
customer_display_view(item,"add");
- show_item_detail(item_data);
+ show_item_detail(item_data,"add_icon");
calculate_sub_total();
}); //End Add Icon Click
- function show_item_detail(data){
+ function show_item_detail(data,click_type){
qty = parseInt(data.attr('data-qty'));
append = 0;
@@ -726,23 +728,26 @@ $(function() {
}else{
instance = "("+data.attr('data-instance')+")";
}
-
- d_option = data.attr('data-options');
- if (d_option){
- option_name = "-"+data.attr('data-options');
+ d_option = data.attr('data-opt');
+ if (click_type != "add_icon"){
+ option_name = "-"+data.attr('data-options');
+ data_option = data.attr('data-options') ;
}else{
- option_name = '';
+ option_name = ' ';
+ data_option = '[]';
}
+
var rowCount = $('.summary-items tbody tr').length+1;
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
item_code = $(item_row[i]).attr('data-code');
instance_code = $(item_row[i]).attr('data-instance-code');
- r_option = $(item_row[i]).attr('data-options');
-
- if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option==d_option) {
+ r_option = $(item_row[i]).attr('data-opt');
+console.log(r_option)
+console.log(d_option)
+ if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option == d_option) {
if (qty > 1) {
qty = parseInt($(item_row[i]).children('#item_qty').text()) + qty;
}else{
@@ -766,9 +771,10 @@ $(function() {
+instance+ "' data-code='"+data.attr('data-item-code')+"' data-instance-code='"
+data.attr('data-instance-code')+"' data-attributes='"
+data.attr('data-attributes')+"' data-options ='"
+ +data_option+"' data-opt ='"
+data.attr('data-options')+"' data-row ='"+rowCount+ "'>"
+' | '+rowCount+' | '
- +'' + data.attr('data-name')+ ' ' + instance +' ' + option_name +' | '
+ +'' + data.attr('data-name')+ ' ' + instance +''+option_name+' | '
+'' + qty + ' | '
+''
+ parseFloat(price).toFixed(2)
@@ -822,8 +828,6 @@ $(function() {
data: params,
dataType: "json",
success:function(result){
- console.log(type)
- console.log(table_type)
if (type == "quick_service") {
window.location.href = "/origami/quick_service"
}else{
@@ -889,7 +893,7 @@ $(function() {
dataType: "json",
success:function(result){
if (result.status) {
- console.log(result)
+
if (result.data == null){
swal({
title: "Please Open Shift !",
diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb
index 2e9602c8..43e1bd11 100755
--- a/app/controllers/api/orders_controller.rb
+++ b/app/controllers/api/orders_controller.rb
@@ -67,7 +67,8 @@ class Api::OrdersController < Api::ApiController
end
}
#end extra time
-
+ puts params[:order_items]
+ puts "ITEM aaaaaaaaaaaaaaaaaaa"
# begin
@order = Order.new
@order.source = params[:order_source]
diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb
index 7dd2b3f0..3a8dea9b 100755
--- a/app/controllers/origami/addorders_controller.rb
+++ b/app/controllers/origami/addorders_controller.rb
@@ -94,10 +94,10 @@ class Origami::AddordersController < BaseOrigamiController
extra_time = Time.at(time)
end
end
- if i["parent_order_item_id"]
- items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]}
+ if i["parent_order_item_id"];
+ items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])}
else
- items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
+ items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])}
end
items_arr.push(items)
}
diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb
index 4d7d6026..0a6d87c7 100755
--- a/app/controllers/settings/menus_controller.rb
+++ b/app/controllers/settings/menus_controller.rb
@@ -7,9 +7,12 @@ class Settings::MenusController < ApplicationController
def index
@settings_menus = Menu.all.page(params[:page]).per(10)
respond_to do |format|
- format.html
- format.csv { send_data Menu.to_csv }
- end
+ format.html
+ # format.csv { send_data MenuCsvExport.generate }
+
+format.csv { send_data Menu.to_csv }
+# format.csv { send_data MenuCategory.to_csv }
+ end
end
# GET /settings/menus/1
@@ -71,6 +74,11 @@ class Settings::MenusController < ApplicationController
# end
end
+ def import
+ Menu.import(params[:file])
+ redirect_to settings_menu_path, notice: "imported"
+ end
+
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_menu
diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb
index 17a117bb..52abf7fd 100755
--- a/app/controllers/transactions/orders_controller.rb
+++ b/app/controllers/transactions/orders_controller.rb
@@ -21,11 +21,12 @@ class Transactions::OrdersController < ApplicationController
@receipt_no = filter
@from = from
@to = to
-
+
respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @orders }
- end
+ format.html
+ format.json { render json: @orders }
+ # format.csv { send_data OrdersCsvExport.generate }
+ end
end
def show
diff --git a/app/models/menu.rb b/app/models/menu.rb
index 052a7042..12784eea 100755
--- a/app/models/menu.rb
+++ b/app/models/menu.rb
@@ -33,27 +33,20 @@ class Menu < ApplicationRecord
end
def self.to_csv
- m_attributes = %w{id name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at}
+ m_attributes = %w{name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at}
CSV.generate(headers: true) do |csv|
csv << m_attributes
menu = Menu.all
menu.each do |user|
- puts user
csv << m_attributes.map{ |attr| user.send(attr)}
end
end
+ end
- # mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at}
- # CSV.generate(headers: true) do |csv|
- # csv << m_attributes
-
- # csv << mc_attributes
- # MenuCategory.all.each do |user|
- # puts user
- # csv << mc_attributes.map{ |attr| user.send(attr)}
- # end
- # end
-
+ def self.import(file)
+ CSV.foreach(file.path, headers:true) do |row|
+ Menu.create! row.to_hash
+ end
end
end
\ No newline at end of file
diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb
index acb06c4f..65477a37 100755
--- a/app/models/menu_category.rb
+++ b/app/models/menu_category.rb
@@ -1,7 +1,7 @@
class MenuCategory < ApplicationRecord
# before_create :generate_menu_category_code
- belongs_to :menu
+ belongs_to :menu , counter_cache: true
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
has_many :menu_items
@@ -83,4 +83,19 @@ class MenuCategory < ApplicationRecord
# def generate_menu_category_code
# self.code = SeedGenerator.generate_code(self.class.name, "C")
# end
+
+ def self.to_csv
+
+ mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at}
+ CSV.generate(headers: true) do |csv|
+ csv << mc_attributes
+
+ csv << mc_attributes
+ MenuCategory.all.each do |user|
+ puts user
+ csv << mc_attributes.map{ |attr| user.send(attr)}
+ end
+ end
+
+ end
end
diff --git a/app/models/order_item.rb b/app/models/order_item.rb
index 776bb94c..87d60e63 100755
--- a/app/models/order_item.rb
+++ b/app/models/order_item.rb
@@ -5,7 +5,8 @@ class OrderItem < ApplicationRecord
before_create :generate_custom_id
#Associations
- belongs_to :order, autosave: true
+ belongs_to :order, autosave: true
+ # belongs_to :order, counter_cache: true
#Validation
validates_presence_of :item_code, :item_name, :qty
diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb
index 6c580f40..4e93e5a7 100755
--- a/app/views/origami/addorders/detail.html.erb
+++ b/app/views/origami/addorders/detail.html.erb
@@ -375,7 +375,7 @@
- <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %>
+ <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %>
diff --git a/config/application.rb b/config/application.rb
index f4cbac01..e9a4e634 100755
--- a/config/application.rb
+++ b/config/application.rb
@@ -20,5 +20,7 @@ module SXRestaurants
config.active_record.time_zone_aware_types = [:datetime, :time]
config.active_job.queue_adapter = :sidekiq
config.time_zone = 'Asia/Rangoon'
+
+
end
end
diff --git a/config/routes.rb b/config/routes.rb
index 88def9dc..b51baca3 100755
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -298,6 +298,7 @@ scope "(:locale)", locale: /en|mm/ do
#menu
resources :menus do
#menu_categories
+ collection { post :import }
resources :menu_categories, only: [:new, :create, :edit, :delete]
end
diff --git a/data/recent_users.json b/data/recent_users.json
deleted file mode 100644
index 4d2e6825..00000000
--- a/data/recent_users.json
+++ /dev/null
@@ -1,128 +0,0 @@
-[
- {
- "id": 1,
- "name": "Administrator",
- "role": "administrator",
- "emp_id": "999",
- "password_digest": "$2a$10$mfWmxBvOHt3NbWrLGOF/POTpnxF7QEtnW99qW818dkrQqVLtjQdrS",
- "token_session": null,
- "session_expiry": null,
- "session_last_login": "2018-03-14 09:41:25 +0630",
- "created_by": "SYSTEM DEFAULT",
- "created_at": "2017-11-08 09:44:30 +0630",
- "updated_at": "2018-03-14 16:02:09 +0630",
- "image_path": {"url":null}
- },
- {
- "id": 2,
- "name": "Waiter",
- "role": "waiter",
- "emp_id": "111",
- "password_digest": "$2a$10$PjBemEA2yKOcoGAyXjz81OqglrASIF8RTYHVe0vqp3FQ0T4/PzJJG",
- "token_session": "662e797ad508ab6c43b1",
- "session_expiry": "2018-02-21 01:45:11 +0630",
- "session_last_login": "2018-02-20 13:45:11 +0630",
- "created_by": "SYSTEM DEFAULT",
- "created_at": "2017-11-08 09:44:30 +0630",
- "updated_at": "2018-02-20 13:59:17 +0630",
- "image_path": {"url":null}
- },
- {
- "id": 3,
- "name": "Waiter 2",
- "role": "waiter",
- "emp_id": "222",
- "password_digest": "$2a$10$gXh/Tpbr8EyJSaxsbJYVh.K7Fr4bT0A1i2mWuuZm/FHQ4D/wV1E8e",
- "token_session": "61868be9530b753ada84",
- "session_expiry": "2018-03-14 05:41:12 +0630",
- "session_last_login": "2018-03-13 17:11:12 +0630",
- "created_by": "SYSTEM DEFAULT",
- "created_at": "2017-11-08 09:44:30 +0630",
- "updated_at": "2018-03-13 17:32:47 +0630",
- "image_path": {"url":null}
- },
- {
- "id": 4,
- "name": "Cashier",
- "role": "cashier",
- "emp_id": "333",
- "password_digest": "$2a$10$fHo.9wOn.yr.2Ke6iuCfou6DjpyHXwQSmZQ.43O7W4SnlmzuoIEF2",
- "token_session": "693f6e98bb90b6af9978",
- "session_expiry": "2018-03-15 12:36:28 +0630",
- "session_last_login": "2018-03-14 16:36:28 +0630",
- "created_by": "SYSTEM DEFAULT",
- "created_at": "2017-11-08 09:44:30 +0630",
- "updated_at": "2018-03-14 17:05:14 +0630",
- "image_path": {"url":null}
- },
- {
- "id": 5,
- "name": "manager",
- "role": "manager",
- "emp_id": "888",
- "password_digest": "$2a$10$EaU/Sxfsb8Q3kBIAyxSEJ.ZpRC9vxSdVAFvF0WXUvWiAqHyqGggoe",
- "token_session": null,
- "session_expiry": null,
- "session_last_login": "2018-01-16 13:37:05 +0630",
- "created_by": null,
- "created_at": "2017-11-30 10:03:11 +0630",
- "updated_at": "2018-01-16 13:48:02 +0630",
- "image_path": {"url":null}
- },
- {
- "id": 6,
- "name": "Account",
- "role": "account",
- "emp_id": "777",
- "password_digest": "$2a$10$bJmgIxHefkvxpxJQLQPcpurTJrp8.BwP/kirJRYb1v1thrU3TDzkC",
- "token_session": null,
- "session_expiry": null,
- "session_last_login": "2018-01-16 10:37:22 +0630",
- "created_by": null,
- "created_at": "2018-01-16 10:23:09 +0630",
- "updated_at": "2018-01-16 10:49:24 +0630",
- "image_path": {"url":null}
- },
- {
- "id": 7,
- "name": "Supervisor",
- "role": "supervisor",
- "emp_id": "666",
- "password_digest": "$2a$10$/WQirOw5nu6kKDiITTVa7.IGeVyxH5JmLp3/Astu/5DlOAoMLn4Ne",
- "token_session": null,
- "session_expiry": null,
- "session_last_login": "2018-01-16 14:28:40 +0630",
- "created_by": null,
- "created_at": "2018-01-16 10:23:32 +0630",
- "updated_at": "2018-01-16 15:32:33 +0630",
- "image_path": {"url":null}
- },
- {
- "id": 8,
- "name": "123",
- "role": "waiter",
- "emp_id": "123",
- "password_digest": "$2a$10$v8JBsc31XkLRNZ/QhfYBg.wbVT7CyVvk83U..0PsGiz61w0Atl/WW",
- "token_session": "4fc9a18a5df511e507fc",
- "session_expiry": "2018-02-01 20:08:35 +0630",
- "session_last_login": "2018-02-01 14:08:35 +0630",
- "created_by": null,
- "created_at": "2018-02-01 14:07:16 +0630",
- "updated_at": "2018-02-01 17:45:10 +0630",
- "image_path": {"url":null}
- },
- {
- "id": 9,
- "name": "Cashier 2",
- "role": "cashier",
- "emp_id": "444",
- "password_digest": "$2a$10$5n34O09xmrIHbgvX.uhr9uAaUR8etjaqiicaXr017VWm/qDkjKVue",
- "token_session": "0477edce9cf259f280c1",
- "session_expiry": "2018-02-20 19:07:50 +0630",
- "session_last_login": "2018-02-20 11:37:50 +0630",
- "created_by": null,
- "created_at": "2018-02-14 17:10:12 +0630",
- "updated_at": "2018-02-20 13:37:46 +0630",
- "image_path": {"url":null}
- }
-]
\ No newline at end of file
|