Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into r-1804001-01

This commit is contained in:
Aung Myo
2018-04-19 16:56:30 +06:30
16 changed files with 140 additions and 41 deletions

1
.gitignore vendored
View File

@@ -24,6 +24,7 @@ capybara-*.html
/public/image
/public/system/*
/public/assets/*
/public/menus/*
/public/uploads/*
/public/swf/*
/public/receipts/

View File

@@ -268,21 +268,24 @@ $(function() {
value = item_sets[field]["instances"];
$(value).each(function(i){
if (type != -1 && modify_order != -1) {
url = '../../../../api/restaurant/menu_item_instances/'+value[i]["id"];
url = '../../../addorders/get_item_instance/'+value[i]["id"];
console.log("ssssssss")
}
if(modify_order == -1 && type != -1){
url = '../../api/restaurant/menu_item_instances/'+value[i]["id"] ;
url = 'addorders/get_item_instance/'+value[i]["id"] ;
console.log("aaaaaa")
}
if (type ==-1 && modify_order == -1){
url = '../../api/restaurant/menu_item_instances/'+value[i]["id"];
url = '../addorders/get_item_instance/'+value[i]["id"];
console.log("cccccccccc")
}
$.ajax({
type: "GET",
url: url,
data: {id:value[i]},
// data: {id:value[i]},
success:function(result){
row = '<div class="col-md-4 " >'

View File

@@ -53,16 +53,4 @@ module LoginVerification
def render_unauthorized
redirect_to root_path
end
private
def check_license
License.check_license_file
end
def check_installation
if current_company.nil?
redirect_to install_path
end
end
end

View File

@@ -13,8 +13,8 @@ module TokenVerification
authenticate_token || render_unauthorized
end
def authenticate_token
authenticate_with_http_token do |token, options|
def authenticate_token
authenticate_with_http_token do |token, options|
# Rails.logger.debug "token - " + token.to_s
if(options.length !=0 && options["from"] == "DOEMAL")
if(ENV["SERVER_MODE"] === "cloud")

View File

@@ -58,6 +58,10 @@ class Origami::AddordersController < BaseOrigamiController
end
end
def get_item_instance
@id = MenuItemInstance.find(params[:id])
end
def get_menu()
if (params[:id])
#Pull this menu

View File

@@ -99,11 +99,39 @@ class Settings::MenusController < ApplicationController
sheet.add_row ["Name",menu.name], :style=>title
sheet.add_row
sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Instance Code", "Instance Name", "Price"], :style=>header_text
sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Price", "Is Default"], :style=>header_text
menu.menu_categories.each do |mc|
mc.menu_items.each do |mi|
attributes = ""
i=0
if mi.item_attributes.length > 0
mi.item_attributes.each do |mia|
attribute = MenuItemAttribute.find(mia)
if i == mi.item_attributes.length - 1
attributes = attributes + attribute.name
else
attributes = attributes + attribute.name + ","
end
i = i + 1
end
end
options = ""
i=0
if mi.item_options.length > 0
mi.item_options.each do |mia|
option = MenuItemOption.find(mia)
if i == mi.item_options.length - 1
options = options + option.name
else
options = options + option.name + ","
end
i = i + 1
end
end
mi.menu_item_instances.each do |mii|
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, mii.item_instance_code, mii.item_instance_name, mii.price], :style=>wrap_text
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, mii.price, mii.is_default], :style=>wrap_text
end
end
end

View File

@@ -153,6 +153,28 @@ class Menu < ApplicationRecord
# status = status + "Category Code already exists."
end
# Menu Item Attributes
item_attrs = []
attributes = row["Attributes"].split(',')
attributes.each do |attr|
attribute = MenuItemAttribute.find_by_name(attr)
if attribute.nil?
attribute = MenuItemAttribute.create({ attribute_type:"any", name: attr.capitalize, value: attr.downcase })
end
item_attrs.push(attribute.id)
end
# Menu Item Options
item_opts = []
options = row["Options"].split(',')
options.each do |opt|
option = MenuItemOption.find_by_name(opt)
if option.nil?
option = MenuItemOption.create({ option_type:"any", name: opt.capitalize, value: opt.downcase })
end
item_opts.push(option.id)
end
menu_itm = MenuItem.find_by_item_code(row["Item Code"])
if !menu_itm
account = Account.find_by_title(row["Account"])
@@ -160,14 +182,14 @@ class Menu < ApplicationRecord
account = Account.create({title: row["Account"], account_type: "0"})
end
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: "[]", item_options: "[]", is_sub_item: 0, is_available: 1, created_by: created_by)
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: item_attrs, item_options: item_opts, is_sub_item: 0, is_available: 1, created_by: created_by)
# else
# status = status + "Item Code already exists for " + row["Item Name"] + "."
end
menu_inst = MenuItemInstance.find_by_item_instance_code(row["Instance Code"])
if !menu_inst
imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: row["Instance Name"], item_attributes: "[]", price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: false)
imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: row["Instance Name"], item_attributes: [], price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: row["Is Default"])
# else
# status = status + "Instance Code already exists for " + row["Instance Name"] + "."
end

View File

@@ -0,0 +1,39 @@
if(@id)
menu_item = MenuItem.find(@id.menu_item_id)
# Format for option json
opt_format = []
# Format for attributes json
menu_item.item_options.each do|opt|
menu_opt = MenuItemOption.find(opt)
if opt_format.count == 0
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
next
end
opt_format.each do |of|
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
if menu_opt.option_type == of[:type]
of[:values].push(menu_opt.name)
end
else
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
opt_format.push(new_opt)
break
end
end
end
json.success true
json.id @id.id
json.name @id.item_instance_name
json.code @id.item_instance_code
json.item_id @id.menu_item_id
json.attributes @id.item_attributes
json.price @id.price
json.is_default @id.is_default
json.options opt_format
else
json.success false
end

View File

@@ -106,6 +106,12 @@
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn bg-default m-t-10 btn-lg btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"> <i class="material-icons m-t--5">reply</i>Back </button>
</div>
<div id="sxModal">
<div id="sxModal-Content"><h3>Card Tap</h3></div>
<div class="m-r-20" align="right">
<button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button>
</div>
</div>
</div>
<div id="sxModal">
<div id="sxModal-Content"><h3>Card Tap</h3></div>
@@ -348,7 +354,7 @@
$.ajax({
type: "POST",
url: "<%=origami_payment_paymal_path%>",
url: "<%=origami_payment_dinga_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:code},
success: function(result){

View File

@@ -432,20 +432,12 @@
<iframe id="receipt_pdf" src="" class="pdf-iframe" scrolling="no"></iframe>
</div>
</div>
<div class="modal-footer ">
<div class="row m-b-10 m-r-30">
<div class="col-md-5 m-r-20">
<% if ENV["SERVER_MODE"] != "cloud" %>
<button type="button" class="btn btn-link bg-red waves-effect print_receipt">Print</button>
<% end %>
</div>
<div class="col-md-5 m-r-20">
<button type="button" class="btn btn-link bg-blue waves-effect btn_pdf_close" data-dismiss="modal">CLOSE</button>
</div>
</div>
<div class="modal-footer">
<button type="button" class="mr-2 btn btn-link bg-red waves-effect print_receipt"> Print
</button>
<button type="button" class="btn btn-link bg-blue waves-effect btn_pdf_close" data-dismiss="modal">
CLOSE
</button>
</div>
</div>
</div>
@@ -1049,7 +1041,6 @@ var customer_name = "<%= @customer.name %>";
url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print",
data: params,
success:function(result){
console.log(result);
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);

View File

@@ -16,7 +16,7 @@
<% if(@server_mode != 'cloud') %>
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %>
<% else %>
<%= f.input :printer_name %>
<%= f.input :printer_name, :as => :select, :collection => [] %>
<% end %>
<%= f.input :brand_name %>
<%= f.input :printer_type %>

View File

@@ -7,7 +7,11 @@
<div class="form-inputs p-l-15">
<%= f.input :name %>
<%= f.input :role, :collection => Lookup.collection_of("employee_roles"),:class=>'form-group' %>
<% if current_user.role == "administrator" %>
<%= f.input :role, :collection => Lookup.collection_of("employee_roles"),:class=>'form-group' %>
<% else %>
<%= f.input :role, :collection => Lookup.collection_of("employee_roles").select{|r| r[1] != "administrator"},:class=>'form-group' %>
<% end %>
<%= f.input :emp_id, :label => "Employee Numberic ID (*Unique)" %>
<%= f.input :password %>

View File

@@ -50,6 +50,16 @@ class ActionController::Base
end
end
def check_license
License.check_license_file
end
def check_installation
if current_company.nil?
redirect_to install_path
end
end
def website_connection(license)
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
:username => license.dbusername, :password => license.dbpassword)

View File

@@ -237,6 +237,9 @@ scope "(:locale)", locale: /en|mm/ do
get '/:addorders/:id' => "addorders#detail"
post '/:addorders/create' => "addorders#create",:as => "addorder_create", :defaults => { :format => 'json' }
get '/addorders/get_item_instance/:id' => "addorders#get_item_instance",:as => "get_item_instance", :defaults => { :format => 'json' }
resources :commissions
resources :commissioners

View File

@@ -13,7 +13,7 @@
development:
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
sx_provision_url: https://connect.pos-myanmar.com/bensai/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api
server_mode: cloud
server_mode: application
cipher_type: AES-256-CBC
sx_key: Wh@t1$C2L

Binary file not shown.