merge with master
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -26,7 +26,7 @@ capybara-*.html
|
||||
/public/assets/*
|
||||
/public/uploads/*
|
||||
/public/swf/*
|
||||
/public/receipts
|
||||
/public/receipts/
|
||||
/coverage/
|
||||
/spec/tmp/*
|
||||
*.orig
|
||||
|
||||
9
Gemfile
9
Gemfile
@@ -46,9 +46,11 @@ gem 'mini_magick'
|
||||
gem 'cups'
|
||||
gem 'prawn'
|
||||
gem 'prawn-table'
|
||||
gem 'spreadsheet'
|
||||
gem 'to_xls-rails'
|
||||
|
||||
gem 'rubyzip', '= 1.0.0'
|
||||
gem 'axlsx', '= 2.0.1'
|
||||
gem 'axlsx_rails'
|
||||
gem 'roo'
|
||||
#Reporting gem
|
||||
#gem 'compendium'
|
||||
#gem "cancan"
|
||||
@@ -81,7 +83,6 @@ gem 'kaminari', '~> 1.0.1'
|
||||
gem 'filterrific'
|
||||
|
||||
gem 'cancancan', '~> 1.10'
|
||||
|
||||
#pageless no need for current
|
||||
# gem 'will_paginate'
|
||||
# gem 'pageless-rails', github: 'rorlab/pageless-rails'
|
||||
@@ -129,4 +130,4 @@ gem 'momentjs-rails' # for date-range selector
|
||||
# gem 'bootstrap-datepicker-rails' # date picker
|
||||
# gem 'jquery-datetimepicker-rails'
|
||||
# gem 'select2-rails' # for multi-select and auto-complete select box
|
||||
gem "chartkick" #chart lib
|
||||
gem "chartkick" #chart lib
|
||||
18
Gemfile.lock
18
Gemfile.lock
@@ -50,6 +50,13 @@ GEM
|
||||
airbrussh (1.3.0)
|
||||
sshkit (>= 1.6.1, != 1.7.0)
|
||||
arel (8.0.0)
|
||||
axlsx (2.0.1)
|
||||
htmlentities (~> 4.3.1)
|
||||
nokogiri (>= 1.4.1)
|
||||
rubyzip (~> 1.0.0)
|
||||
axlsx_rails (0.5.1)
|
||||
actionpack (>= 3.1)
|
||||
axlsx (>= 2.0.1)
|
||||
bcrypt (3.1.11)
|
||||
bindex (0.5.0)
|
||||
builder (3.2.3)
|
||||
@@ -100,6 +107,7 @@ GEM
|
||||
railties (>= 3.2, < 5.2)
|
||||
globalid (0.4.1)
|
||||
activesupport (>= 4.2.0)
|
||||
htmlentities (4.3.4)
|
||||
httparty (0.15.6)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (0.9.1)
|
||||
@@ -197,6 +205,10 @@ GEM
|
||||
rb-inotify (0.9.10)
|
||||
ffi (>= 0.5.0, < 2)
|
||||
redis (3.3.5)
|
||||
roo (1.13.2)
|
||||
nokogiri
|
||||
rubyzip
|
||||
spreadsheet (> 0.6.4)
|
||||
rspec-core (3.7.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-expectations (3.7.0)
|
||||
@@ -215,6 +227,7 @@ GEM
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-support (3.7.0)
|
||||
ruby-ole (1.2.12.1)
|
||||
rubyzip (1.0.0)
|
||||
sass (3.5.3)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
@@ -286,6 +299,8 @@ PLATFORMS
|
||||
|
||||
DEPENDENCIES
|
||||
aescrypt
|
||||
axlsx (= 2.0.1)
|
||||
axlsx_rails
|
||||
bcrypt (~> 3.1.7)
|
||||
byebug
|
||||
cancancan (~> 1.10)
|
||||
@@ -320,13 +335,14 @@ DEPENDENCIES
|
||||
rack-cors
|
||||
rails (~> 5.1.0)
|
||||
redis (~> 3.0)
|
||||
roo
|
||||
rspec-rails (~> 3.5)
|
||||
rubyzip (= 1.0.0)
|
||||
sass-rails (~> 5.0)
|
||||
schema_to_scaffold
|
||||
shoulda-matchers (~> 3.1)
|
||||
sidekiq
|
||||
simple_form
|
||||
spreadsheet
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
tether-rails
|
||||
|
||||
64
README.md
64
README.md
@@ -8,30 +8,24 @@ Things you may want to cover:
|
||||
ruby 2.4.1p111
|
||||
|
||||
* Membership Details
|
||||
Osaka =>
|
||||
Auth Token => wu8YvlLmah0CL => New => v3
|
||||
=> rj0MJ0XI5GsKZehE => Old => v2
|
||||
=> code2lab => Old
|
||||
|
||||
Osaka
|
||||
Merchant account => RxzaYyAGzm7VqAZ4hKnv
|
||||
Campaign Id => {"campaign_type_id": 5}
|
||||
|
||||
Auth Token => wu8YvlLmah0CL => New ##note : Old => rj0MJ0XI5GsKZehE
|
||||
BITP
|
||||
Auth Token => pZBHXEFbGNj/G => New => V3
|
||||
=> rj0MJ0XI5GsKZehE => Old => V2
|
||||
=> code2lab => Old
|
||||
|
||||
=> code2lab => Old
|
||||
|
||||
Merchant account => RxzaYyAGzm7VqAZ4hKnv
|
||||
|
||||
Campaign Id => {"campaign_type_id": 5}
|
||||
|
||||
|
||||
|
||||
BITP
|
||||
|
||||
Auth Token => pZBHXEFbGNj/G => New ##note : Old => rj0MJ0XI5GsKZehE
|
||||
|
||||
=> code2lab => Old
|
||||
|
||||
Merchant account => vWSsseoZCzxd6xcNf_uS
|
||||
|
||||
Campaign Id => {"campaign_type_id": 1}
|
||||
Merchant account => vWSsseoZCzxd6xcNf_uS
|
||||
Campaign Id => {"campaign_type_id": 1}
|
||||
|
||||
java -jar ~/Documents/Jade.jar http://192.168.1.88:3002
|
||||
java -jar ~/Documents/c2l_jade.jar http://192.168.1.151:3002
|
||||
|
||||
Person and Extra Time
|
||||
category_code = SPL... //for menu categories special
|
||||
@@ -105,7 +99,15 @@ Change type in mysql
|
||||
|
||||
For split bill
|
||||
1) settings/lookups => { type:split_bill, name:SplitBill, value:1 }
|
||||
|
||||
|
||||
For Sidekiq
|
||||
1) If you want to use sidekiq
|
||||
=> Create New Lookups => lookup_type = sidekiq, Name = sidekiq , Value = 1 or 0
|
||||
|
||||
For Clear Menu
|
||||
1) rake clear:menu # menu,menu item,menu category,menu item instance,account,item option,item attribute,item set
|
||||
|
||||
For Check CUp status
|
||||
###please open
|
||||
sudo cat /etc/sudoers
|
||||
### cope and parse
|
||||
@@ -134,12 +136,34 @@ ADD COLUMN image_path VARCHAR(255);
|
||||
|
||||
ALTER TABLE sales
|
||||
ADD COLUMN equal_persons INT(11) after rebate_status;
|
||||
|
||||
ALTER TABLE sale_items
|
||||
ADD COLUMN remark VARCHAR(255) after status;
|
||||
|
||||
ALTER TABLE shops
|
||||
ADD COLUMN shop_code VARCHAR(255) after name,
|
||||
ADD COLUMN client_name VARCHAR(255) after shop_code,
|
||||
ADD COLUMN client_code VARCHAR(255) after client_name;
|
||||
|
||||
ALTER TABLE print_settings
|
||||
ADD COLUMN brand_name VARCHAR(255) after api_settings,
|
||||
ADD COLUMN type VARCHAR(255) after brand_name;
|
||||
|
||||
ALTER TABLE tax_profiles
|
||||
ADD COLUMN group_type VARCHAR(255) after name;
|
||||
|
||||
<---- Extra Fields Script ----->
|
||||
For CloseCashierCustomisePdf in lookups
|
||||
*** change CloseCashierPdf to CloseCashierCustomisePdf
|
||||
1) settings/print_settings
|
||||
2) settings/lookups => { type:print_settings, name: CloseCashierCustomisePdf, value:1 }
|
||||
|
||||
/* Tax Profile Group Types in lookups */
|
||||
1) settings/lookups => { type:tax_profiles, name: Cashier, value:cashier }
|
||||
2) settings/lookups => { type:tax_profiles, name: Quick Service, value: quick_service }
|
||||
3) settings/lookups => { type:tax_profiles, name: Doemal, value: doemal }
|
||||
/* Tax Profile Group Types in lookups */
|
||||
|
||||
* ToDo list
|
||||
|
||||
1. Migration
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
//= require bootstrap-notify/bootstrap-notify.js
|
||||
//= require node-waves/waves.js
|
||||
//= require sweetalert/sweetalert.min.js
|
||||
//= require fileinput.min
|
||||
//= require BSBMaterial/turbolink_admin.js
|
||||
//= require BSBMaterial/demo.js
|
||||
//= require custom.js
|
||||
@@ -34,4 +35,24 @@ $(document).on('turbolinks:load', function() {
|
||||
weekStart: 1,
|
||||
time: false
|
||||
});
|
||||
});
|
||||
|
||||
$("#customer_image_path").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ $(function() {
|
||||
image_path = "/image/logo.png";
|
||||
}
|
||||
|
||||
row = '<div class="card custom-card testimonial-card animated fadeInRight" style="">'
|
||||
row = '<div class="card custom-card testimonial-card fadeInRight" style="">'
|
||||
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;">'
|
||||
+'<div class="col-md-9">'+ product[field].name +'</div>'
|
||||
+"<div class='col-md-3 add_icon' data-item-code='"
|
||||
@@ -180,9 +180,8 @@ $(function() {
|
||||
image_path = "image/logo.png";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
row = '<div class="card custom-card testimonial-card animated fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
|
||||
row = '<div class="card custom-card testimonial-card fadeInRight" style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
|
||||
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">'
|
||||
+'<div class="col-md-9">'+ menu_items[field].name +'</div>'
|
||||
+"<div class='col-md-3 "+menu_item_box+"' data-item-code='"
|
||||
@@ -190,19 +189,21 @@ $(function() {
|
||||
+JSON.stringify(menu_items[field].instances)+"' data-id = '"
|
||||
+JSON.stringify(menu_items[field].attributes)+"' data-item = '"
|
||||
+JSON.stringify(item_attributes)+"' data-option = '"
|
||||
+JSON.stringify(menu_items[field].options)+"'data-opt = '"
|
||||
+JSON.stringify(menu_items[field].options)+"' data-item-sets = '"
|
||||
+JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"' >"
|
||||
+"<i class='fa "+fa_plus+" '>"
|
||||
+add+ '</i>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+"<div class='"+add_icon+" p-t-65 m-r--5' data-item-code='"
|
||||
+"<div class='"+add_icon+" p-t-65 m-r-' data-item-code='"
|
||||
+ menu_items[field].code +"' data-name='"
|
||||
+ menu_items[field].name +"' data-qty = '"+ qty +"' data-price = '"
|
||||
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
|
||||
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
|
||||
+ JSON.stringify(item_attributes) +"' data-options = '"
|
||||
+ options +"' data-image='"+image_path+"' data-toggle='"
|
||||
+ JSON.stringify(menu_items[field].options) +"' data-opt = '"
|
||||
+ JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"' data-toggle='"
|
||||
+data_modal+"' data-target='."+data_target+"' data-item-sets = '"
|
||||
+JSON.stringify(menu_items[field].item_sets)+"'data-instances = '"
|
||||
+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
@@ -237,10 +238,10 @@ $(function() {
|
||||
//instances = $(this).data('instance');
|
||||
item_sets = $(this).data('item-sets');
|
||||
instances = $(this).data('instances');
|
||||
// item_sets = $(data).attr('data-item-sets');
|
||||
item_options = $(this).data('options');
|
||||
|
||||
for(var field in item_sets) {
|
||||
|
||||
|
||||
$('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]);
|
||||
|
||||
value = item_sets[field]["instances"];
|
||||
@@ -283,10 +284,20 @@ $(function() {
|
||||
});
|
||||
}
|
||||
|
||||
for(var j in item_options) {
|
||||
value = item_options[j]["values"];
|
||||
type = item_options[j]["type"];
|
||||
row = "<h4>"+type+"</h4>"
|
||||
$(value).each(function(i){
|
||||
row +="<button class='btn btn- waves-effect option_btn "+ type +"' data-type='"
|
||||
+type+"' data-value='"+value[i]+"' data-group='set_menu_default'>"+value[i]+"</button>";
|
||||
});
|
||||
$(".options-list").append(row);
|
||||
}
|
||||
$('.set-item').attr('data-code',instances[0]['code']);
|
||||
$('.set-item').attr('data-name',instances[0]['name']);
|
||||
$('.set-item').attr('data-price',instances[0]['price']);
|
||||
$('.set-item').attr('data-options','[]');
|
||||
$('.set-item').attr('data-options','');
|
||||
$('.set-item').attr('data-parent',true);
|
||||
|
||||
$('#set_change_qty').val(1);
|
||||
@@ -341,6 +352,7 @@ $(function() {
|
||||
sub_total = $('#set_total_price').text();
|
||||
name = $(this).data('name');
|
||||
price = $(this).data('price');
|
||||
options = $(this).attr('data-options','');
|
||||
// qty = $('#set_change_qty').val();
|
||||
qty = document.getElementById("set_count").value;
|
||||
total = qty*price;
|
||||
@@ -369,52 +381,48 @@ $(function() {
|
||||
|
||||
item = get_set_item(items);
|
||||
customer_display_view(item,"set_add");
|
||||
|
||||
var option = ''
|
||||
attribute_arr = []
|
||||
option_arr = []
|
||||
|
||||
var rowCount = $('.summary-items tbody tr').length+1;
|
||||
option_arr = []
|
||||
code = $('.set-item').attr('data-code');
|
||||
name = $('.set-item').attr('data-name');
|
||||
price = $('.set-item').attr('data-price');
|
||||
option = $('.set-item').attr('data-options');
|
||||
option = ($('.set-item').attr('data-options') === 'undefined') ? '' :$('.set-item').attr('data-options');
|
||||
parent = $('.set-item').attr('data-parent');
|
||||
total = qty * price ;
|
||||
option_arr.push(option);
|
||||
row ="<tr class='item_box' data-price ='"
|
||||
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
|
||||
+name+ "' data-code='"+item_code+"' data-instance-code='"
|
||||
+code+"' data-attributes='"
|
||||
+attribute_arr+"' data-options ='"
|
||||
+option_arr+"' data-row ='"+rowCount+ "' data-parent ='"+parent+ "'>"
|
||||
+option+"' data-row ='"+rowCount+ "' data-parent ='"+parent+ "'>"
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +' ' + option +'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(total).toFixed(2)
|
||||
+'</td>'
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
|
||||
var rowCount = $('.summary-items tbody tr').length+1;
|
||||
var set_option = ''
|
||||
$(items).each(function(i){
|
||||
code = $(items[i]).attr('data-code');
|
||||
name = $(items[i]).attr('data-name');
|
||||
price = $(items[i]).attr('data-price');
|
||||
option = $(items[i]).attr('data-options');
|
||||
set_option = ($(items[i]).attr('data-options') === 'undefined') ? ' ' :$(items[i]).attr('data-options');
|
||||
|
||||
sub_item = $(items[i]).attr('data-sub-item');
|
||||
option = $(items[i]).attr('data-options');
|
||||
total = qty * price ;
|
||||
option_arr.push(option);
|
||||
row ="<tr class='item_box' data-price ='"
|
||||
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
|
||||
+name+ "' data-code='"+item_code+"' data-instance-code='"
|
||||
+code+"' data-attributes='"
|
||||
+attribute_arr+"' data-options ='"
|
||||
+option_arr+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>"
|
||||
+set_option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>"
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +' ' + set_option +'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(total).toFixed(2)
|
||||
@@ -626,8 +634,6 @@ $(function() {
|
||||
|
||||
|
||||
if(group == "set_menu"){
|
||||
code = $(this).data('code');
|
||||
value = $(this).data('value');
|
||||
|
||||
instance = $(".selected-instance");
|
||||
$(instance).each(function(i){
|
||||
@@ -638,6 +644,12 @@ $(function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(group == "set_menu_default"){
|
||||
option_arr = get_selected_attributes('selected-option');
|
||||
$('.set-item').attr('data-options',JSON.stringify(option_arr));
|
||||
$('.set_default_option').text(option_arr);
|
||||
}
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
@@ -650,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'));
|
||||
|
||||
@@ -689,9 +700,9 @@ $(function() {
|
||||
$('.add_to_order').attr('data-attributes',JSON.stringify(attribute_arr));
|
||||
$('.add_to_order').attr('data-options',JSON.stringify(option_arr));
|
||||
var item_data = $(this);
|
||||
item = get_item(item_data);
|
||||
item = get_item(item_data,"add_to_order");
|
||||
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
|
||||
@@ -699,13 +710,13 @@ $(function() {
|
||||
// click plus icon for add
|
||||
$(document).on('click', '.add_icon', function(event){
|
||||
var item_data = $(this);
|
||||
item = get_item(item_data);
|
||||
item = get_item(item_data,"add_icon");
|
||||
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;
|
||||
@@ -717,23 +728,24 @@ $(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');
|
||||
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{
|
||||
@@ -757,9 +769,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+ "'>"
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance +' ' + option_name +'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance +''+option_name+'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(price).toFixed(2)
|
||||
@@ -776,17 +789,17 @@ $(function() {
|
||||
e.preventDefault();
|
||||
$("#oqs_loading_wrapper").show();
|
||||
|
||||
type = window.location.href.indexOf("quick_service");
|
||||
if (type != -1) {
|
||||
quick_service = window.location.href.indexOf("quick_service");
|
||||
if (quick_service != -1) {
|
||||
type = 'quick_service'
|
||||
var table_type = $('#table_type').text();
|
||||
var table_type = $('#table_type').text();
|
||||
var table_id = $('#table_id').val();
|
||||
var customer_id = $('#customer_id').val();
|
||||
var booking_id = $('#booking_id').text();
|
||||
var ajax_url = 'addorders/create';
|
||||
}else{
|
||||
type = 'cashier'
|
||||
var table_type = $('#table_type').text();
|
||||
var table_type = $('#table_type').text();
|
||||
var table_id = $('#table_id').text();
|
||||
var customer_id = $('#customer_id').text();
|
||||
var booking_id = $('#booking_id').text();
|
||||
@@ -813,17 +826,17 @@ $(function() {
|
||||
data: params,
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
customer_display_view(null,"reload");
|
||||
if (type == "quick_service") {
|
||||
window.location.href = "/origami/quick_service"
|
||||
window.location.href = "/origami/quick_service"
|
||||
}else{
|
||||
if(table_type == "Table"){
|
||||
window.location.href = "/origami/table/" + table_id
|
||||
window.location.href = "/origami/table/" + table_id
|
||||
}
|
||||
else {
|
||||
window.location.href = "/origami/room/" + table_id
|
||||
window.location.href = "/origami/room/" + table_id
|
||||
}
|
||||
}
|
||||
customer_display_view(null,"reload");
|
||||
}
|
||||
});
|
||||
// }else{
|
||||
@@ -878,13 +891,24 @@ $(function() {
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
if (result.status) {
|
||||
|
||||
if (result.data == null){
|
||||
window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text();
|
||||
swal({
|
||||
title: "Please Open Shift !",
|
||||
text: result.status,
|
||||
type: "warning",
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "Ok",
|
||||
closeOnConfirm: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text();
|
||||
});
|
||||
|
||||
}else{
|
||||
window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1156,7 +1180,7 @@ $(function() {
|
||||
|
||||
for(var i in data) {
|
||||
|
||||
row = '<li class="menu_category fadeInTop animated" data-id="'+data[i].id+'">'
|
||||
row = '<li class="menu_category fadeInTop" data-id="'+data[i].id+'">'
|
||||
+'<a class="nav-link" data-toggle="tab" href="" role="tab">'+ data[i].name+'</a>'
|
||||
+'</li>' ;
|
||||
$(sub_category).append(row);
|
||||
@@ -1169,7 +1193,7 @@ $(function() {
|
||||
}
|
||||
|
||||
/* Get Item rows */
|
||||
function get_item(data){
|
||||
function get_item(data,click_type){
|
||||
var sale_items = [];
|
||||
|
||||
var sale_item = {};
|
||||
@@ -1180,6 +1204,8 @@ $(function() {
|
||||
sale_item.instance_code = data.attr('data-instance-code')
|
||||
sale_item.attributes = data.attr('data-attributes')
|
||||
sale_item.options = data.attr('data-options')
|
||||
sale_item.opt = data.attr('data-opt')
|
||||
sale_item.click_type = click_type
|
||||
sale_item.instance = data.attr('data-instance')
|
||||
sale_items.push(sale_item);
|
||||
|
||||
|
||||
@@ -104,6 +104,86 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$("#shop_logo").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
|
||||
$("#commissioner_image_path").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
|
||||
$("#employee_image_path").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
|
||||
$("#shop_image").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
|
||||
// first input focus for all form
|
||||
$('form:first *input[data-behaviour!=datepicker]:input[type!=hidden]:first').focus();
|
||||
|
||||
|
||||
@@ -10,10 +10,12 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
var tax = data.tax_profiles;
|
||||
var status= data.status
|
||||
if (status == "reload") {
|
||||
window.location.reload();
|
||||
jQuery('#s_reload').click();
|
||||
}
|
||||
$('#second_display_slider').addClass("hidden")
|
||||
$('#second_display_items').removeClass("hidden")
|
||||
$('#second_display_slider').addClass("hidden")
|
||||
$('#second_display_items').removeClass("hidden")
|
||||
|
||||
|
||||
// append items
|
||||
if (status == "add") {
|
||||
for(var i in items) {
|
||||
@@ -28,11 +30,20 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
instance = "("+items[i].instance+")";
|
||||
}
|
||||
|
||||
d_option = items[i].options;
|
||||
if (d_option){
|
||||
option_name = "-"+items[i].options;
|
||||
// d_option = items[i].options;
|
||||
// if (d_option){
|
||||
// option_name = "-"+items[i].options;
|
||||
// }else{
|
||||
// option_name = '';
|
||||
// }
|
||||
|
||||
d_option = items[i].opt;
|
||||
if (items[i].click_type != "add_icon"){
|
||||
option_name = "-"+items[i].options;
|
||||
data_option = items[i].options ;
|
||||
}else{
|
||||
option_name = '';
|
||||
option_name = ' ';
|
||||
data_option = '[]';
|
||||
}
|
||||
|
||||
var rowCount = $('.second_display_items tbody tr').length+1;
|
||||
@@ -66,7 +77,8 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
+instance+ "' data-code='"+items[i].item_code+"' data-instance-code='"
|
||||
+items[i].instance_code+"' data-attributes='"
|
||||
+items[i].attributes+"' data-options ='"
|
||||
+items[i].options+"' data-row ='"+rowCount+ "'>"
|
||||
+data_option+"' data-opt ='"
|
||||
+items[i].options+"' data-row ='"+rowCount+ "'>"
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + items[i].name+ ' ' + instance + ' ' + option_name +'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
@@ -84,8 +96,6 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
var attribute_arr = [];
|
||||
var rowCount = $('.second_display_items tbody tr').length+1;
|
||||
for(var i in items) {
|
||||
|
||||
|
||||
code = items[i].code;
|
||||
item_code = items[i].item_code;
|
||||
name = items[i].name;
|
||||
|
||||
@@ -9,7 +9,8 @@ $(document).ready(function() {
|
||||
color: 'rgba(0,0,0,0.5)',
|
||||
alwaysVisible: false,
|
||||
borderRadius: '0',
|
||||
railBorderRadius: '0'
|
||||
railBorderRadius: '0',
|
||||
touchScrollStep : 25
|
||||
});
|
||||
|
||||
$('#order-detail-slimscroll').slimScroll({
|
||||
@@ -18,7 +19,18 @@ $(document).ready(function() {
|
||||
color: 'rgba(0,0,0,0.5)',
|
||||
alwaysVisible: false,
|
||||
borderRadius: '0',
|
||||
railBorderRadius: '0'
|
||||
railBorderRadius: '0',
|
||||
touchScrollStep : 25
|
||||
});
|
||||
|
||||
$('#menu-slimscroll').slimScroll({
|
||||
height: height-$('#menu-slimscroll').attr('data-height'),
|
||||
size: '5px',
|
||||
color: 'rgba(0,0,0,0.5)',
|
||||
alwaysVisible: false,
|
||||
borderRadius: '0',
|
||||
railBorderRadius: '0',
|
||||
touchScrollStep : 25
|
||||
});
|
||||
|
||||
// $('.delete').click(function(){
|
||||
|
||||
@@ -9,12 +9,37 @@
|
||||
//= require bootstrap-notify/bootstrap-notify.js
|
||||
//= require node-waves/waves.js
|
||||
//= require sweetalert/sweetalert.min.js
|
||||
//= require fileinput.min
|
||||
//= require cable
|
||||
//= require turbolinks
|
||||
//= require BSBMaterial/turbolink_admin.js
|
||||
//= require BSBMaterial/demo.js
|
||||
//= require custom.js
|
||||
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
|
||||
$("#customer_image_path").fileinput({
|
||||
previewFileType: "image",
|
||||
allowedFileExtensions: ["jpg", "gif", "png"],
|
||||
browseClass: "btn btn-success",
|
||||
browseLabel: "Pick Image",
|
||||
browseIcon: "<i class=\"fa fa-image\"></i> ",
|
||||
removeClass: "btn btn-danger",
|
||||
removeLabel: "Delete",
|
||||
removeIcon: "<i class=\"fa fa-trash\"></i> ",
|
||||
showUpload: false,
|
||||
// uploadClass: "btn btn-info",
|
||||
// uploadLabel: "Upload",
|
||||
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
|
||||
previewTemplates: {
|
||||
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
|
||||
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
|
||||
'</div>\n',
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.datetimepicker').bootstrapMaterialDatePicker({
|
||||
format: 'DD-MM-YYYY - HH:mm',
|
||||
@@ -224,7 +249,7 @@ function setCommPorts(comPortLists) {
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment";
|
||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment/others_payment";
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -298,7 +323,7 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
|
||||
if(jobj.STATUS == "Approved"){
|
||||
$.ajax({type: "POST",
|
||||
url: "/origami/payment/"+payment_type,
|
||||
data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id,
|
||||
data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id + "&ref_no=" + jobj.REFNUM,
|
||||
success:function(result){
|
||||
if(result){
|
||||
swal({
|
||||
@@ -317,6 +342,8 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun
|
||||
}else{
|
||||
if(payment_type!="master"){
|
||||
payment_type = payment_type.toUpperCase();
|
||||
}else{
|
||||
payment_type = "Master";
|
||||
}
|
||||
swal({
|
||||
title: 'Oops',
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
@import "BSBMaterial/style";
|
||||
@import "BSBMaterial/themes/all-themes";
|
||||
@import "reset";
|
||||
@import "fileinput.min";
|
||||
|
||||
.sx-margin-0 {
|
||||
margin: 0 !important;
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
background-color: #2790a5;
|
||||
}
|
||||
|
||||
.active_tab{
|
||||
border-style: solid;
|
||||
border-color: #2790a5;
|
||||
}
|
||||
|
||||
.login-page {
|
||||
margin: 0% auto;
|
||||
background-color: #2790a5;
|
||||
@@ -75,3 +80,13 @@
|
||||
background-color: #fff;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.p-card{
|
||||
margin: 20px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.p-name{
|
||||
padding-bottom: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@@ -198,6 +198,18 @@ select.form-control {
|
||||
background-color: blue !important;
|
||||
}
|
||||
|
||||
.selected-payment {
|
||||
color: #fff !important;
|
||||
background-color: blue !important;
|
||||
}
|
||||
.payment_btn {
|
||||
white-space: normal !important;
|
||||
margin-bottom: 15px;
|
||||
margin-right: 15px;
|
||||
color:#fff !important;
|
||||
# background-color: green !important;
|
||||
}
|
||||
|
||||
/* Reciept Style */
|
||||
#order-charges-table td {
|
||||
border-top: none !important;
|
||||
@@ -314,7 +326,7 @@ tr.discount-item-row:hover {
|
||||
position: relative;
|
||||
left: 42%;
|
||||
top: 30%;
|
||||
background-color: #d9534f;
|
||||
background-color: #32ad1a;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
width: 200px;
|
||||
@@ -396,3 +408,27 @@ i.logout_icon{
|
||||
color: #fff !important;
|
||||
background-color: #5DADE2 !important;
|
||||
}
|
||||
|
||||
/* Start Is Member Modal */
|
||||
#is_memberModal .modal-body {
|
||||
height: 260px !important;
|
||||
}
|
||||
|
||||
#is_memberModal .btn {
|
||||
width: 80%;
|
||||
}
|
||||
/* End Is Member Modal */
|
||||
|
||||
/* Start iframe */
|
||||
iframe {
|
||||
border: none;
|
||||
overflow: hidden !important;
|
||||
width: 400px;
|
||||
height: 550px;
|
||||
}
|
||||
|
||||
#pdfModal .btn {
|
||||
width: 150%;
|
||||
height: 100%;
|
||||
}
|
||||
/* End iframe */
|
||||
@@ -67,7 +67,8 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
}
|
||||
#end extra time
|
||||
|
||||
puts params[:order_items]
|
||||
puts "ORDER ITEMS"
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@@ -171,9 +172,9 @@ class Api::OrdersController < Api::ApiController
|
||||
# Update customer info, Guest Info
|
||||
# Input Params
|
||||
# order_id , order_items {[item_code, item_instance_code , qty, option, variants]}
|
||||
def update
|
||||
# def update
|
||||
|
||||
end
|
||||
# end
|
||||
|
||||
def order_params
|
||||
params.permits(:order_source, :booking_id,:order_type,
|
||||
@@ -198,4 +199,59 @@ class Api::OrdersController < Api::ApiController
|
||||
end
|
||||
return status
|
||||
end
|
||||
|
||||
def update
|
||||
Rails.logger.debug "Booking ID - " + params[:booking_id].to_s
|
||||
if checkin_checkout_time(params[:booking_id])
|
||||
Rails.logger.debug "Order Item ID - " + params[:order_item_id].to_s
|
||||
|
||||
order_items_id = params[:order_item_id]
|
||||
qty_weight = params[:quantity].to_f
|
||||
remarks = params[:remark]
|
||||
|
||||
order_item = OrderItem.find(order_items_id)
|
||||
before_updated_qty = order_item.qty
|
||||
|
||||
order_item.item_order_by = current_login_employee.name
|
||||
order_item.qty = qty_weight
|
||||
order_item.remark = remarks
|
||||
order_item.save
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# print
|
||||
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
|
||||
# order queue stations
|
||||
oqs = assigned_item.order_queue_station
|
||||
|
||||
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
||||
|
||||
unique_code="OrderItemPdf"
|
||||
if !order_slim_pdf.empty?
|
||||
order_slim_pdf.each do |order_item_slim|
|
||||
if order_item_slim[0] == 'OrderSlimPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
unique_code="OrderItemSlimPdf"
|
||||
else
|
||||
unique_code="OrderItemPdf"
|
||||
end
|
||||
elsif order_item_slim[0] == 'OrderSetPdf'
|
||||
if order_item_slim[1] == '1'
|
||||
unique_code="OrderSetItemPdf"
|
||||
else
|
||||
unique_code="OrderItemPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
|
||||
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
|
||||
end
|
||||
|
||||
return return_json_status_with_code(200, "updated successfully!")
|
||||
else
|
||||
return return_json_status_with_code(406, "Checkout time is over!")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -84,6 +84,17 @@ class Api::PaymentsController < ActionController::API
|
||||
sale_payment.payment_reference = params[:payment_reference]
|
||||
#TODO: implement paypar implementation
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
when "JunctionPay"
|
||||
sale_payment.payment_method = "JunctionPay"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.customer_id = params[:customer_id]
|
||||
sale_payment.payment_reference = params[:vochure_no]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
when "alipay"
|
||||
sale_payment.payment_method = "alipay"
|
||||
sale_payment.received_amount = params[:amount]
|
||||
sale_payment.payment_reference = params[:payment_reference]
|
||||
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
class BaseController < ActionController::Base
|
||||
layout "installation"
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,11 +2,36 @@ class BaseCrmController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "CRM"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
#change locallization
|
||||
def set_locale
|
||||
I18n.locale = params[:locale] || I18n.default_locale
|
||||
end
|
||||
|
||||
# RESTful url for localize
|
||||
def default_url_options
|
||||
{ locale: I18n.locale }
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,11 +2,26 @@ class BaseInventoryController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "inventory"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,11 +2,36 @@ class BaseOqsController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "OQS"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
#change locallization
|
||||
def set_locale
|
||||
I18n.locale = params[:locale] || I18n.default_locale
|
||||
end
|
||||
|
||||
# RESTful url for localize
|
||||
def default_url_options
|
||||
{ locale: I18n.locale }
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,19 +2,22 @@ class BaseOrigamiController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "origami"
|
||||
|
||||
# before_action :checkin_process
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
# redirect_to origami_root_path
|
||||
redirect_to origami_dashboard_path
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
# def checkin_process
|
||||
@@ -25,4 +28,10 @@ class BaseOrigamiController < ActionController::Base
|
||||
def get_cashier
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,10 +2,14 @@ class BaseReportController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "application"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
helper_method :shop_detail
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
@@ -80,4 +84,15 @@ class BaseReportController < ActionController::Base
|
||||
|
||||
return from, to
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,6 +2,21 @@ class BaseWaiterController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "waiter"
|
||||
|
||||
before_action :check_user
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,10 +33,10 @@ module LoginVerification
|
||||
protected
|
||||
# Authenticate the user with token based authentication
|
||||
def authenticate
|
||||
authenticate_session_token || render_unauthorized
|
||||
authenticate_session_token || render_unauthorized
|
||||
end
|
||||
|
||||
def authenticate_session_token
|
||||
def authenticate_session_token
|
||||
token = session[:session_token]
|
||||
if (token)
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
@@ -50,7 +50,7 @@ module LoginVerification
|
||||
end
|
||||
end
|
||||
|
||||
def render_unauthorized()
|
||||
def render_unauthorized
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
|
||||
@@ -15,9 +15,4 @@ class Crm::BookingsController < BaseCrmController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -143,7 +143,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -269,7 +269,7 @@ end
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -328,7 +328,7 @@ end
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -396,12 +396,7 @@ end
|
||||
def customer_params
|
||||
|
||||
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type)
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :image_path)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -142,10 +142,5 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
def dining_queue_params
|
||||
params.require(:dining_queue).permit(:customer_id, :name, :contact_no, :queue_no,:status,:seater,:remark)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -56,10 +56,5 @@ class Crm::HomeController < BaseCrmController
|
||||
# end
|
||||
# end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
class HomeController < ApplicationController
|
||||
# layout "application", except: [:index, :show]
|
||||
# skip_before_action only: [:index, :show, :create, :update, :destroy]
|
||||
# skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
|
||||
|
||||
before_action :check_user, only: :dashboard
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
# Special check for only dashboard
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
def index
|
||||
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
||||
@@ -65,63 +80,78 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def dashboard
|
||||
@from, @to = get_date_range_from_params
|
||||
@from, @to, @from_time, @to_time = get_date_range_from_params
|
||||
|
||||
@shop = Shop.first
|
||||
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
|
||||
@top_products = Sale.top_products(today,@from,@to).sum('i.qty')
|
||||
@bottom_products = Sale.bottom_products(today,@from,@to).sum('i.qty')
|
||||
@hourly_sales = Sale.hourly_sales(today,@from,@to).sum(:grand_total)
|
||||
if !@from.nil? && !@to.nil?
|
||||
if !@from_time.nil? && @to_time.nil?
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
|
||||
else
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
end
|
||||
else
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
if !@from.nil? && !@to.nil?
|
||||
if !@from_time.nil? && @to_time.nil?
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}' and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%m') between '#{@from_time}' and '#{@to_time}'").count()
|
||||
else
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
end
|
||||
else
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
@top_products = Sale.top_products(today,current_user,@from,@to,@from_time,@to_time).sum('i.qty')
|
||||
@bottom_products = Sale.bottom_products(today,current_user,@from,@to,@from_time,@to_time).sum('i.qty')
|
||||
@hourly_sales = Sale.hourly_sales(today,current_user,@from,@to,@from_time,@to_time).sum(:grand_total)
|
||||
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
|
||||
# .sum(:grand_total)
|
||||
@employee_sales = Sale.employee_sales(today,@from,@to)
|
||||
@employee_sales = Sale.employee_sales(today,current_user,@from,@to,@from_time,@to_time)
|
||||
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
|
||||
@inventories = StockJournal.inventory_balances(today,@from,@to).sum(:balance)
|
||||
@inventories = StockJournal.inventory_balances(today,@from,@to,@from_time,@to_time).sum(:balance)
|
||||
|
||||
@total_sale = Sale.total_sale(today,current_user,@from,@to)
|
||||
@total_count = Sale.total_count(today,current_user,@from,@to)
|
||||
@total_card = Sale.total_card_sale(today,current_user,@from,@to)
|
||||
@total_credit = Sale.credit_payment(today,current_user,@from,@to)
|
||||
@total_sale = Sale.total_sale(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_count = Sale.total_count(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_card = Sale.total_card_sale(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_credit = Sale.credit_payment(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
@sale_data = Array.new
|
||||
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to)
|
||||
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
if !@total_payment_methods.nil?
|
||||
@total_payment_methods.each do |payment|
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
|
||||
pay = Sale.payment_sale('card', today, current_user,@from,@to)
|
||||
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay"
|
||||
pay = Sale.payment_sale('card', today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({'card' => pay.payment_amount})
|
||||
else
|
||||
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to)
|
||||
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to,@from_time,@to_time)
|
||||
@sale_data.push({payment.payment_method => pay.payment_amount})
|
||||
end
|
||||
end
|
||||
end
|
||||
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to)
|
||||
@total_customer = Sale.total_customer(today,current_user,@from,@to)
|
||||
@total_dinein = Sale.total_dinein(today,current_user,@from,@to)
|
||||
@total_takeaway = Sale.total_takeaway(today,current_user,@from,@to)
|
||||
@total_other_customer = Sale.total_other_customer(today,current_user,@from,@to)
|
||||
@total_membership = Sale.total_membership(today,current_user,@from,@to)
|
||||
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_customer = Sale.total_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_dinein = Sale.total_dinein(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_takeaway = Sale.total_takeaway(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_other_customer = Sale.total_other_customer(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_membership = Sale.total_membership(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
@total_order = Sale.total_order(today,current_user,@from,@to)
|
||||
@total_accounts = Sale.total_account(today,current_user,@from,@to)
|
||||
@total_order = Sale.total_order(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_accounts = Sale.total_account(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@account_data = Array.new
|
||||
if !@total_accounts.nil?
|
||||
@total_accounts.each do |account|
|
||||
acc = Sale.account_data(account.account_id, today,current_user,@from,@to)
|
||||
acc = Sale.account_data(account.account_id, today,current_user,@from,@to,@from_time,@to_time)
|
||||
if !acc.nil?
|
||||
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@top_items = Sale.top_items(today,current_user,@from,@to)
|
||||
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to)
|
||||
@top_items = Sale.top_items(today,current_user,@from,@to,@from_time,@to_time)
|
||||
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to,@from_time,@to_time)
|
||||
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
@@ -135,12 +165,6 @@ class HomeController < ApplicationController
|
||||
render :json => {:status=> "Success", :url => root_path }.to_json
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
@@ -181,17 +205,27 @@ class HomeController < ApplicationController
|
||||
|
||||
def get_date_range_from_params
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
to = params[:to]
|
||||
from_time = params[:from_time]
|
||||
to_time = params[:to_time]
|
||||
|
||||
if from.present? && to.present?
|
||||
f_date = DateTime.parse(from)
|
||||
t_date = DateTime.parse(to)
|
||||
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
||||
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
||||
from = f_time.beginning_of_day.utc.getlocal
|
||||
to = t_time.end_of_day.utc.getlocal
|
||||
# f_date = DateTime.parse(from)
|
||||
# t_date = DateTime.parse(to)
|
||||
# f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
|
||||
# t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
|
||||
# from = f_time.beginning_of_day.utc.getlocal
|
||||
# to = t_time.end_of_day.utc.getlocal
|
||||
|
||||
from = DateTime.parse(from).utc.getlocal.strftime('%Y-%m-%d')
|
||||
to = DateTime.parse(to).utc.getlocal.strftime('%Y-%m-%d')
|
||||
end
|
||||
|
||||
return from, to
|
||||
return from, to, from_time, to_time
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,8 @@ class InstallController < BaseController
|
||||
skip_before_action :verify_authenticity_token
|
||||
# before_action :check_license
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
@@ -75,4 +77,9 @@ class InstallController < BaseController
|
||||
# return nil
|
||||
# end
|
||||
# end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,12 +30,6 @@ class Oqs::HomeController < BaseOqsController
|
||||
@queue_stations_items
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
# Get Order items
|
||||
def get_order_items
|
||||
items = []
|
||||
@@ -129,9 +123,4 @@ class Oqs::HomeController < BaseOqsController
|
||||
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
6
app/controllers/oqs/edit_controller.rb
Executable file → Normal file
6
app/controllers/oqs/edit_controller.rb
Executable file → Normal file
@@ -3,9 +3,15 @@ class Oqs::EditController < BaseOqsController
|
||||
assigned_item_id = params[:id]
|
||||
@link_type = params[:type]
|
||||
@dining_type = nil
|
||||
@booking = nil
|
||||
if params[:type] == 'oqs'
|
||||
assigned_item = AssignedOrderItem.find(assigned_item_id)
|
||||
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'")
|
||||
elsif params[:type] == "pending"
|
||||
assigned_item = OrderItem.find(assigned_item_id)
|
||||
@booking = Booking.joins(" JOIN booking_orders as bko on bko.booking_id = bookings.booking_id")
|
||||
.where("bko.order_id = '#{assigned_item.order_id}'").first()
|
||||
@order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.item_instance_code }'")
|
||||
else
|
||||
assigned_item = OrderItem.find(assigned_item_id)
|
||||
dining = DiningFacility.find_by_id(params[:type])
|
||||
|
||||
@@ -244,10 +244,4 @@ class Oqs::HomeController < BaseOqsController
|
||||
.group("order_queue_stations.id")
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -102,9 +102,4 @@ class Oqs::PrintController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
class Origami::AddordersController < BaseOrigamiController
|
||||
# before_action :set_dining, only: [:detail]
|
||||
|
||||
|
||||
def index
|
||||
@tables = Table.all.active.order('zone_id asc').group("zone_id")
|
||||
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
|
||||
@@ -94,20 +94,20 @@ 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)
|
||||
}
|
||||
|
||||
# begin
|
||||
if params[:order_source] == "quick_service"
|
||||
customer_id = "CUS-000000000002" # for no customer id from mobile
|
||||
else
|
||||
# if params[:order_source] == "quick_service"
|
||||
# customer_id = "CUS-000000000002" # for no customer id from mobile
|
||||
# else
|
||||
customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
end
|
||||
# end
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@@ -226,9 +226,4 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
# @dining = DiningFacility.find(params[:id])
|
||||
# end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
77
app/controllers/origami/alipay_controller.rb
Normal file
77
app/controllers/origami/alipay_controller.rb
Normal file
@@ -0,0 +1,77 @@
|
||||
class Origami::AlipayController < BaseOrigamiController
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
# limit alipay_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = 0
|
||||
@alipaycount = 0
|
||||
@shop = Shop::ShopDetail
|
||||
@rounding_adj = 0
|
||||
@can_alipay = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "alipay"
|
||||
@alipaycount = @alipaycount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_alipay = total - @alipaycount - others
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@bank_integration = bank_integration[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
@@ -96,9 +96,4 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon
|
||||
render json: response
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,9 +24,4 @@ class Origami::CardPaymentsController < BaseOrigamiController
|
||||
def create
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,10 +14,5 @@ class Origami::CashInsController < BaseOrigamiController
|
||||
shift.cash_in = shift.cash_in + amount.to_i
|
||||
shift.save
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,9 +8,4 @@ class Origami::CashMgmtController < ApplicationController
|
||||
def create
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,9 +13,4 @@ class Origami::CashOutsController < BaseOrigamiController
|
||||
shift.save
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,9 +36,4 @@ class Origami::CheckInProcessController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,10 +47,4 @@ class Origami::CreditPaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -98,10 +98,10 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
customer_id = params[:customer_id]
|
||||
customer = Customer.find(customer_id)
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
customer_id = params[:customer_id]
|
||||
customer = Customer.find(customer_id)
|
||||
order_source = params[:type]
|
||||
# Check and find with card no
|
||||
# if(!customer_id.include? "CUS")
|
||||
# customer = Customer.find_by_paypar_account_no(customer_id)
|
||||
@@ -135,16 +135,11 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
if(id == "SAL")
|
||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
|
||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount, nil, order_source)
|
||||
end
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -58,8 +58,4 @@ class Origami::DashboardController < BaseOrigamiController
|
||||
@current_user = current_user
|
||||
end
|
||||
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,10 +20,12 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
#discount page show from origami index with selected order
|
||||
def create
|
||||
order_source = params[:cashier_type]
|
||||
sale_id = params[:sale_id]
|
||||
discount_items = JSON.parse(params[:discount_items])
|
||||
overall_discount = params[:overall_discount]
|
||||
sub_total = params[:sub_total]
|
||||
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
@@ -82,7 +84,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
|
||||
end
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f, nil,order_source)
|
||||
if !table.nil?
|
||||
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
|
||||
else
|
||||
@@ -102,6 +104,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
# Remove selected discount Items
|
||||
def remove_discount_items
|
||||
order_source = params[:cashier_type]
|
||||
sale_id = params[:sale_id]
|
||||
discount_items = JSON.parse(params[:discount_items])
|
||||
if Sale.exists?(sale_id)
|
||||
@@ -136,7 +139,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax;
|
||||
# sale.save
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, order_source)
|
||||
if table.nil?
|
||||
result = {:status=> "Success"}
|
||||
else
|
||||
@@ -158,6 +161,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
# Remove all discount Items
|
||||
def remove_all_discount
|
||||
sale_id = params[:id]
|
||||
order_source = params[:type]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
@@ -197,7 +201,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, 0, nil, order_source)
|
||||
if table.nil?
|
||||
result = {:status=> "Success"}
|
||||
else
|
||||
@@ -218,7 +222,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
# Member Discount
|
||||
def member_discount
|
||||
|
||||
order_source = params[:cashier_type]
|
||||
sale_id = params[:sale_id]
|
||||
is_card = params[:is_card]
|
||||
sub_total = params[:sub_total]
|
||||
@@ -273,7 +277,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10)
|
||||
rescue HTTParty::Error
|
||||
response = {"status": false, "message": "Can't open membership server " }
|
||||
@@ -297,7 +301,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
if response["discount_bonus_earned"]
|
||||
discount_amount = discount_amount + response["discount_bonus_earned"]
|
||||
end
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount', order_source)
|
||||
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
|
||||
elsif response["status"] == "500"
|
||||
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||
@@ -355,9 +359,5 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
|
||||
# redirect_to origami_path(sale_id)
|
||||
# end
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -74,16 +74,6 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@date = order.created_at
|
||||
@booking= booking
|
||||
order.order_items.each do |item|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
end
|
||||
item.set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
@order_items.push(item)
|
||||
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
|
||||
# if !assigned_order_items.nil?
|
||||
@@ -105,7 +95,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@status_order = 'order'
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
@@ -136,12 +126,6 @@ class Origami::HomeController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_dining
|
||||
|
||||
@@ -81,9 +81,4 @@ class Origami::HomeController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -169,9 +169,4 @@ class Origami::InDutiesController < BaseOrigamiController
|
||||
params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
58
app/controllers/origami/jcb_controller.rb
Executable file → Normal file
58
app/controllers/origami/jcb_controller.rb
Executable file → Normal file
@@ -5,32 +5,43 @@ class Origami::JcbController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
# limit jcb_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
total = 0
|
||||
@jcbcount = 0
|
||||
others = 0
|
||||
@shop = Shop::ShopDetail
|
||||
@rounding_adj = 0
|
||||
@can_jcb = 0
|
||||
@member_discount= 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "jcb"
|
||||
@jcbcount = @jcbcount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_jcb = total - @jcbcount - others
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "jcb"
|
||||
@jcbcount = @jcbcount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_jcb = total - @jcbcount - others
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@@ -41,6 +52,7 @@ class Origami::JcbController < BaseOrigamiController
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
@@ -54,7 +66,7 @@ class Origami::JcbController < BaseOrigamiController
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb")
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
70
app/controllers/origami/junction_pay_controller.rb
Normal file
70
app/controllers/origami/junction_pay_controller.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
class Origami::JunctionPayController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
@sale_id = params[:sale_id]
|
||||
@cashier_type = params[:type]
|
||||
# limit jcb_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
@junction_pay_count = 0
|
||||
others = 0
|
||||
@cashier_id = current_user.emp_id
|
||||
|
||||
@payment_method_setting_nav = PaymentMethodSetting.all
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "JunctionPay"
|
||||
@junction_pay_count = @junction_pay_count + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_junction_pay = total - @junction_pay_count - others
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
|
||||
def create
|
||||
gift_amount = params[:gift_amount]
|
||||
voucher_amount = params[:voucher_amount]
|
||||
voucher_no = params[:voucher_no]
|
||||
sale_id = params[:sale_id]
|
||||
|
||||
# Gift card or Voucher classified and add for payment_reference
|
||||
remarks = ''
|
||||
cash = (gift_amount.to_f + voucher_amount.to_f)
|
||||
if gift_amount.to_f > 0
|
||||
remarks = "Junciton Gift Card Payment. RefNo-" + voucher_no
|
||||
else
|
||||
remarks = "Junciton Voucher Payment. RefNo-" + voucher_no
|
||||
end
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
|
||||
# rounding adjustment
|
||||
# if shop_details.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
# rounding_adj = new_total-saleObj.grand_total
|
||||
# saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
# end
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "JunctionPay", remarks)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
57
app/controllers/origami/master_controller.rb
Executable file → Normal file
57
app/controllers/origami/master_controller.rb
Executable file → Normal file
@@ -5,31 +5,41 @@ class Origami::MasterController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
# limit master_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
total = 0
|
||||
@mastercount = 0
|
||||
others = 0
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
@shop = Shop::ShopDetail
|
||||
@rounding_adj = 0
|
||||
@can_master = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "master"
|
||||
@mastercount = @mastercount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "master"
|
||||
@mastercount = @mastercount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_master = total - @mastercount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
@can_master = total - @mastercount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@@ -40,6 +50,7 @@ class Origami::MasterController < BaseOrigamiController
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
@@ -53,7 +64,7 @@ class Origami::MasterController < BaseOrigamiController
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master")
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -35,11 +35,5 @@ class Origami::MoveroomController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -70,10 +70,5 @@ class Origami::MovetableController < BaseOrigamiController
|
||||
|
||||
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
60
app/controllers/origami/mpu_controller.rb
Executable file → Normal file
60
app/controllers/origami/mpu_controller.rb
Executable file → Normal file
@@ -4,32 +4,43 @@ class Origami::MpuController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
# limit mpu_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
total = 0
|
||||
@mpucount = 0
|
||||
others = 0
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "mpu"
|
||||
@mpucount = @mpucount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_mpu = total - @mpucount - others
|
||||
@rounding_adj = 0
|
||||
@can_mpu = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "mpu"
|
||||
@mpucount = @mpucount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_mpu = total - @mpucount - others
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@@ -40,6 +51,7 @@ class Origami::MpuController < BaseOrigamiController
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
@@ -53,7 +65,7 @@ class Origami::MpuController < BaseOrigamiController
|
||||
|
||||
# saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu")
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -80,10 +80,5 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -19,6 +19,7 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
sale_id = params[:sale_id]
|
||||
other_charges_items = JSON.parse(params[:other_charges_items])
|
||||
sub_total = params[:sub_total]
|
||||
cashier_type = params[:cashier_type]
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find(sale_id)
|
||||
@@ -68,7 +69,7 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
end
|
||||
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount, nil, cashier_type)
|
||||
end
|
||||
if !table.nil?
|
||||
dining = {:table_id => table_id, :table_type => table.type }
|
||||
@@ -76,10 +77,5 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
@@ -37,9 +37,4 @@ class Origami::OthersPaymentsController < BaseOrigamiController
|
||||
def create
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
# Print for First Bill to Customer
|
||||
unique_code = "ReceiptBillPdf"
|
||||
@@ -63,9 +63,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
# current_balance = 0
|
||||
# member_info = Customer.get_member_account(customer)
|
||||
# current_balance = SaleAudit.paymal_search(sale_id)
|
||||
current_balance = 0
|
||||
end
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
@@ -79,8 +79,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
|
||||
end
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
|
||||
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -104,7 +113,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
#end rounding adjustment
|
||||
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")
|
||||
|
||||
@@ -129,7 +138,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
# For Print
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
unique_code = "ReceiptBillPdf"
|
||||
if !receipt_bill_a5_pdf.empty?
|
||||
@@ -156,6 +165,23 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
|
||||
#orders print out
|
||||
if params[:type] == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table_id = booking.dining_facility_id
|
||||
else
|
||||
table_id = 0
|
||||
end
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
# Order.pay_process_order_queue(order.order_id, table_id)
|
||||
oqs = OrderQueueStation.new
|
||||
oqs.pay_process_order_queue(order.order_id, table_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#for card sale data
|
||||
card_data = Array.new
|
||||
card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
|
||||
@@ -180,19 +206,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
|
||||
|
||||
if params[:type] == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
if booking.dining_facility_id.to_i>0
|
||||
table_id = booking.dining_facility_id
|
||||
else
|
||||
table_id = 0
|
||||
end
|
||||
|
||||
booking.booking_orders.each do |order|
|
||||
Order.pay_process_order_queue(order.order_id,table_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
#end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -210,16 +224,20 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@jcbcount= 0.0
|
||||
@mastercount = 0.0
|
||||
@unionpaycount = 0.0
|
||||
@alipaycount = 0.0
|
||||
@junctionpaycount = 0.0
|
||||
@credit = 0.0
|
||||
@paymalcount = 0.0
|
||||
@sale_data = Sale.find_by_sale_id(sale_id)
|
||||
@balance = 0.00
|
||||
@balance = 0
|
||||
@accountable_type = ''
|
||||
@table_no = ''
|
||||
@dining = ''
|
||||
|
||||
@shop = Shop::ShopDetail #show shop info
|
||||
|
||||
@customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'")
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
#total customer with individual total amount
|
||||
@@ -269,10 +287,11 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
accounts = @customer.tax_profiles
|
||||
# accounts = @customer.tax_profiles
|
||||
accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC")
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
account = TaxProfile.find(acc.id)
|
||||
@account_arr.push(account)
|
||||
end
|
||||
|
||||
@@ -283,7 +302,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if response["status"]==true
|
||||
response["account_data"].each do |res|
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
@balance += res["balance"]
|
||||
@balance = @balance.to_f + res["balance"].to_f
|
||||
# @accountable_type = res["accountable_type"]
|
||||
@accountable_type = "Rebate Balance"
|
||||
end
|
||||
@@ -323,10 +342,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@mastercount += spay.payment_amount
|
||||
elsif spay.payment_method == "unionpay"
|
||||
@unionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "JunctionPay"
|
||||
@junctionpaycount += spay.payment_amount
|
||||
elsif spay.payment_method == "creditnote"
|
||||
@credit += spay.payment_amount
|
||||
elsif spay.payment_method == "paymal"
|
||||
@paymalcount += spay.payment_amount
|
||||
elsif spay.payment_method == "alipay"
|
||||
@alipaycount += spay.payment_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -402,19 +425,19 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
current_balance = nil
|
||||
order_source = params[:type]
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
if saleObj.discount_type == "member_discount"
|
||||
saleObj.update_attributes(rounding_adjustment: 0)
|
||||
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0)
|
||||
saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0,order_source)
|
||||
end
|
||||
|
||||
saleObj.update_attributes(rounding_adjustment: 0)
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
# if bookings.count > 1
|
||||
@@ -436,7 +459,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# Re-call Sale Data
|
||||
saleObj = Sale.find(sale_id)
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
@@ -450,7 +473,17 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil)
|
||||
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil)
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
|
||||
if params[:type] == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
@@ -464,7 +497,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
Order.pay_process_order_queue(order.order_id,table_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -510,12 +543,15 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name)
|
||||
|
||||
render :json => {status: true}
|
||||
end
|
||||
result = {
|
||||
:status => true,
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# render :json => {status: true}
|
||||
end
|
||||
end
|
||||
@@ -29,9 +29,4 @@ class Origami::PayparPaymentsController < BaseOrigamiController
|
||||
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,9 +41,4 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -137,9 +137,4 @@ class Origami::ProductCommissionsController < BaseOrigamiController
|
||||
params.fetch(:product_commission, {})
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
class Origami::QuickServiceController < ApplicationController
|
||||
# before_action :set_dining, only: [:detail]
|
||||
|
||||
before_action :check_user
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
today = DateTime.now
|
||||
day = Date.today.wday
|
||||
@@ -211,6 +217,11 @@ class Origami::QuickServiceController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
# this can always true
|
||||
def check_order_with_booking(booking)
|
||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
|
||||
|
||||
@@ -6,6 +6,7 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
@membership_rebate_balance=0
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
|
||||
@payment_method_setting_nav = PaymentMethodSetting.all
|
||||
@shop = Shop::ShopDetail
|
||||
# if @shop.is_rounding_adj
|
||||
# new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
@@ -68,10 +69,5 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
|
||||
end
|
||||
@out = false, 0
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
class Origami::RequestBillsController < ApplicationController
|
||||
|
||||
before_action :check_user
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
# Print Request Bill and add to sale tables
|
||||
def print
|
||||
@sale = Sale.new
|
||||
@@ -8,14 +14,12 @@ class Origami::RequestBillsController < ApplicationController
|
||||
if !ShiftSale.current_shift.nil?
|
||||
order_id = params[:id] # order_id
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
puts params[:id]
|
||||
puts bk_order
|
||||
puts bk_order.booking_id
|
||||
order = Order.find(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
|
||||
if check_booking.sale_id.nil?
|
||||
# Create Sale if it doesn't exist
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user)
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source)
|
||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||
else
|
||||
@@ -29,6 +33,10 @@ class Origami::RequestBillsController < ApplicationController
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(@sale)
|
||||
if order.source == "quick_service"
|
||||
result = {:status=> @status, :data => @sale.sale_id }
|
||||
render :json => result.to_json
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "No Current Open Shift for This Employee"
|
||||
@@ -56,10 +64,5 @@ class Origami::RequestBillsController < ApplicationController
|
||||
|
||||
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -37,9 +37,4 @@ class Origami::RoomInvoicesController < BaseOrigamiController
|
||||
@customer = @sale.customer
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,16 +68,6 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@date = order.created_at
|
||||
@booking = booking
|
||||
order.order_items.each do |item|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
end
|
||||
item.set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
@order_items.push(item)
|
||||
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
|
||||
# if !assigned_order_items.nil?
|
||||
@@ -89,8 +79,7 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@status_order = 'order'
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
puts "enter"
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
@@ -136,9 +125,4 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -76,11 +76,14 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMFOC" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order.source)
|
||||
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
|
||||
end
|
||||
|
||||
@@ -141,7 +144,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order.source)
|
||||
|
||||
ProductCommission.edit_product_commission(saleitemObj)
|
||||
end
|
||||
@@ -162,17 +165,21 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
# re-calc tax
|
||||
saleObj = Sale.find(saleitemObj.sale_id)
|
||||
|
||||
order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id
|
||||
order = Order.find(order_id)
|
||||
|
||||
action_by = current_user.id
|
||||
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"ITEMCANCELVOID" )
|
||||
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount, order.source)
|
||||
ProductCommission.remove_product_commission(saleitemObj)
|
||||
end
|
||||
|
||||
# remove all void items
|
||||
def cancel_all_void
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:type]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.sale_items.each do |item|
|
||||
if item.qty.to_i < 0
|
||||
@@ -185,21 +192,17 @@ class Origami::SaleEditController < BaseOrigamiController
|
||||
end
|
||||
|
||||
# re-calc tax
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount)
|
||||
saleObj.compute_by_sale_items(saleObj.sale_id, saleObj.sale_items, saleObj.total_discount,order_source)
|
||||
end
|
||||
|
||||
def apply_void
|
||||
sale_id = params[:sale_id]
|
||||
order_source = params[:type]
|
||||
saleObj = Sale.find(sale_id)
|
||||
saleObj.compute_without_void
|
||||
saleObj.compute_without_void(order_source)
|
||||
saleObj.sale_items.each do |item|
|
||||
ProductCommission.remove_product_commission(item)
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -56,9 +56,4 @@ class Origami::SalesController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def show
|
||||
@cashier_type = params[:type]
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
#for bank integration
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@@ -125,9 +126,4 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
71
app/controllers/origami/split_bill_controller.rb
Normal file → Executable file
71
app/controllers/origami/split_bill_controller.rb
Normal file → Executable file
@@ -3,6 +3,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
|
||||
def index
|
||||
dining_id = params[:dining_id]
|
||||
@cashier_type = params[:type]
|
||||
@table = DiningFacility.find(dining_id)
|
||||
@booking = @table.get_booking
|
||||
@orders = Array.new
|
||||
@@ -76,7 +77,12 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def create
|
||||
cashier_type = params[:cashier_type]
|
||||
order_ids = params[:order_ids]
|
||||
arr_order_ids = nil
|
||||
if !params[:arr_order_ids].nil?
|
||||
arr_order_ids = JSON.parse(params[:arr_order_ids])
|
||||
end
|
||||
orders = nil
|
||||
if !params[:orders].empty?
|
||||
orders = JSON.parse(params[:orders])
|
||||
@@ -107,7 +113,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
if booking
|
||||
if booking.sale_id.nil?
|
||||
sale = Sale.new
|
||||
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user)
|
||||
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type)
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
else
|
||||
status = true
|
||||
@@ -136,14 +142,15 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
order_id_count = 0
|
||||
order_id = nil
|
||||
|
||||
order_items.each do |order_item|
|
||||
order_item_count = 0
|
||||
order = Order.find(order_item["order_id"])
|
||||
if order.order_items.count == 1
|
||||
order_id = order.id
|
||||
order_id_count += 1
|
||||
else
|
||||
order_item_count += 1
|
||||
arr_order_ids.each do |order|
|
||||
order.each do |odr|
|
||||
data = Order.find(odr[0])
|
||||
if data.order_items.count == odr[1]
|
||||
order_id = odr[0]
|
||||
order_id_count += 1
|
||||
else
|
||||
order_item_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -158,10 +165,12 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
puts "order_id_count > 1"
|
||||
|
||||
updated_order_id = Array.new
|
||||
order_ids.each do |odr_id|
|
||||
odr = Order.find(odr_id)
|
||||
if odr.order_items.count > 1
|
||||
updated_order_id.push(odr_id)
|
||||
arr_order_ids.each do |order|
|
||||
order.each do |odr|
|
||||
data = Order.find(odr[0])
|
||||
if data.order_items.count != odr[1]
|
||||
updated_order_id.push(odr[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -226,7 +235,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
puts "order_id_count < 1"
|
||||
new_order_status = true
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find_by_order_id(order_id)
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if !orderItem.nil?
|
||||
if order_item["id"] == orderItem.order_items_id
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
@@ -266,12 +275,32 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
else
|
||||
# puts order_ids
|
||||
if order_ids.count == 1 && order_id_count == 0 && order_item_count == 1
|
||||
BookingOrder.find_by_order_id(order_ids[0]).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_ids[0], order_item)
|
||||
if order_ids.count == 1 && order_item_count == 1
|
||||
if order_id_count == 0
|
||||
customer = Customer.find(params[:customer_id])
|
||||
order_type = "dine_in"
|
||||
if !customer.nil?
|
||||
if customer.customer_type == "Takeaway"
|
||||
order_type = "takeaway"
|
||||
elsif customer.customer_type == "Delivery"
|
||||
order_type = "delivery"
|
||||
end
|
||||
end
|
||||
|
||||
# begin
|
||||
order = create_order(params,order_type,order_items.count,current_user)
|
||||
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order.order_id, order_item)
|
||||
end
|
||||
else
|
||||
BookingOrder.find_by_order_id(order_ids[0]).delete
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
|
||||
order_items.each do |order_item|
|
||||
update_order_item(order_ids[0], order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
customer = Customer.find(params[:customer_id])
|
||||
@@ -297,7 +326,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
|
||||
sale = Sale.new
|
||||
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user)
|
||||
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type)
|
||||
end
|
||||
|
||||
Promotion.promo_activate(sale)
|
||||
|
||||
@@ -90,10 +90,5 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
def survey_params
|
||||
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -31,6 +31,8 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
|
||||
def show
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
shop = Shop::ShopDetail
|
||||
@sale_array = Array.new
|
||||
@table.bookings.each do |booking|
|
||||
@@ -70,9 +72,4 @@ class Origami::TableInvoicesController < BaseOrigamiController
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,31 +4,40 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
# limit unionpay_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
total = 0
|
||||
@unionpaycount = 0
|
||||
others = 0
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
@rounding_adj = 0
|
||||
@can_unionpay = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "unionpay"
|
||||
@unionpaycount = @unionpaycount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_unionpay = total - @unionpaycount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "unionpay"
|
||||
@unionpaycount = @unionpaycount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_unionpay = total - @unionpaycount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@@ -39,6 +48,7 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
@@ -53,7 +63,7 @@ class Origami::UnionpayController < BaseOrigamiController
|
||||
# saleObj = Sale.find(sale_id)
|
||||
#end rounding adjustment
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay")
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
56
app/controllers/origami/visa_controller.rb
Executable file → Normal file
56
app/controllers/origami/visa_controller.rb
Executable file → Normal file
@@ -4,31 +4,40 @@ class Origami::VisaController < BaseOrigamiController
|
||||
@cashier_type = params[:type]
|
||||
# limit visa_amount
|
||||
sale_data = Sale.find_by_sale_id(@sale_id)
|
||||
total = sale_data.grand_total
|
||||
total = 0
|
||||
@visacount = 0
|
||||
others = 0
|
||||
|
||||
@shop = Shop::ShopDetail
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
@rounding_adj = 0
|
||||
@can_visa = 0
|
||||
@member_discount = 0
|
||||
@sub_total = 0
|
||||
@membership_id = nil
|
||||
@receipt_no = nil
|
||||
if !sale_data.nil?
|
||||
total = sale_data.grand_total
|
||||
others = 0
|
||||
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
|
||||
else
|
||||
new_total = sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "visa"
|
||||
@visacount = @visacount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_visa = total - @visacount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
end
|
||||
@rounding_adj = new_total-sale_data.grand_total
|
||||
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
if sale_payment.payment_method == "visa"
|
||||
@visacount = @visacount + sale_payment.payment_amount
|
||||
else
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
end
|
||||
@can_visa = total - @visacount - others
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@sub_total = sale_data.total_amount
|
||||
@membership_id = sale_data.customer.membership_id
|
||||
#for bank integration
|
||||
@receipt_no = sale_data.receipt_no
|
||||
bank_integration = Lookup.collection_of('bank_integration')
|
||||
@bank_integration = 0
|
||||
if !bank_integration[0].nil?
|
||||
@@ -39,6 +48,7 @@ class Origami::VisaController < BaseOrigamiController
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
ref_no = params[:ref_no]
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
@@ -53,7 +63,7 @@ class Origami::VisaController < BaseOrigamiController
|
||||
# saleObj = Sale.find(sale_id)
|
||||
#end rounding adjustment
|
||||
sale_payment = SalePayment.new
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa")
|
||||
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa",ref_no)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -4,12 +4,13 @@ class Origami::VoidController < BaseOrigamiController
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
remark = params[:remark]
|
||||
order_source = params[:type] #tax profile source
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
|
||||
if sale.discount_type == "member_discount"
|
||||
sale.update_attributes(total_discount: 0)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0)
|
||||
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
||||
end
|
||||
|
||||
# update count for shift sale
|
||||
@@ -47,7 +48,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
table.bookings.each do |booking|
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void'
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
@@ -86,8 +87,6 @@ class Origami::VoidController < BaseOrigamiController
|
||||
if bookings[0].dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
@@ -99,7 +98,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
end
|
||||
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
@@ -119,9 +118,17 @@ class Origami::VoidController < BaseOrigamiController
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil)
|
||||
end
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
|
||||
#end print
|
||||
|
||||
@@ -134,10 +141,5 @@ class Origami::VoidController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
@@ -54,7 +54,7 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
@@ -78,9 +78,4 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
128
app/controllers/origami/waste_spoile_controller.rb
Executable file
128
app/controllers/origami/waste_spoile_controller.rb
Executable file
@@ -0,0 +1,128 @@
|
||||
class Origami::WasteSpoileController < BaseOrigamiController
|
||||
def waste_and_spoilage
|
||||
|
||||
sale_id = params[:sale_id]
|
||||
remark = params[:remark]
|
||||
order_source = params[:type] #tax profile source
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax|
|
||||
existing_tax.delete
|
||||
end
|
||||
sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0)
|
||||
sale.payment_status = remark
|
||||
sale.sale_status = remark
|
||||
sale.save
|
||||
|
||||
# sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
||||
# add to sale item with foc
|
||||
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
|
||||
|
||||
sale.sale_items.each do|item|
|
||||
# SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price)
|
||||
item.status = remark
|
||||
item.remark = remark
|
||||
item.save
|
||||
end
|
||||
|
||||
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||
table_avaliable = true
|
||||
table_count = 0
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
table_avaliable = true
|
||||
end
|
||||
else
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
if table_avaliable && table_count == 0
|
||||
table.status = 'available'
|
||||
table.save
|
||||
end
|
||||
else
|
||||
table = nil
|
||||
end
|
||||
|
||||
# FOr Sale Audit
|
||||
action_by = current_user.name
|
||||
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,remark )
|
||||
|
||||
# For Print
|
||||
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
current_balance = nil
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
if bookings.count > 1
|
||||
# for Multiple Booking
|
||||
if bookings[0].dining_facility_id.to_i>0
|
||||
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||
end
|
||||
end
|
||||
|
||||
if bookings[0].dining_facility_id.to_i > 0
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||
else
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||
end
|
||||
|
||||
|
||||
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(sale.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||
current_balance = SaleAudit.paymal_search(sale_id)
|
||||
end
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil)
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
# end
|
||||
|
||||
#end print
|
||||
|
||||
# update complete order items in oqs
|
||||
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||
aoi.delivery_status = 1
|
||||
aoi.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,6 +2,8 @@ class PrintSettingsController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_print_setting, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
helper_method :shop_detail
|
||||
|
||||
# GET /print_settings
|
||||
# GET /print_settings.json
|
||||
def index
|
||||
@@ -62,6 +64,17 @@ class PrintSettingsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def get_printer_options
|
||||
printer_name = params[:printer_name]
|
||||
printer_options = Printer::PrinterWorker.printer_options(printer_name)
|
||||
options = {
|
||||
:url => printer_options['device-uri'],
|
||||
:model => printer_options['printer-info'],
|
||||
}
|
||||
|
||||
render :json => options.to_json
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_print_setting
|
||||
@@ -70,6 +83,11 @@ class PrintSettingsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def print_setting_params
|
||||
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :font, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
|
||||
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :brand_name, :printer_type, :font, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,10 +16,4 @@ class Reports::SaleitemController < BaseReportController
|
||||
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -49,11 +49,6 @@ class Reports::CommissionController < BaseReportController
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -60,9 +60,4 @@ authorize_resource :class => false
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
@@ -19,10 +19,5 @@ class Reports::DailysaleController < BaseReportController
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -62,9 +62,4 @@ class Reports::PaymentMethodController < BaseReportController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
@@ -18,4 +18,10 @@ class Reports::ProductSaleController < BaseReportController
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -61,10 +61,5 @@ authorize_resource :class => false
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
@@ -15,7 +15,8 @@ class Reports::SaleitemController < BaseReportController
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
@sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED)
|
||||
@type = params[:sale_type]
|
||||
@sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type)
|
||||
|
||||
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
|
||||
|
||||
@@ -76,10 +77,5 @@ class Reports::SaleitemController < BaseReportController
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -48,10 +48,5 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -46,11 +46,6 @@ class Reports::StockCheckController < BaseReportController
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -59,9 +59,4 @@ authorize_resource :class => false
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
end
|
||||
19
app/controllers/reports/waste_and_spoilage_controller.rb
Executable file
19
app/controllers/reports/waste_and_spoilage_controller.rb
Executable file
@@ -0,0 +1,19 @@
|
||||
class Reports::WasteAndSpoilageController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
def index
|
||||
from, to = get_date_range_from_params
|
||||
@sale_type = params[:sale_type]
|
||||
@sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type)
|
||||
@from = from
|
||||
@to = to
|
||||
# get printer info
|
||||
@print_settings = PrintSetting.get_precision_delimiter()
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -1,6 +1,7 @@
|
||||
class Settings::CommissionersController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
|
||||
before_action :check_user
|
||||
|
||||
# GET /commissioners
|
||||
# GET /commissioners.json
|
||||
@@ -82,7 +83,11 @@ class Settings::CommissionersController < ApplicationController
|
||||
end
|
||||
render json: @transactions
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_commissioner
|
||||
@@ -91,6 +96,6 @@ class Settings::CommissionersController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def commissioner_params
|
||||
params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active)
|
||||
params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active, :image_path)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Settings::CommissionsController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_commission, only: [:show, :edit, :update, :destroy]
|
||||
before_action :check_user
|
||||
|
||||
# GET /commissions
|
||||
# GET /commissions.json
|
||||
@@ -68,6 +69,12 @@ class Settings::CommissionsController < ApplicationController
|
||||
# end
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_commission
|
||||
|
||||
11
app/controllers/settings/display_images_controller.rb
Normal file
11
app/controllers/settings/display_images_controller.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class Settings::DisplayImagesController < ApplicationController
|
||||
def destroy
|
||||
#byebug
|
||||
@item_photo = DisplayImage.find(params[:shop_id])
|
||||
item = @item_photo.id
|
||||
@item_photo.destroy
|
||||
respond_to do |format|
|
||||
format.html {redirect_to settings_shops_url+'/1/edit', notice: 'Image was successfully destroyed.'}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -68,6 +68,6 @@ class Settings::EmployeesController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def employee_params
|
||||
params.require(:employee).permit(:name, :role, :emp_id, :password)
|
||||
params.require(:employee).permit(:name, :role, :emp_id, :password, :image_path)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,10 @@ class Settings::MenusController < ApplicationController
|
||||
# GET /settings/menus.json
|
||||
def index
|
||||
@settings_menus = Menu.all.page(params[:page]).per(10)
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xlsx
|
||||
end
|
||||
end
|
||||
|
||||
# GET /settings/menus/1
|
||||
@@ -67,6 +71,14 @@ class Settings::MenusController < ApplicationController
|
||||
# end
|
||||
end
|
||||
|
||||
def import
|
||||
if params[:file]
|
||||
Menu.import(params[:file])
|
||||
redirect_to settings_menus_path, notice: "Menu was successfully Imported"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_menu
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Settings::OrderQueueStationsController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_settings_order_queue_station, only: [:show, :edit, :update, :destroy]
|
||||
before_action :check_user
|
||||
|
||||
# GET /settings/order_queue_stations
|
||||
# GET /settings/order_queue_stations.json
|
||||
@@ -67,6 +68,12 @@ class Settings::OrderQueueStationsController < ApplicationController
|
||||
# end
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_order_queue_station
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Settings::ProductsController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_settings_product, only: [:show, :edit, :update, :destroy]
|
||||
before_action :check_user
|
||||
|
||||
# GET /settings/products
|
||||
# GET /settings/products.json
|
||||
@@ -65,6 +66,12 @@ load_and_authorize_resource except: [:create]
|
||||
# end
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_product
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Settings::PromotionProductsController < ApplicationController
|
||||
before_action :set_promotion, only: [:show, :edit, :update, :destroy,:new]
|
||||
before_action :set_promotion_product, only: [:show, :edit, :update, :destroy]
|
||||
before_action :check_user
|
||||
|
||||
# GET /promotion_products
|
||||
# GET /promotion_products.json
|
||||
@@ -63,6 +64,12 @@ class Settings::PromotionProductsController < ApplicationController
|
||||
# end
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_promotion
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Settings::PromotionsController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_promotion, only: [:show, :edit, :update, :destroy]
|
||||
before_action :check_user
|
||||
|
||||
# GET /promotions
|
||||
# GET /promotions.json
|
||||
@@ -119,6 +120,12 @@ class Settings::PromotionsController < ApplicationController
|
||||
render json: res
|
||||
end
|
||||
|
||||
def check_user
|
||||
if current_user.nil?
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_promotion
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Settings::ShopsController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_shop, only: [:show, :edit, :update]
|
||||
before_action :set_shop, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /settings/shops
|
||||
# GET /settings/shops.json
|
||||
@@ -11,11 +11,13 @@ class Settings::ShopsController < ApplicationController
|
||||
# GET /settings/shops/1
|
||||
# GET /settings/shops/1.json
|
||||
def show
|
||||
@display_images = @settings_shop.display_images.all
|
||||
end
|
||||
|
||||
# GET /settings/shops/new
|
||||
def new
|
||||
@settings_shop = Shop.new
|
||||
@display_image = @settings_shop.display_images.build
|
||||
end
|
||||
|
||||
# GET /settings/shops/1/edit
|
||||
@@ -28,6 +30,11 @@ class Settings::ShopsController < ApplicationController
|
||||
@settings_shop = Shop.new(shop_params)
|
||||
respond_to do |format|
|
||||
if @settings_shop.save
|
||||
if params[:display_images].present?
|
||||
params[:display_images]['image'].each do |a|
|
||||
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => a)
|
||||
end
|
||||
end
|
||||
format.html { redirect_to settings_shops_url, notice: 'Shop was successfully created.' }
|
||||
format.json { render :index, status: :created, location: @settings_shop }
|
||||
else
|
||||
@@ -42,6 +49,11 @@ class Settings::ShopsController < ApplicationController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_shop.update(shop_params)
|
||||
if params[:display_images].present?
|
||||
params[:display_images]['image'].each do |a|
|
||||
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :image => a)
|
||||
end
|
||||
end
|
||||
format.html { redirect_to settings_shops_url, notice: 'Shop was successfully updated.' }
|
||||
format.json { render :index, status: :ok, location: @settings_shop }
|
||||
else
|
||||
@@ -71,6 +83,6 @@ class Settings::ShopsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def shop_params
|
||||
params.require(:shop).permit(:name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info)
|
||||
params.require(:shop).permit(:logo, :name,:address,:city,:township,:state,:country,:phone_no,:reservation_no,:license,:activated_at,:license_data,:base_currency,:cloud_token,:cloud_url,:owner_token,:id_prefix,:is_rounding_adj,:quick_sale_summary,:calc_tax_order,:show_account_info, display_images_attributes: [:id, :shop_id, :image])
|
||||
end
|
||||
end
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user