Merge branch 'settings_backend' of bitbucket.org:code2lab/sxrestaurant into settings_backend

This commit is contained in:
Nweni
2017-06-19 15:23:23 +06:30
324 changed files with 10499 additions and 1542 deletions

3
.gitignore vendored
View File

@@ -45,3 +45,6 @@ config/deploy/config/*
# Gem files
#Gemfile
#Gemfile.lock
# For Redis Server log file
dump.rdb

24
Gemfile
View File

@@ -9,9 +9,9 @@ end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.0'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.3.18', '< 0.5'
#Use PosgreSQL
gem 'pg'
# redis server for cable
@@ -42,12 +42,10 @@ gem 'to_xls-rails'
#Reporting gem
#gem 'compendium'
# Pagination
gem 'kaminari', :git => "git://github.com/amatsuda/kaminari.git", :branch => 'master'
#gem "cancan"
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
@@ -59,8 +57,14 @@ gem 'bcrypt', '~> 3.1.7'
gem 'sidekiq'
# XML parser
#gem 'nokogiri', '~> 1.6'
# Pagination
gem 'kaminari', :git => "git://github.com/amatsuda/kaminari.git", :branch => 'master'
gem 'kaminari', '~> 1.0.1'
# Datatable
gem 'filterrific'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
@@ -90,3 +94,11 @@ end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'httparty', '~> 0.15.5'
# gem 'momentjs-rails', '>= 2.9.0'
# gem 'bootstrap-datepicker-rails'
# # gem 'momentjs-rails', '>= 2.9.0'
# gem 'bootstrap3-datetimepicker-rails'z
gem 'bootstrap-datepicker-rails'

View File

@@ -1,21 +1,3 @@
GIT
remote: git://github.com/amatsuda/kaminari.git
revision: c3c853a944cd2bff072ae05e48c563b2c9a29597
branch: master
specs:
kaminari (1.0.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.0.1)
kaminari-activerecord (= 1.0.1)
kaminari-core (= 1.0.1)
kaminari-actionview (1.0.1)
actionview
kaminari-core (= 1.0.1)
kaminari-activerecord (1.0.1)
activerecord
kaminari-core (= 1.0.1)
kaminari-core (1.0.1)
GEM
remote: https://rubygems.org/
specs:
@@ -64,6 +46,8 @@ GEM
bootstrap (4.0.0.alpha6)
autoprefixer-rails (>= 6.0.3)
sass (>= 3.4.19)
bootstrap-datepicker-rails (1.6.4.1)
railties (>= 3.0)
builder (3.2.3)
byebug (9.0.6)
coffee-rails (4.2.2)
@@ -88,36 +72,54 @@ GEM
faker (1.7.3)
i18n (~> 0.5)
ffi (1.9.18)
filterrific (2.1.2)
font-awesome-rails (4.7.0.2)
railties (>= 3.2, < 5.2)
globalid (0.4.0)
activesupport (>= 4.2.0)
i18n (0.8.1)
jbuilder (2.6.4)
activesupport (>= 3.0.0)
httparty (0.15.5)
multi_xml (>= 0.5.2)
i18n (0.8.4)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
kaminari (1.0.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.0.1)
kaminari-activerecord (= 1.0.1)
kaminari-core (= 1.0.1)
kaminari-actionview (1.0.1)
actionview
kaminari-core (= 1.0.1)
kaminari-activerecord (1.0.1)
activerecord
kaminari-core (= 1.0.1)
kaminari-core (1.0.1)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.5)
mail (2.6.6)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
mini_portile2 (2.2.0)
minitest (5.10.2)
multi_json (1.12.1)
multi_xml (0.6.0)
mysql2 (0.4.6)
nio4r (2.1.0)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
pdf-core (0.7.0)
pg (0.20.0)
prawn (2.2.2)
@@ -125,7 +127,7 @@ GEM
ttfunk (~> 1.5)
prawn-table (0.2.2)
prawn (>= 1.3.0, < 3.0.0)
puma (3.8.2)
puma (3.9.1)
rack (2.0.3)
rack-cors (0.4.1)
rack-protection (2.0.0)
@@ -189,7 +191,7 @@ GEM
activesupport (>= 3.2.1)
shoulda-matchers (3.1.1)
activesupport (>= 4.0.0)
sidekiq (5.0.0)
sidekiq (5.0.2)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
@@ -241,16 +243,20 @@ PLATFORMS
DEPENDENCIES
bcrypt (~> 3.1.7)
bootstrap (~> 4.0.0.alpha3)
bootstrap-datepicker-rails
byebug
coffee-rails (~> 4.2)
cups (~> 0.0.7)
database_cleaner
factory_girl_rails (~> 4.0)
faker
filterrific
font-awesome-rails
httparty (~> 0.15.5)
jbuilder (~> 2.5)
jquery-rails
kaminari!
jquery-ui-rails
kaminari (~> 1.0.1)
listen (~> 3.0.5)
mysql2 (>= 0.3.18, < 0.5)
pg
@@ -276,4 +282,4 @@ DEPENDENCIES
web-console (>= 3.3.0)
BUNDLED WITH
1.15.0
1.15.1

View File

@@ -11,7 +11,10 @@
// about supported directives.
//
//= require jquery
//= require tether
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require cable
//= require jquery-ui
//= require bootstrap-datepicker

View File

@@ -17,6 +17,11 @@
//= require cable
$(document).ready(function(){
// auto refresh every 10 seconds
// setTimeout(function(){
// window.location.reload(1);
// }, 10000);
$('.queue_station').on('click',function(){
var orderZone=$(this).children().children().children('.order-zone').text();
var orderItem=$(this).children().children().children('.order-item').text();
@@ -39,36 +44,44 @@ $(document).ready(function(){
});
// complete for queue item
$('.order-complete').on('click',function(){
var _self= $(this);
$('.order-complete').on('click',function(e){
//e.preventDefault();
var _self = $(this); // To know in ajax return
var assigned_item_id=$(this).attr('id').substr(15);
var params = { 'id':assigned_item_id };
var station=$(this).parent().parent(".queue_station").parent().parent().attr('id');
$.ajax({
type: 'POST',
url: '/oqs/update_delivery',
data: params,
dataType: 'json',
success: function(data){
var queue_station=_self.parent().parent(".queue_station");
success: function(data){
for (i = 0; i < data.length; i++) {
var queue_station = $('#assigned_queue_' + data[i]).parent().parent(".queue_station");
var station = queue_station.parent().parent().attr('id');
// Remove a queue card from current station
queue_station.remove();
// Remove a queue card from current station
queue_station.remove();
// Remove a queue card from current station
queue_station.children('.card-footer').remove();
// Add removed queue card from station to completed
$("#completed").children('.card-columns').append(queue_station);
// Remove a queue card from current station
queue_station.children('.card-footer').remove();
// Add removed queue card from station to completed
$("#completed").children('.card-columns').append(queue_station);
// update queue item count in station
$("#"+station+"_count").text(parseInt($("#"+station+"_count").text())-1);
$("#completed_count").text(parseInt($("#completed_count").text())+1);
// update queue item count in each station
var station_count=parseInt($("#"+station+"_count").text()) - 1;
$("#"+station+"_count").text(station_count);
}
// update queue item count in completed station
$("#completed_count").text(parseInt($("#completed_count").text()) + data.length);
alert("updated!");
// Page reload
location.reload();
}
});
});
});
$('#print_order_item').on('click',function(){
@@ -80,4 +93,14 @@ $(document).ready(function(){
success: function(data){ }
});
});
$('#print_order_summary').on('click',function(){
var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
var params = { 'id':assigned_item_id };
$.ajax({
type: 'GET',
url: '/oqs/print/print_order_summary/'+assigned_item_id,
success: function(data){ }
});
});
});

View File

@@ -17,3 +17,141 @@
//= require turbolinks
//= require cable
//= require settings/processing_items
//= require jquery-ui
//= require bootstrap-datepicker
$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
$('.dropdown-toggle').dropdown();
});
/*
* ToDo Move to here from pages
*
*
$(function(){
$('#custom_excel').hide();
$('#custom_excel').click(function(){
var url = $('#custom_excel').attr('data-url');
$('#frm_report').attr('action',url)
$('#frm_report').submit();
// window.location = url;
});
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
else if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
}
else{
$('#waiter').hide();
$('#cashier').show();
$("#item").val('sale');
}
});
//Reset the form to pervious values
$("#branch").val(<%=params[:branch]%>);
$("#waiter").val("<%=params[:waiter]%>");
$("#cashier").val(<%=params[:cashier]%>);
$("#product").val(<%=params[:product]%>);
$("#singer").val(<%=params[:singer]%>);
$("#item").val('<%=params[:item]%>');
$("#guest_role").val('<%=params[:guest_role]%>');
$("#from").val("<%=params[:from]%>");
$("#to").val("<%=params[:to]%>");
$("#sel_period").val(<%=params[:period]%>);
$("#sel_sale_type").val(<%=params[:sale_type]%>);
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked");
<% else %>
$("#rd_period_type_0").attr("checked","checked");
<% end %>
$(".btn-group button").removeClass("active");
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
$("#btn_report_type_<%= report_type %>").addClass("active");
$('#item').change(function(){
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
if(payment_type){
$('#payment_type').show();
}
}
else{
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
});
$(function(){
var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
}
else{
search_by_date();
}
}else{
search_by_period();
}
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
}
$('#from').change(function(){
search_by_date();
});
$('#to').change(function(){
search_by_date();
});
function search_by_date(){
var from = $('#from').val();
var to = $('#to').val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
// console.log(check_arr.length)
if(check_arr.length == 1){
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
});
*/

View File

@@ -5,6 +5,7 @@
//= require_self
//= require_tree ./channels
// Temp Disable
(function() {
this.App || (this.App = {});

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,346 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require tether
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require cable
//= require jquery-ui
//= require bootstrap-datepicker
$(document).ready(function(){
// auto refresh every 60 seconds
// setTimeout(function(){
// window.location.reload(1);
// }, 60000);
// For selected order return
var order_status = "";
order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim();
// Enable/Disable Button
control_button(order_status);
$(".orders").on('click', function(){
$("#order-sub-total").text('');
// $("#order-food").text('');
// $("#order-beverage").text('');
$("#order-discount").text('');
$("#order-Tax").text('');
$("#order-grand-total").text('');
var zone_name=$(this).find(".orders-table").text();
var receipt_no=$(this).find(".orders-receipt-no").text();
var unique_id = $(this).find(".orders-id").text();
var order_status=$(this).find(".orders-order-status").text().trim();
// Enable/Disable Button
control_button(order_status);
var customer_id=$(this).find(".customer-id").text();
show_customer_details(customer_id);
$("#re-print").val(unique_id);
var cashier="";
var receipt_date="";
var sub_total=0;
var discount_amount=0;
var tax_amount=0;
var grand_total_amount=0;
$("#order-title").text("ORDER DETAILS - " + zone_name);
// clear order items
$("#order-items-table").children("tbody").empty();
// AJAX call for order
$.ajax({
type: "POST",
url: "/origami/" + unique_id,
data: { 'booking_id' : unique_id },
success:function(result){
for (i = 0; i < result.length; i++) {
var data = JSON.stringify(result[i]);
var parse_data = JSON.parse(data);
var show_date = "";
// Receipt Header
receipt_no = result[i].receipt_no;
cashier = result[i].cashier_name;
if(result[i].receipt_date != null){
receipt_date = new Date(result[i].receipt_date);
show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes()
}
$("#receipt_no").text(receipt_no);
$("#cashier").text(cashier == null ? "" : cashier);
$("#receipt_date").text(show_date);
//Receipt Charges
sub_total += (parse_data.qty*parse_data.price);
discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount;
tax_amount = parse_data.tax_amount;
grand_total_amount = parse_data.grand_total_amount;
$("#order-sub-total").text(sub_total);
// $("#order-food").text('');
// $("#order-beverage").text('');
$("#order-discount").text(discount_amount);
$("#order-Tax").text(tax_amount);
$("#order-grand-total").text(grand_total_amount);
// Ordered Items
var order_items_rows = "<tr>" +
"<td class='item-name'>" + parse_data.item_name + "</td>" +
"<td class='item-attr'>" + parse_data.qty + "</td>" +
"<td class='item-attr'>" + parse_data.qty*parse_data.price + "</td>" +
"</tr>";
$("#order-items-table").children("tbody").append(order_items_rows);
}
}
});
// End AJAX Call
$('.orders').removeClass('selected-item');
$(this).addClass('selected-item');
});
// Bill Request
$('#request_bills').click(function() {
var order_id=$(".selected-item").find(".orders-id").text();
if(order_id!=""){
window.location.href = '/origami/' + order_id + '/request_bills'
}
else {
alert("Please select an order!");
}
return false;
});
// Discount for Payment
$('#discount').click(function() {
var order_id=$(".selected-item").find(".orders-id").text();
if(order_id!=""){
window.location.href = '/origami/' + order_id + '/discount'
}
else {
alert("Please select an order!");
}
return false;
});
// Pay Discount for Payment
$("#pay-discount").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var sale_item_id = $('.selected-item').attr('id');
var sub_total = $('#order-sub-total').text();
var grand_total = $('#order-grand-total').text();
var discount_type = $('#discount-type').val();
var discount_value = $('#discount-amount').val();
var discount_amount = discount_value;
var ajax_url = "/origami/" + sale_id + "/discount";
if(sale_item_id != null){
ajax_url = "/origami/" + sale_item_id + "/discount";
sub_total = $("#"+sale_item_id).children().find("#item-total-price").text();
}
// For Percentage Discount
if(discount_type == 1){
discount_amount=(sub_total*discount_value)/100;
}
var params = {'sale_id': sale_id, 'sale_item_id': sale_item_id, 'grand_total' : grand_total, 'discount_type':discount_type, 'discount_value':discount_value, 'discount_amount':discount_amount};
$.ajax({
type: "POST",
url: ajax_url,
data: params,
success:function(result){ }
});
});
// Payment for Bill
$('#pay-bill').click(function() {
var sale_id=$(".selected-item").find(".orders-id").text();
if(sale_id!=""){
window.location.href = '/origami/sale/'+ sale_id + "/payment"
}
else {
alert("Please select an order!");
}
return false;
});
$('#customer').click(function() {
var sale = $(".selected-item").find(".orders-id").text();
if (sale.substring(0, 3)=="SAL") {
var sale_id = sale
}else{
var sale_id = $(".selected-item").find(".order-cid").text();
}
window.location.href = '/origami/'+ sale_id + "/customers"
return false;
});
$('#re-print').click(function() {
var sale_id = $(".selected-item").find(".orders-id").text();
window.location.href = '/origami/'+ sale_id + "/reprint"
return false;
});
function show_customer_details(customer_id){
if(window.location.pathname.substring(0, 12) == "/origami/SAL"){
var url = customer_id+"/get_customer/"
}else{
var url = "origami/"+customer_id+"/get_customer/"
}
$('.customer_detail').removeClass('hide');
//Start Ajax
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
$("#customer_name").text(data["customer"].name);
$.each(data["response_data"]["data"], function (i) {
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
var balance = data["response_data"]["data"][i]["balance"];
if (data["response_data"]["status"]==true) {
$('.rebate_amount').removeClass('hide');
row =
'<td class="charges-name">' + data["response_data"]["data"][i]["accountable_type"] +'</td>'
+'<td class="item-attr">' + balance + '</td>';
$(".rebate_amount").html(row);
}
}
});
}
});
//End Ajax
}
/* For Receipt - Calculate discount or tax */
$('.cashier_number').on('click', function(event){
if(event.handled !== true) {
var original_value=0;
original_value = $('#discount-amount').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#discount-amount').val(input_value);
update_balance();
}
else{
$('#discount-amount').val(original_value + '' + input_value);
update_balance();
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#discount-amount').val(amount);
$('#discount-type').val(1);
update_balance();
break;
case 'del' :
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
update_balance();
break;
case 'clr':
$('#discount-amount').val("0.0");
update_balance();
break;
}
event.handled = true;
} else {
return false;
}
});
$('.discount-item-row').on('click',function(){
$('.discount-item-row').removeClass('selected-item');
$(this).addClass('selected-item');
});
});
/* Button Control by Status */
function control_button(order_status){
if(order_status=="billed"){
$("#customer").prop('disabled', false);
$("#request_bills").prop('disabled', true);
$("#discount").prop('disabled', false);
$("#pay-bill").prop('disabled', false);
$("#re-print").prop('disabled', true);
}
else if(order_status=="new") {
$("#customer").prop('disabled', false);
$("#request_bills").prop('disabled', false);
$("#discount").prop('disabled', true);
$("#pay-bill").prop('disabled', true);
$("#re-print").prop('disabled', true);
}else if(order_status=="completed"){
$("#re-print").prop('disabled', false);
}
else {
$("#customer").prop('disabled', true);
$("#request_bills").prop('disabled', true);
$("#discount").prop('disabled', true);
$("#pay-bill").prop('disabled', true);
$("#re-print").prop('disabled', true);
}
}
/* For Receipt - Update Balance */
function update_balance(){
var discount_type = $('#discount-type').val();
var discount_amount = $('#discount-amount').val();
var sub_total = $('#order-sub-total').text();
var tax = $('#order-Tax').text();
// For Percentage Discount
if(discount_type == 1){
discount_amount=(sub_total*discount_amount)/100;
}
var total = (parseFloat(sub_total) + parseFloat(tax)) - discount_amount;
$('#order-discount').text(discount_amount);
$('#order-grand-total').text(total);
}

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,40 @@
// number key pad
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
}
event.handled = true;
} else {
return false;
}
});

View File

@@ -0,0 +1,4 @@
$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
$('.dropdown-toggle').dropdown();
});

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,7 @@
//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require cable
//= require jquery-ui
//= require bootstrap-datepicker

View File

@@ -1,9 +1,13 @@
@import "bootstrap";
@import "font-awesome";
@import "theme";
@import "jquery-ui";
@import "bootstrap-datepicker3";
/* Show it is fixed to the top */
// body {
// min-height: 75rem;
// padding-top: 4.5rem;
// }

View File

@@ -16,5 +16,6 @@
}
.selected-item {
color: #fff !important;
background-color: blue;
}

View File

@@ -1,3 +1,3 @@
// Place all the styles related to the origami/RequestBills controller here.
// Place all the styles related to the api/origami/paypar controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -2,6 +2,9 @@
@import "bootstrap";
@import "font-awesome";
@import "theme";
@import "jquery-ui";
@import "bootstrap-datepicker3";
/* Show it is fixed to the top */
// body {
@@ -57,3 +60,19 @@ ul.dropdown-menu li a{
/*----- Header Bar -----*/
/*----- Header Bar -----*/
/*----- Layout ------ */
.margin-top-20 {
margin: 20px 0 0 0;
}
/*----- Layout ------ */
/*--- Reset --- */
select.form-control {
height: inherit !important;
}
/*--- Reset --- */

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the membership_actions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -1,9 +0,0 @@
@import "bootstrap";
@import "font-awesome";
@import "theme";
/* Show it is fixed to the top */
// body {
// min-height: 75rem;
// padding-top: 4.5rem;
// }

View File

@@ -0,0 +1,131 @@
@import "bootstrap";
@import "font-awesome";
@import "theme";
@import "jquery-ui";
@import "bootstrap-datepicker3";
/* Show it is fixed to the top */
// body {
// min-height: 75rem;
// padding-top: 4.5rem;
// }
.others-payment{
line-height:100px;
text-align:center;
color:white;
width:300px;
height:100px;
font-size:18px;
}
.orders-table {
cursor: pointer;
}
.cashier_number{
width: 33%;
height:70px;
line-height:70px;
text-align:center;
background:#54A5AF;
// float:left;
// margin:2px;
font-size:20px;
color:white;
// cursor:pointer;
}
.del_cashier_number{
opacity:0.6,
}
.pay{
width: 98%;
height:211px;
line-height:211px;
text-align:center;
font-size:20px;
color:white;
}
.cashier_number:hover{
background:#A9F5F2;
}
.long{
width:49%;
}
.sold {
background-color: red;
}
.paid {
background-color: green;
}
.selected-item {
color: #fff !important;
background-color: blue !important;
}
/* Reciept Style */
#order-charges-table td {
border-top: none !important;
}
.charges-name {
width: 80%;
text-align: left;
}
.item-name {
width: 60%;
text-align: left;
}
.item-attr {
width: 20%;
text-align: right;
}
/* Colors */
.purple {
background-color:#7a62d3;
}
.red {
background-color:#ff0000;
}
.green{
background-color: #009900
}
.left{
margin-left:1px;
}
.bottom{
margin-bottom: 1px;
}
/*----- Reset -----*/
select.form-control {
height: inherit !important;
}
.form-horizontal .form-group {
margin-right: 0px !important;
}
/* Discount */
.discount-item-row {
cursor: pointer;
}
tr.discount-item-row:hover {
background-color: #e3e3e3 !important;
}

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the origami/redeem_payments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the settings/membership_actions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the settings/orders controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,5 @@
@import "bootstrap";
@import "font-awesome";
@import "theme";
@import "jquery-ui";
@import "bootstrap-datepicker3";

View File

@@ -8,12 +8,18 @@ class Api::BillController < Api::ApiController
#create Bill by Booking ID
if (params[:booking_id])
@sale = Sale.new
@status = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee.name)
booking = Booking.find(params[:booking_id])
if booking
if booking.sale_id.nil?
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee)
else
@status = true
end
end
elsif (params[:order_id])
@sale = Sale.new
@status = @sale.generate_invoice_from_order(params[:order_id], current_login_employee.name)
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee)
end
end

View File

@@ -9,4 +9,9 @@ class Api::CustomersController < ActionController::API
def show
@customer = Customer.find_by(params[:id])
end
#Show customer detail by Order item
def get_customer_order
@customer = Customer.find(params[:id])
end
end

View File

@@ -1,6 +1,6 @@
class Api::InvoicesController < ActionController::API
before :authenticate_token
before :set_sale_params, only:[:show, :update, :destroy]
# before :authenticate_token
# before :set_sale_params, only:[:show, :update, :destroy]
#List open invoices for today.
def index

View File

@@ -1,5 +1,5 @@
class Api::MembershipsController < ActionController::API
before :authenticate_token
#before :authenticate_token
#Add Membership to invoice

View File

@@ -28,33 +28,31 @@ class Api::OrdersController < Api::ApiController
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = params[:customer_id]
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
@order.items = params[:order_items]
@order.guest = params[:guest_info]
@order.table_id = params[:table_id]
@order.new_booking = true
#@order.employee_name = "Emenu"
@order.employee_name = current_login_employee.name
#Create Table Booking or Room Booking
if !params["booking_id"].nil? && params[:booking_id].to_i > 0
#@order.new_booking = false
@order.new_booking = true
@order.booking_id = params[:booking_id]
if !params["booking_id"].nil?
# check booking id is already completed.
booking = Booking.find(params[:booking_id])
if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
@order.new_booking = true
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
end
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
puts "booking sale is null"
end
end
@status, @booking = @order.generate
# rescue Exception => error
# @status = false
# @error_messages = "Exception has occurs on System"
#
# logger.fatal("Exception Raise - " + error.message)
# end
end
# Description

View File

@@ -29,56 +29,56 @@ class Api::PaymentsController < ActionController::API
#:received_amount, :card_payment_reference, :vochure_no, :giftcard_no,
#:customer_id, :external_payment_status
switch (payment_method)
case "cash"
case payment_method
when "cash"
sale_payment.payment_method = "cash"
sale_payment.received_amount = params[:amount]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
case "creditnote"
when "creditnote"
sale_payment.payment_method = "creditnote"
sale_payment.received_amount = params[:amount]
sale_payment.customer_id = params[:customer_id]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
case "visa"
when "visa"
sale_payment.payment_method = "visa"
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)
case "master"
when "master"
sale_payment.payment_method = "master"
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)
case "jcb"
when "jcb"
sale_payment.payment_method = "jcb"
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)
case "mpu"
when "mpu"
sale_payment.payment_method = "mpu"
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)
case "unionpay"
when "unionpay"
sale_payment.payment_method = "unionpay"
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)
case "vochure"
when "vochure"
sale_payment.payment_method = "vochure"
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)
case "giftcard"
when "giftcard"
sale_payment.payment_method = "giftcard"
sale_payment.received_amount = params[:amount]
sale_payment.customer_id = params[:customer_id]
sale_payment.payment_reference = params[:giftcard_no]
@status, @invoice = sale_payment.process_payment(sale_payment, current_login_employee.name)
case "paypar"
when "paypar"
sale_payment.payment_method = "paypar"
sale_payment.received_amount = params[:amount]
sale_payment.payment_reference = params[:payment_reference]

View File

@@ -0,0 +1,77 @@
class BaseReportController < ActionController::Base
include LoginVerification
layout "application"
#before_action :check_installation
protect_from_forgery with: :exception
PERIOD = {
"today" => 0,
"yesterday" => 1,
"this_week" => 2,
"last_week" => 3,
"last_7" => 4,
"this_month" => 5,
"last_month" => 6,
"last_30" => 7,
"this_year" => 8,
"last_year" => 9
}
def get_date_range_from_params
period_type = params[:period_type]
period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now
if period_type.to_i == 1
if params[:from] && params[:to]
if params[:from] != "" && params[:to] !=""
from = DateTime.strptime(params[:from], "%m/%d/%Y")
to = DateTime.strptime(params[:to], "%m/%d/%Y")
else
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
end
end
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
return from, to
end
end

View File

@@ -1,4 +1,4 @@
class Crm::BookingsController < ApplicationController
class Crm::BookingsController < BaseCrmController
def update_booking
booking = Booking.find(params[:booking_id])

View File

@@ -1,20 +1,73 @@
class Crm::CustomersController < ApplicationController
class Crm::CustomersController < BaseCrmController
before_action :set_crm_customer, only: [:show, :edit, :update, :destroy]
# GET /crm/customers
# GET /crm/customers.json
def index
@crm_customers = Crm::Customer.all
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
@crm_customers = Customer.search(filter)
end
#@crm_customers = Customer.all
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
@crm_customer = Customer.new
# if flash["errors"]
# @crm_customer.valid?
# end
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
# end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @crm_customers }
end
end
# GET /crm/customers/1
# GET /crm/customers/1.json
def show
@orders = Order.where("customer_id=?", params[:id])
@sales = Sale.where("customer_id=?", params[:id])
if @orders
@order_items = []
@orders.each do |order|
@order_items = @order_items + order.order_items
end
end
if @sales
@sale_items = []
@sales.each do |sale|
@sale_items = @sale_items + sale.sale_items
end
end
#get customer amount
@customer = Customer.find(params[:id])
response = Customer.get_member_account(@customer)
if(response["status"] == true)
@membership = response["data"]
else
@membership = 0
end
#end customer amount
end
# GET /crm/customers/new
def new
@crm_customer = Crm::Customer.new
@crm_customer = Customer.new
@membership = Customer.get_member_group()
end
# GET /crm/customers/1/edit
@@ -23,31 +76,109 @@ class Crm::CustomersController < ApplicationController
# POST /crm/customers
# POST /crm/customers.json
def create
@crm_customer = Crm::Customer.new(crm_customer_params)
def create
@crm_customers = Customer.new(customer_params)
respond_to do |format|
if @crm_customer.save
format.html { redirect_to @crm_customer, notice: 'Customer was successfully created.' }
format.json { render :show, status: :created, location: @crm_customer }
puts @crm_customers.errors.to_json
if @crm_customers.save
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
dob = customer_params[:date_of_birth]
member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
merchant_uid = memberaction.merchant_account_id.to_s
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,
member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
if response["status"] == true
customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' }
else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
end
# format.json { render :index, status: :created, location: @crm_customers }
else
@crm_customers.destroy
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
else
format.html { redirect_to crm_customers_path, notice: response["message"] }
end
end
else
format.html { render :new }
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
if params[:sale_id]
flash[:errors] = @crm_customers.errors
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
else
flash[:errors] = @crm_customers.errors
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
end
end
end
end
end
# PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json
def update
respond_to do |format|
if @crm_customer.update(crm_customer_params)
format.html { redirect_to @crm_customer, notice: 'Customer was successfully updated.' }
if @crm_customer.update(customer_params)
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
dob = customer_params[:date_of_birth]
id = @crm_customer.membership_id
member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
merchant_uid = memberaction.merchant_account_id.to_s
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
format.json { render :show, status: :ok, location: @crm_customer }
else
format.html { render :edit }
flash[:errors] = @crm_customers.errors
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
end
end
end
@@ -64,11 +195,12 @@ class Crm::CustomersController < ApplicationController
private
# Use callbacks to share common setup or constraints between actions.
def set_crm_customer
@crm_customer = Crm::Customer.find(params[:id])
@crm_customer = Customer.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def crm_customer_params
params.require(:crm_customer).permit(:name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code)
def customer_params
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth)
end
end

View File

@@ -0,0 +1,84 @@
class Crm::DiningQueuesController < BaseCrmController
before_action :set_dining_queue, only: [:show, :edit, :update, :destroy]
# GET /crm/dining_queues
# GET /crm/dining_queues.json
def index
@dining_queues = DiningQueue.all
end
# GET /crm/dining_queues/1
# GET /crm/dining_queues/1.json
def show
end
# GET /crm/dining_queues/new
def new
@dining_queue = DiningQueue.new
@queue_no = DiningQueue.generate_queue_no
end
# GET /crm/dining_queues/1/edit
def edit
end
# POST /crm/dining_queues
# POST /crm/dining_queues.json
def create
@dining_queue = DiningQueue.new(dining_queue_params)
respond_to do |format|
if @dining_queue.save
unique_code = "QueueNoPdf"
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_queue_no(print_settings,@dining_queue)
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' }
format.json { render :show, status: :created, location: @dining_queue }
else
format.html { render :new }
format.json { render json: @dining_queue.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /crm/dining_queues/1
# PATCH/PUT /crm/dining_queues/1.json
def update
respond_to do |format|
if @dining_queue.update(dining_queue_params)
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully updated.' }
format.json { render :show, status: :ok, location: @dining_queue }
else
format.html { render :edit }
format.json { render json: @dining_queue.errors, status: :unprocessable_entity }
end
end
end
# DELETE /crm/dining_queues/1
# DELETE /crm/dining_queues/1.json
def destroy
@dining_queue.destroy
respond_to do |format|
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_dining_queue
@dining_queue = DiningQueue.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def dining_queue_params
params.require(:dining_queue).permit(:name, :contact_no, :queue_no)
end
end

View File

@@ -1,24 +1,60 @@
class Crm::HomeController < BaseCrmController
def index
@booking = Booking.all
@booking = Booking.all
@customer = Customer.all
#@booking = Booking.select("bookings.id as booking_id,
# bookings.checkin_at,
# bookings.checkin_by,
# bookings.dining_facility_id,
# od.customer_id as customer,
# od.id as order_id,
# od.item_count as count,
# odt.id as order_item_id,
# odt.item_name as item_name")
# .joins("join booking_orders as bko ON bko.booking_id = bookings.id")
# .joins("right join orders as od ON od.id = bko.order_id")
# .joins("right join order_items as odt ON odt.order_id=od.id")
# .order("bookings.id DESC")
from = Time.now.beginning_of_day.utc
to = Time.now.end_of_day.utc
@queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC')
# .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
end
def show
end
#print for crm
def print_order
@booking = Booking.find(params[:id])
@total_amount = 0.00
@total_tax = 0.00
if @booking.booking_orders
order_items = []
@booking.booking_orders.each do |bo|
order = Order.find(bo.order_id)
#if (order.status == "new")
order_items = order_items + order.order_items
#end
end
end
unique_code="CrmOrderPdf"
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_crm_order(@booking,order_items,print_settings)
end
# def update_sale_by_customer
# sale = Sale.find(params[:sale_id])
# status = sale.update_attributes(customer_id: params[:customer_id])
# if status == true
# render json: JSON.generate({:status => true})
# else
# render json: JSON.generate({:status => false, :error_message => "Record not found"})
# end
# end
end

View File

@@ -10,12 +10,20 @@ class HomeController < ApplicationController
@login_form.emp_id = params[:login_form][:emp_id]
@login_form.password = params[:login_form][:password]
@employee = Employee.login(@login_form.emp_id, @login_form.password)
if @employee
session[:session_token] = @employee.token_session
redirect_to dashboard_path
else
render :index
end
if @employee != nil
if @employee.role == "administrator"
session[:session_token] = @employee.token_session
redirect_to dashboard_path
elsif @employee.role == "cashier"
session[:session_token] = @employee.token_session
redirect_to origami_root_path
else
render :index
end
else
redirect_to origami_root_path, :notice => "Username and Password dosn't match!"
end
end

View File

@@ -27,23 +27,31 @@ class Oqs::HomeController < BaseOqsController
# update delivery status when complete click
def update_delivery_status
removed_item = []
assigned_item_id = params[:id]
assigned_item=AssignedOrderItem.find(assigned_item_id)
assigned_item.delivery_status=true
assigned_item.save
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# update delivery status for completed same order items
assigned_items.each do |ai|
ai.delivery_status=true
ai.save
removed_item.push(ai.assigned_order_item_id)
end
render :json => removed_item.to_json
end
# Query for OQS with status
def queue_items_query(status)
AssignedOrderItem.select("assigned_order_items.id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at")
.joins("join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id
left join dining_facilities as df on df.zone_id = oqpz.zone_id
left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id
left join orders as od ON od.id = assigned_order_items.order_id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_code = assigned_order_items.item_code
left join customers as cus ON cus.id = od.customer_id")
left join customers as cus ON cus.customer_id = od.customer_id")
.where("assigned_order_items.delivery_status = #{status}")
.group("assigned_order_items.id")
.group("assigned_order_items.assigned_order_item_id")
.order("odt.item_name DESC")
end
end

View File

@@ -1,16 +1,45 @@
class Oqs::PrintController < ApplicationController
# Print Order Item
def print
unique_code="OrderItemPdf"
assigned_item_id=params[:id]
assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id)
assigned_item=AssignedOrderItem.find(assigned_item_id)
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# printer for each stations
printer_name = assigned_item.order_queue_station.printer_name
# print when complete click
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,assigned_order_item[0].order_id, assigned_order_item[0].item_code )
order_queue_printer.print_order_item(printer_name,assigned_item.order_id, assigned_item.item_code )
# update print status for completed same order items
assigned_items.each do |ai|
ai.print_status=true
ai.save
end
end
# update print status when complete click
assigned_item=AssignedOrderItem.find(assigned_item_id)
assigned_item.print_status=true
assigned_item.save
# Print Order Details
def print_order_summary
unique_code="OrderSummaryPdf"
assigned_item_id=params[:id]
assigned_item=AssignedOrderItem.find(assigned_item_id)
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# printer for each stations
printer_name = assigned_item.order_queue_station.printer_name
# print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(printer_name,assigned_item.order_id)
# update print status for completed same order items
assigned_items.each do |ai|
ai.print_status=true
ai.save
end
end
end

View File

@@ -0,0 +1,29 @@
class Origami::CardPaymentsController < BaseOrigamiController
def index
@membership_rebate_balance = 0
@membership_id = 0
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.get_paypar_account(membership_setting.gateway_url,membership_setting.auth_token,@membership_id)
if membership_data["status"]==true
membership_account_data = membership_data["data"];
membership_account_data.each do |acc_data|
if acc_data["accountable_type"] == "REBATEACCOUNT"
@membership_rebate_balance=acc_data["balance"]
else
@membership_rebate_balance = 0
end
end
else
@membership_rebate_balance = 0
end
end
end
def create
end
end

View File

@@ -0,0 +1,10 @@
class Origami::CreditPaymentsController < BaseOrigamiController
def index
end
def create
end
end

View File

@@ -1,7 +1,43 @@
class Origami::CustomersController < BaseOrigamiController
#Form to add customer -
def index
end
def create
# GET /crm/customers/1
# GET /crm/customers/1.json
def show
end
def add_customer
@sale_id = params[:sale_id]
filter = params[:filter]
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
@crm_customers = Customer.search(filter)
end
#@crm_customers = Customer.all
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
@crm_customer = Customer.new
# if flash["errors"]
# @crm_customer.valid?
# end
respond_to do |format|
# format.html { render :template => "crm/customers/index" }
format.html { render action: "index"}
format.json { render json: @crm_customers }
end
end
end

View File

@@ -1,6 +1,57 @@
class Origami::DiscountsController < BaseOrigamiController
#discount page show from origami index with selected order
def index
sale_id = params[:id]
if Sale.exists?(sale_id)
@sale_data = Sale.find(sale_id)
end
end
#discount for selected order
def create
sale_id = params[:sale_id]
sale_item_id = params[:sale_item_id]
discount_type = params[:discount_type]
discount_value = params[:discount_value]
discount_amount = params[:discount_amount]
grand_total = params[:grand_total]
product_name = "Overall Discount"
if discount_type == 0
remark="Discount " + discount_amount + " as net"
else
remark="Discount " + discount_amount + " as percentage"
end
#update discount for sale
sale = Sale.find(sale_id)
sale.total_discount = sale.total_discount + discount_amount.to_f
sale.grand_total = grand_total
sale.save
#save sale item for discount
if sale_item_id != nil
origin_sale_item = SaleItem.find(sale_item_id)
product_name = origin_sale_item.product_name + "-Disocunt"
end
sale_item = SaleItem.new
#pull
sale_item.sale_id = sale_id
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
sale_item.product_name = product_name
sale_item.remark = remark
sale_item.qty = 1
sale_item.unit_price = (0-discount_amount.to_f)
sale_item.taxable_price = discount_amount
sale_item.is_taxable = 0
sale_item.price = sale_item.qty * sale_item.unit_price
sale_item.save
redirect_to origami_path(sale_id)
end
end

View File

@@ -1,15 +1,83 @@
class Origami::HomeController < BaseOrigamiController
def index
@order_table = Order.get_order_table()
@order_rooms = Order.get_order_rooms()
@orders = Order.get_orders()
end
def show
str = []
@order_details = OrderItem.get_order_items_details(params[:order_id])
@order_details.each do |ord_detail|
str.push(ord_detail)
if params[:booking_id] != nil
type=params[:booking_id].split('-')[0];
# Sale
if type == "SAL"
@selected_item = Sale.find(params[:booking_id])
@selected_item_type="Sale"
# Booking
else
@selected_item = Order.find(params[:booking_id])
@selected_item_type="Order"
end
end
render :json => str.to_json
@completed_orders = Order.get_completed_order()
@booking_orders = Order.get_booking_order_table()
@booking_rooms = Order.get_booking_order_rooms()
@orders = Order.get_orders()
end
def item_show
selection(params[:booking_id],1)
end
def selection(selected_id, is_ajax)
str = []
type=selected_id.split('-')[0];
# Sale
if type == "SAL"
@order_details = SaleItem.get_order_items_details(params[:booking_id])
@order_details.each do |ord_detail|
str.push(ord_detail)
end
# Booking
else
@order_details = OrderItem.get_order_items_details(params[:booking_id])
@order_details.each do |ord_detail|
str.push(ord_detail)
end
end
if is_ajax == 1
render :json => str.to_json
else
str
end
end
def update_sale_by_customer
id = params[:sale_id][0,3]
if(id == "SAL")
sale = Sale.find(params[:sale_id])
else
sale = Order.find(params[:sale_id])
end
status = sale.update_attributes(customer_id: params[:customer_id])
if status == true
render json: JSON.generate({:status => true})
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end
def get_customer
@customer = Customer.find(params[:customer_id])
response = Customer.get_member_account(@customer)
respond_to do |format|
format.js do
render :json => {
:response_data => response.as_json,
:customer => @customer}
end
end
end
end

View File

@@ -0,0 +1,32 @@
class Origami::JcbController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
# limit jcb_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@jcbcount = 0
others = 0
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
end
def create
cash = params[:amount]
sale_id = params[:sale_id]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "jcb")
end
end
end

View File

@@ -0,0 +1,31 @@
class Origami::MasterController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
# limit master_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@mastercount = 0
others = 0
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
end
def create
cash = params[:amount]
sale_id = params[:sale_id]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "master")
end
end
end

View File

@@ -0,0 +1,32 @@
class Origami::MpuController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
# limit mpu_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@mpucount = 0
others = 0
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
end
def create
cash = params[:amount]
sale_id = params[:sale_id]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu")
end
end
end

View File

@@ -0,0 +1,39 @@
class Origami::OthersPaymentsController < BaseOrigamiController
def index
@membership_rebate_balance = 0
@sale_id = params[:sale_id]
@payment_method_setting = PaymentMethodSetting.all
# @sale_id = params[:sale_id]
# sale_data = Sale.find_by_sale_id(@sale_id)
# if sale_data.customer_id
# customer_data= Customer.find_by_customer_id(sale_data.customer_id)
# @membership_id = customer_data.membership_id
# if !@membership_id.nil?
# membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
# membership_data = SalePayment.get_paypar_account(membership_setting.gateway_url,membership_setting.auth_token,@membership_id)
# if membership_data["status"]==true
# membership_account_data = membership_data["data"];
# membership_account_data.each do |acc_data|
# if acc_data["accountable_type"] == "REBATEACCOUNT"
# @membership_rebate_balance=acc_data["balance"]
# else
# @membership_rebate_balance = 0
# end
# end
# else
# @membership_rebate_balance = 0
# end
# end
# else
# end
end
def create
end
end

View File

@@ -1,6 +1,104 @@
class Origami::PaymentsController < BaseOrigamiController
def index
end
def create
cash = params[:cash]
sale_id = params[:sale_id]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "cash")
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
# get member information
member_info = Customer.get_member_account(customer)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
end
end
def show
sale_id = params[:sale_id]
if Sale.exists?(sale_id)
@cash = 0.0
@other = 0.0
@ppamount = 0.0
@visacount= 0.0
@jcbcount= 0.0
@mastercount = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
# get member information
response = Customer.get_member_account(@customer)
@balance = 0.00
@accountable_type = ''
if response["data"]==true
response["data"].each do |res|
if res["accountable_type"] == "RebateAccount"
@balance = res["balance"]
@accountable_type = res["accountable_type"]
end
end
end
#end customer amount
@sale_data.sale_payments.each do |spay|
if spay.payment_method == "cash"
@cash = spay.payment_amount
end
if spay.payment_method == "mpu"
@other += spay.payment_amount
elsif spay.payment_method == "paypar"
@ppamount += spay.payment_amount
elsif spay.payment_method == "visa"
@visacount += spay.payment_amount
elsif spay.payment_method == "jcb"
@jcbcount += spay.payment_amount
elsif spay.payment_method == "master"
@mastercount += spay.payment_amount
end
end
end
end
def reprint
sale_id = params[:sale_id]
saleObj = Sale.find(sale_id)
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
# get member information
member_info = Customer.get_member_account(customer)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
end
end

View File

@@ -0,0 +1,21 @@
class Origami::PayparPaymentsController < BaseOrigamiController
def create
sale_id = params[:sale_id]
redeem_amount = params[:redeem_amount]
membership_id = params[:membership_id]
payment_method = "paypar"
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
status,msg =sale_payment.process_payment(saleObj, @user, redeem_amount,payment_method)
if status == true
@out = true, "Success!"
else
@out =false, "Please try again payment!"
end
else
@out = false, "There has no sale record!"
end
end
end

View File

@@ -0,0 +1,67 @@
class Origami::RedeemPaymentsController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
payment_method = params[:payment_method]
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
# limit redeem_amount
food_prices, beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
@payparcount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "paypar"
@payparcount = @payparcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
is_bervage_exceed = others - (beverage_prices + sale_data.total_tax)
if is_bervage_exceed < 0
@food_prices = food_prices - @payparcount
else
@food_prices = food_prices - @payparcount -is_bervage_exceed
end
if sale_data
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
@membership_id = customer_data.membership_id
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url
@campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]
@out = true, @membership_rebate_balance,@membership_id
end
else
@out =false,0
end
else
@out = false,0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
@out = false, 0
end
end

View File

@@ -1,22 +1,37 @@
class Origami::RequestBillsController < BaseOrigamiController
def show
# Print Request Bill and add to sale tables
def print
@sale = Sale.new
sale_order=SaleOrder.new
check_order = Order.find_by_id(params[:id])
if check_order
@order_details = OrderItem.get_order_items_details(check_order.id)
@order_details = OrderItem.get_order_items_details(check_order.id)
@status, @sale_id = @sale.generate_invoice_from_order(check_order.id, nil,current_login_employee.name)
@sale_data = Sale.find_by_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id)
end
unique_code="ReceiptBillPdf"
booking_id = params[:id]
check_booking = Booking.find_by_booking_id(booking_id)
if check_booking.sale_id.nil?
# Create Sale if it doesn't exist
puts "current_login_employee"
puts current_login_employee.name
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee)
@sale_data = Sale.find_by_sale_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id)
else
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
end
unique_code = "ReceiptBillPdf"
customer= Customer.where('customer_id=' + @sale_data.customer_id)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# find order id by sale id
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
# Calculate Food and Beverage Total
food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,@sale_items,@sale)
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
redirect_to origami_path(@sale_data.sale_id)
end
end

View File

@@ -0,0 +1,31 @@
class Origami::VisaController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
# limit visa_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@visacount = 0
others = 0
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
end
def create
cash = params[:amount]
sale_id = params[:sale_id]
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "visa")
end
end
end

View File

@@ -0,0 +1,9 @@
class Reports::DailySaleController < BaseReportController
def index
from, to = get_date_range_from_params
@sale_data = Sale.get_receipt_no_list(from,to)
@sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50)
end
end

View File

@@ -0,0 +1,15 @@
class Reports::ReceiptNoController < BaseReportController
def index
from, to = get_date_range_from_params
puts "from..."
puts from
puts "to..."
puts to
@sale_data = Sale.get_receipt_no_list(from,to)
@sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50)
end
def show
end
end

View File

@@ -68,6 +68,6 @@ class Settings::AccountsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def account_params
params.require(:account).permit(:title, :account_type)
params.require(:account).permit(:title, :account_type,:discount,:point,:bonus,:rebate)
end
end

View File

@@ -0,0 +1,74 @@
class Settings::MembershipActionsController < ApplicationController
before_action :set_settings_membership_action, only: [:show, :edit, :update, :destroy]
# GET /settings/membership_actions
# GET /settings/membership_actions.json
def index
@settings_membership_actions = MembershipAction.all
end
# GET /settings/membership_actions/1
# GET /settings/membership_actions/1.json
def show
end
# GET /settings/membership_actions/new
def new
@settings_membership_action = MembershipAction.new
end
# GET /settings/membership_actions/1/edit
def edit
end
# POST /settings/membership_actions
# POST /settings/membership_actions.json
def create
@settings_membership_action = MembershipAction.new(settings_membership_action_params)
respond_to do |format|
if @settings_membership_action.save
format.html { redirect_to settings_membership_actions_path, notice: 'Membership action was successfully created.' }
format.json { render :show, status: :created, location: @settings_membership_action }
else
format.html { render :new }
format.json { render json: @settings_membership_action.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/membership_actions/1
# PATCH/PUT /settings/membership_actions/1.json
def update
respond_to do |format|
if @settings_membership_action.update(settings_membership_action_params)
format.html { redirect_to settings_membership_action_path, notice: 'Membership action was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_membership_action }
else
format.html { render :edit }
format.json { render json: @settings_membership_action.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/membership_actions/1
# DELETE /settings/membership_actions/1.json
def destroy
@settings_membership_action.destroy
respond_to do |format|
format.html { redirect_to settings_membership_actions_url, notice: 'Membership action was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_membership_action
@settings_membership_action = MembershipAction.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_membership_action_params
params.require(:membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by, :additional_parameter)
end
end

View File

@@ -63,7 +63,14 @@ class Settings::MenuCategoriesController < ApplicationController
# DELETE /settings/menu_categories/1
# DELETE /settings/menu_categories/1.json
def destroy
# instances = MenuItemInstance.where("menu_item_id=?",@settings_menu_item.id)
# instances.each do |instance|
# instance.destroy
# end
# @settings_menu_item.destroy
# @settings_menu_category.destroy
abc = MenuCategory.destroyCategory(@settings_menu_category)
respond_to do |format|
format.html { redirect_to settings_menu_categories_path, notice: 'Menu category was successfully destroyed.' }
format.json { head :no_content }

View File

@@ -11,18 +11,21 @@ class Settings::MenuItemInstancesController < ApplicationController
# GET /settings/menu_item_instances/1
# GET /settings/menu_item_instances/1.json
def show
@category = MenuCategory.find(@item.menu_category_id)
id = MenuItemInstance.findParentCategory(@item)
@category = MenuCategory.find(id)
end
# GET /settings/menu_item_instances/new
def new
@category = MenuCategory.find(@item.menu_category_id)
id = MenuItemInstance.findParentCategory(@item)
@category = MenuCategory.find(id)
@settings_menu_item_instances = MenuItemInstance.new
end
# GET /settings/menu_item_instances/1/edit
def edit
@category = MenuCategory.find(@item.menu_category_id)
id = MenuItemInstance.findParentCategory(@item)
@category = MenuCategory.find(id)
end
# POST /settings/menu_item_instances
@@ -30,6 +33,7 @@ class Settings::MenuItemInstancesController < ApplicationController
def create
@settings_menu_item_instances = MenuItemInstance.new(settings_menu_item_instance_params)
#check if the menu item type is simple or not( not only the diff of status .. here is different routes)
if params[:simple_menu_item_id]
@settings_menu_item_instances.menu_item_id = params[:simple_menu_item_id]
catID = MenuItem.find(params[:simple_menu_item_id])
@@ -38,10 +42,11 @@ class Settings::MenuItemInstancesController < ApplicationController
catID = MenuItem.find(params[:set_menu_item_id])
end
category = MenuCategory.find(catID.menu_category_id)
id = MenuItemInstance.findParentCategory(catID)
category = MenuCategory.find(id)
respond_to do |format|
if @settings_menu_item_instances.save
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes]
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?)
@settings_menu_item_instances.save
format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item_instances }
@@ -55,14 +60,15 @@ class Settings::MenuItemInstancesController < ApplicationController
# PATCH/PUT /settings/menu_item_instances/1
# PATCH/PUT /settings/menu_item_instances/1.json
def update
puts "params[:menu_item_instance][:item_attributes]"
puts params[:menu_item_instance][:item_attributes]
#check if the menu item type is simple or not( not only the diff of status .. here is different routes)
if params[:simple_menu_item_id]
catID = MenuItem.find(params[:simple_menu_item_id])
else
catID = MenuItem.find(params[:set_menu_item_id])
end
category = MenuCategory.find(catID.menu_category_id)
id = MenuItemInstance.findParentCategory(catID)
category = MenuCategory.find(id)
respond_to do |format|
if @settings_menu_item_instances.update(settings_menu_item_instance_params)
@@ -86,7 +92,13 @@ class Settings::MenuItemInstancesController < ApplicationController
else
catID = MenuItem.find(params[:set_menu_item_id])
end
category = MenuCategory.find(catID.menu_category_id)
# check if the menu item is sub of another menu item
if catID.menu_category_id
category = MenuCategory.find(catID.menu_category_id)
else
item = MenuItem.find(catID.menu_item_id)
category = MenuCategory.find(item.menu_category_id)
end
respond_to do |format|
format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully destroyed.' }
format.json { head :no_content }

View File

@@ -55,7 +55,8 @@ class Settings::MenusController < ApplicationController
# DELETE /settings/menus/1
# DELETE /settings/menus/1.json
def destroy
@settings_menu.destroy
# @settings_menu.destroy
abc = Menu.destroyMenu(@settings_menu)
respond_to do |format|
format.html { redirect_to settings_menus_path, notice: 'Menu was successfully destroyed.' }
format.json { head :no_content }

View File

@@ -4,7 +4,8 @@ class Settings::OrderQueueStationsController < ApplicationController
# GET /settings/order_queue_stations
# GET /settings/order_queue_stations.json
def index
@settings_order_queue_stations = OrderQueueStation.all.active
@settings_order_queue_stations = OrderQueueStation.all
@settings_order_queue_stations = Kaminari.paginate_array(@settings_order_queue_stations).page(params[:page]).per(50)
end
# GET /settings/order_queue_stations/1
@@ -70,6 +71,6 @@ class Settings::OrderQueueStationsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_order_queue_station_params
params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by)
params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] })
end
end

View File

@@ -69,6 +69,6 @@ class Settings::PaymentMethodSettingsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_payment_method_setting_params
params.require(:payment_method_setting).permit(:payment_method, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id)
params.require(:payment_method_setting).permit(:payment_method, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :additional_parameters)
end
end

View File

@@ -0,0 +1,81 @@
class Settings::RoomsController < ApplicationController
before_action :set_settings_room, only: [:show, :edit, :update, :destroy]
before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create]
# GET /settings/rooms
# GET /settings/rooms.json
def index
@settings_rooms = @zone.rooms
end
# GET /settings/rooms/1
# GET /settings/rooms/1.json
def show
@room = Room.find(params[:id])
end
# GET /settings/rooms/new
def new
@settings_room = Room.new
end
# GET /settings/rooms/1/edit
def edit
end
# POST /settings/rooms
# POST /settings/rooms.json
def create
@settings_room = Room.new(settings_room_params)
@settings_room.type = DiningFacility::ROOM_TYPE
@settings_room.zone_id = params[:zone_id]
respond_to do |format|
if @settings_room.save
format.html { redirect_to settings_zone_rooms_path, notice: 'Room was successfully created.' }
format.json { render :show, status: :created, location: @settings_room }
else
puts "abc"
format.html { render :new }
format.json { render json: @settings_room.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/rooms/1
# PATCH/PUT /settings/rooms/1.json
def update
respond_to do |format|
if @settings_room.update(settings_room_params)
format.html { redirect_to settings_zone_rooms_path, notice: 'Room was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_room }
else
format.html { render :edit }
format.json { render json: @settings_room.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/rooms/1
# DELETE /settings/rooms/1.json
def destroy
@settings_room.destroy
respond_to do |format|
format.html { redirect_to settings_zones_path, notice: 'Room was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_room
@settings_room = Room.find(params[:id])
end
def set_settings_zone
@zone = Zone.find(params[:zone_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_room_params
params.require(:room).permit(:name, :status, :seater, :order_by,:is_active ,:id, :zone_id, :created_by)
end
end

View File

@@ -62,7 +62,7 @@ class Settings::SetMenuItemsController < ApplicationController
# DELETE /settings/menu_items/1
# DELETE /settings/menu_items/1.json
def destroy
# @settings_menu_item.destroy
abc = MenuItem.deleteRecursive(@settings_menu_item)
respond_to do |format|
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully destroyed.' }
format.json { head :no_content }
@@ -81,6 +81,6 @@ class Settings::SetMenuItemsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_params
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id , :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
end
end

View File

@@ -59,7 +59,7 @@ class Settings::SimpleMenuItemsController < ApplicationController
# DELETE /settings/menu_items/1
# DELETE /settings/menu_items/1.json
def destroy
# @settings_menu_item.destroy
abc = MenuItem.deleteRecursive(@settings_menu_item)
respond_to do |format|
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully destroyed.' }
format.json { head :no_content }
@@ -78,6 +78,6 @@ class Settings::SimpleMenuItemsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_params
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
end
end

View File

@@ -0,0 +1,81 @@
class Settings::TablesController < ApplicationController
before_action :set_settings_table, only: [:show, :edit, :update, :destroy]
before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create]
# GET /settings/tables
# GET /settings/tables.json
def index
@settings_tables = @zone.tables
end
# GET /settings/tables/1
# GET /settings/tables/1.json
def show
@table = Table.find(params[:id])
end
# GET /settings/tables/new
def new
@settings_table = Table.new
end
# GET /settings/tables/1/edit
def edit
end
# POST /settings/tables
# POST /settings/tables.json
def create
@settings_table = Table.new(settings_table_params)
@settings_table.type = DiningFacility::TABLE_TYPE
@settings_table.zone_id = params[:zone_id]
respond_to do |format|
if @settings_table.save
format.html { redirect_to settings_zone_tables_path, notice: 'Table was successfully created.' }
format.json { render :show, status: :created, location: @settings_table }
else
puts "abc"
format.html { render :new }
format.json { render json: @settings_table.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/tables/1
# PATCH/PUT /settings/tables/1.json
def update
respond_to do |format|
if @settings_table.update(settings_table_params)
format.html { redirect_to settings_zone_tables_path, notice: 'Table was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_table }
else
format.html { render :edit }
format.json { render json: @settings_table.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/tables/1
# DELETE /settings/tables/1.json
def destroy
@settings_table.destroy
respond_to do |format|
format.html { redirect_to settings_zones_path, notice: 'Table was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_table
@settings_table = Table.find(params[:id])
end
def set_settings_zone
@zone = Zone.find(params[:zone_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_table_params
params.require(:table).permit(:name, :status, :seater, :order_by,:is_active ,:id, :zone_id, :created_by)
end
end

View File

@@ -10,6 +10,8 @@ class Settings::ZonesController < ApplicationController
# GET /settings/zones/1
# GET /settings/zones/1.json
def show
@settings_tables = @settings_zone.tables
@settings_rooms = @settings_zone.rooms
end
# GET /settings/zones/new
@@ -28,7 +30,7 @@ class Settings::ZonesController < ApplicationController
respond_to do |format|
if @settings_zone.save
format.html { redirect_to @settings_zone, notice: 'Zone was successfully created.' }
format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully created.' }
format.json { render :show, status: :created, location: @settings_zone }
else
format.html { render :new }
@@ -42,7 +44,7 @@ class Settings::ZonesController < ApplicationController
def update
respond_to do |format|
if @settings_zone.update(settings_zone_params)
format.html { redirect_to @settings_zone, notice: 'Zone was successfully updated.' }
format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_zone }
else
format.html { render :edit }
@@ -56,7 +58,7 @@ class Settings::ZonesController < ApplicationController
def destroy
@settings_zone.destroy
respond_to do |format|
format.html { redirect_to settings_zones_url, notice: 'Zone was successfully destroyed.' }
format.html { redirect_to settings_zones_path, notice: 'Zone was successfully destroyed.' }
format.json { head :no_content }
end
end
@@ -69,6 +71,6 @@ class Settings::ZonesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_zone_params
params.require(:settings_zone).permit(:name, :is_active, :created_by)
params.require(:zone).permit(:name, :is_active, :created_by)
end
end

View File

@@ -0,0 +1,77 @@
class Transactions::ManualSalesController < ApplicationController
def void
@sale = params[:sale_id]
@reason = Lookup.where("lookup_type = 'void_reason'")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sales }
end
end
def manual_void_sale
sale_id = params[:sale_id]
reason = params[:reason]
sale = Sale.find(sale_id)
sale.sale_status = 'void'
sale.requested_by = current_login_employee.id
if sale.save
@sale = SaleAudit.record_audit_void(sale_id, current_login_employee.id, current_login_employee.id, reason)
if sale.sale_orders
sale.sale_orders.each do |bo|
order =Order.find(bo.order_id)
order.status= 'void'
order.save
booking_order = BookingOrder.find_by_order_id(bo.order_id)
if booking_order.booking_id
booking = Booking.find(booking_order.booking_id)
dining_facility = booking.dining_facility
dining_facility.status = 'available'
dining_facility.save
end
end
end
end
respond_to do |format|
format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully void.' }
end
end
def manual_complete_sale
sale_id = params[:sale_id]
sale = Sale.find(sale_id)
sale.sale_status = 'completed'
sale.requested_by = current_login_employee.id
remark = "Complete for Sale ID #{sale_id} By #{current_login_employee.name}"
if sale.save
@sale = SaleAudit.record_audit_complete(sale_id, remark, current_login_employee.id)
if sale.sale_orders
sale.sale_orders.each do |bo|
# order =Order.find(bo.order_id)
# order.status= 'void'
# order.save
booking_order = BookingOrder.find_by_order_id(bo.order_id)
if booking_order.booking_id
booking = Booking.find(booking_order.booking_id)
dining_facility = booking.dining_facility
dining_facility.status = 'available'
dining_facility.save
end
end
end
end
redirect_to transactions_sales_path
end
end

View File

@@ -0,0 +1,32 @@
class Transactions::OrdersController < ApplicationController
def index
filter = params[:filter]
if filter.nil?
orders = Order.order("order_id desc")
else
order = Order.search(filter)
if order.count > 0
orders = order
else
orders = Order.order("order_id desc")
end
end
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @orders }
end
end
def show
@order = Order.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @order }
end
end
end

View File

@@ -4,12 +4,68 @@ class Transactions::SalesController < ApplicationController
# GET /transactions/sales
# GET /transactions/sales.json
def index
@transactions_sales = Sale.all
search_date = params[:date]
receipt_no = params[:receipt_no]
today = Date.today
if receipt_no.nil? && search_date.nil?
@sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
else
if !search_date.blank? && receipt_no.blank?
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", search_date).order("sale_id desc").limit(500).page(params[:page])
elsif !search_date.blank? && !receipt_no.blank?
sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
else
sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
end
if sale.count > 0
@sales = sale
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
else
@sales = 0
end
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sales }
end
end
# GET /transactions/sales/1
# GET /transactions/sales/1.json
def show
@sale = Sale.find(params[:id])
@order_items = []
@sale.sale_orders.each do |sale_order|
order = Order.find(sale_order.order_id)
#if (order.status == "new")
@order_items = @order_items + order.order_items
#end
end
@sale_receivables = SalePayment.where('sale_id = ?', @sale.id)
#get customer amount
@customer = Customer.find(@sale.customer_id)
response = Customer.get_member_account(@customer)
if(response["status"] == true)
@membership = response["data"]
else
@membership = 0
end
#end customer amount
respond_to do |format|
format.html # show.html.erb
format.json { render json: @sale }
end
end
# GET /transactions/sales/new

View File

@@ -1,7 +1,7 @@
#Form object to use during the installation process - will handle creation of shop model into db after verification from the cloud
#provising service through license verification
class ShopForm < ActiveModel
:attr_accessor :logo, :name, :address, :township, :city, :state, :country, :license, :base_currency, :password, :password_confirmation
end
# class ShopForm < ActiveModel
# # attr_accessor :logo, :name, :address, :township, :city, :state, :country, :license, :base_currency, :password, :password_confirmation
#
# end

View File

@@ -0,0 +1,2 @@
module Api::Origami::PayparHelper
end

View File

@@ -0,0 +1,2 @@
module Crm::DiningQueuesHelper
end

View File

@@ -0,0 +1,2 @@
module Origami::PayparHelper
end

View File

@@ -0,0 +1,2 @@
module Origami::RedeemPaymentsHelper
end

View File

@@ -0,0 +1,2 @@
module Settings::MembershipActionsHelper
end

View File

@@ -0,0 +1,2 @@
module Settings::OrdersHelper
end

View File

@@ -5,7 +5,7 @@ class OrderQueueProcessorJob < ApplicationJob
# Do something later
#Order ID
order = Order.find(order_id)
#Loop through the order stations and process the items
#Execute orders and send to order stations
if order

View File

@@ -2,6 +2,8 @@ class Account < ApplicationRecord
validates_presence_of :title, :account_type
has_many :menu_items
# belongs_to :lookup , :class_name => "Lookup"
def self.collection
Account.select("id, title").map { |e| [e.title, e.id] }
end
end

View File

@@ -1,4 +1,9 @@
class AssignedOrderItem < ApplicationRecord
before_create :generate_custom_id
#primary key - need to be unique
self.primary_key = "assigned_order_item_id"
belongs_to :order
belongs_to :order_queue_station
@@ -11,4 +16,9 @@ class AssignedOrderItem < ApplicationRecord
assigned_order_item.delivery_status = false
assigned_order_item.save
end
private
def generate_custom_id
self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI")
end
end

View File

@@ -1,9 +1,17 @@
class Booking < ApplicationRecord
self.primary_key = "booking_id"
#primary key - need to be unique
before_create :generate_custom_id
belongs_to :dining_facility, :optional => true
belongs_to :sale, :optional => true
has_many :booking_orders
has_many :orders, :through => :booking_orders
private
def generate_custom_id
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")
end
end

View File

@@ -1,5 +1,5 @@
class BookingOrder < ApplicationRecord
#primary key - need to be unique
#primary key - need to be unique
belongs_to :booking
belongs_to :order

View File

@@ -1,4 +1,11 @@
class CashierLoginLog < ApplicationRecord
before_create :generate_custom_id
belongs_to :cashier_station
belongs_to :employee
private
def generate_custom_id
self.cashier_login_log_id = SeedGenerator.generate_id(self.class.name, "CLO")
end
end

View File

@@ -1,11 +1,74 @@
class Customer < ApplicationRecord
#self.primary_key = :customer_id
before_create :generate_custom_id
has_many :orders
has_many :sales
validates_presence_of :name, :contact_no
validates_presence_of :name, :contact_no, :email
validates :contact_no, uniqueness: true
validates :email, uniqueness: true
paginates_per 50
# def self.get_member_group
# membership = MembershipSetting.find_by_membership_type("paypar_url")
# memberaction = MembershipAction.find_by_membership_type("get_all_member_group")
# app_token = membership.auth_token.to_s
# url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# response = HTTParty.get(url,
# :body => { app_token: app_token}.to_json,
# :headers => {
# 'Content-Type' => 'application/json',
# 'Accept' => 'application/json'
# }
# )
# puts response.body, response.code, response.message, response.headers.inspect
# return response;
# end
def self.get_member_account(customer)
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_all_member_account")
merchant_uid = memberaction.merchant_account_id.to_s
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.get(url, :body => { membership_id: customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
return response;
end
def self.search(search)
if search
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
else
find(:all)
end
end
# def self.search(search)
# where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
# end
def lastest_invoices
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
end
private
def generate_custom_id
self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS")
end
end

View File

@@ -9,10 +9,11 @@ class DiningFacility < ApplicationRecord
scope :active, -> {where(is_active: true)}
def get_current_booking
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='occupied' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
puts "enter booking"
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
if booking.count > 0 then
return booking[0]
return booking[0].booking_id
else
return nil
end

View File

@@ -0,0 +1,7 @@
class DiningQueue < ApplicationRecord
def self.generate_queue_no
queue_no = DiningQueue.all.count + 1
return queue_no
end
end

View File

@@ -6,6 +6,9 @@ class Employee < ApplicationRecord
validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true
validates :password, numericality: true, length: {in: 3..9}, allow_blank: true
def self.collection
Employee.select("id, name").map { |e| [e.name, e.id] }
end
def self.login(emp_id, password)
user = Employee.find_by_emp_id(emp_id)

View File

@@ -17,6 +17,10 @@ class Lookup < ApplicationRecord
"Gateway Communication Type" => "gateway_communication_type"}
end
# def self.get_by_type( lookup_type)
# Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
# end
def self.collection_of(type)
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }

View File

@@ -0,0 +1,2 @@
class MembershipAction < ApplicationRecord
end

View File

@@ -22,4 +22,13 @@ class Menu < ApplicationRecord
return current_menu
end
def self.destroyMenu(menu)
cats = MenuCategory.where("menu_id=?",menu.id)
cats.each do |cat|
abc = MenuCategory.destroyCategory(cat)
end
menu.destroy
return false
end
end

View File

@@ -8,5 +8,29 @@ class MenuCategory < ApplicationRecord
default_scope { order('order_by asc') }
def self.destroyCategory(menu_category)
# find the sub menu item of current item
sub_menu_cat = MenuCategory.where("menu_category_id=?",menu_category.id)
if sub_menu_cat.length != 0
sub_menu_cat.each do |sub|
if destroyCategory(sub)
end
end
# find the items of current menu item
items = MenuItem.where("menu_category_id=?",menu_category.id)
items.each do |item|
abc = MenuItem.deleteRecursive(item)
end
menu_category.destroy
return true
else
items = MenuItem.where("menu_category_id=?",menu_category.id)
items.each do |item|
abc = MenuItem.deleteRecursive(item)
end
menu_category.destroy
return false
end
end
end

View File

@@ -1,9 +1,10 @@
class MenuItem < ApplicationRecord
belongs_to :account
belongs_to :menu_category, :optional => true
has_many :menu_item_instances
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
belongs_to :account
validates_presence_of :item_code, :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
@@ -38,4 +39,31 @@ class MenuItem < ApplicationRecord
return nil
end
def self.deleteRecursive(menu_item)
# find the sub menu item of current item
sub_menu_items = MenuItem.where("menu_item_id=?",menu_item.id)
if sub_menu_items.length != 0
sub_menu_items.each do |subitem|
if deleteRecursive(subitem)
end
end
# find the instances of current menu item
instances = MenuItemInstance.where("menu_item_id=?",menu_item.id)
instances.each do |instance|
instance.destroy
end
menu_item.destroy
return true
else
instances = MenuItemInstance.where("menu_item_id=?",menu_item.id)
instances.each do |instance|
instance.destroy
end
menu_item.destroy
return false
end
end
end

View File

@@ -1,4 +1,12 @@
class MenuItemInstance < ApplicationRecord
belongs_to :menu_item
def self.findParentCategory(item)
if item.menu_category_id
return item.menu_category_id
else
parentitem = MenuItem.find(item.menu_item_id)
findParentCategory(parentitem)
end
end
end

View File

@@ -1,6 +1,8 @@
class Order < ApplicationRecord
#primary key - need to be unique
self.primary_key = "order_id"
#primary key - need to be unique
before_create :generate_custom_id
before_create :set_order_date
belongs_to :customer
@@ -23,14 +25,15 @@ class Order < ApplicationRecord
booking = nil
if self.new_booking
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
:booking_status => "assign" })
table = DiningFacility.find(self.table_id)
table.status = "occupied"
table.save
else
if (self.booking_id.to_i > 0 )
booking = Booking.find(self.booking_id)
end
booking = Booking.find(self.booking_id)
end
booking.save!
@@ -40,13 +43,13 @@ class Order < ApplicationRecord
self.adding_line_items
#Add Order Table and Room relation afrer order creation
BookingOrder.create({:booking_id => booking.id, :order => self})
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
#Send order to queue one it done!
process_order_queue
#send order to broadcast job
send_order_broadcast
#send_order_broadcast
return true, booking
@@ -182,14 +185,6 @@ class Order < ApplicationRecord
return new_items_list
end
private
def validate_api_inputs
end
def set_order_date
self.date = Time.now.utc
end
#Update Items Count and Quantity changes whenever there is changes
def update_products_and_quantity_count
@@ -198,7 +193,7 @@ class Order < ApplicationRecord
# Count number of different items
self.item_count = self.order_items.item_count
self.quantity_count = quantity_count
# Counter number of quantity
# Counter number of quantityf
end
#Process order items and send to order queue
@@ -214,42 +209,125 @@ class Order < ApplicationRecord
OrderBroadcastJob.perform_later(self.id)
end
#Origami: Cashier : to view order type Table
#Origami: Cashier : to view order Table
def self.get_order_table
order_table = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
order_items.id as order_items_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.order_id = orders.id
left join bookings on bookings.id = booking_orders.id
order_table = Order.select("orders.order_id as order_id,sum(order_items.qty*order_items.price) as total_price,
order_items.order_items_id as order_items_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.order_id = orders.order_id
left join bookings on bookings.booking_id = booking_orders.booking_order_id
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
left join order_items on order_items.order_id = orders.id")
left join order_items on order_items.order_id = orders.order_id")
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true)
.group("orders.id")
.group("orders.order_id, order_items.order_items_id,dining_facilities.name")
end
#Origami: Cashier : to view booking order Table
def self.get_booking_order_table
booking_orders = Booking.select("sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status,
orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id,
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true)
.group("bookings.booking_id")
# For PG
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id
end
#Origami: Cashier : to view booking order Table
def self.get_completed_order
completed_orders = Booking.select("sales.receipt_no, sales.sale_status, orders.status as order_status,orders.order_id,
bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("sales.sale_status='completed'")
.group("sales.sale_id,bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id")
# For PG
#bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id
end
#Origami: Cashier : to view order type Room
def self.get_booking_order_rooms
booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status,
orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id,
bookings.booking_id,orders.customer_id as customer_id,
sales.sale_id as sale_id,dining_facilities.name as room_name")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true)
.group("bookings.booking_id")
# For PG
# booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true
# sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id
end
#Origami: Cashier : to view order type Room
def self.get_order_rooms
order_rooms = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
order_items.id as order_items_id,dining_facilities.name as room_name")
.joins("left join booking_orders on booking_orders.order_id = orders.id
left join bookings on bookings.id = booking_orders.id
order_rooms = Order.select("orders.order_id as order_id,sum(order_items.qty*order_items.price) as total_price,
order_items.id as order_items_id,dining_facilities.name as room_name")
.joins("left join booking_orders on booking_orders.order_id = orders.order_id
left join bookings on bookings.booking_id = booking_orders.order_id
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
left join order_items on order_items.order_id = orders.id")
left join order_items on order_items.order_id = orders.order_id")
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true)
.group("orders.id,order_items.id,dining_facilities.name")
.group("orders.order_id")
end
#Origami: Cashier : to view orders
def self.get_orders
from = Time.now.beginning_of_day.utc
to = Time.now.end_of_day.utc
orders = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
order_items.id as order_items_id,dining_facilities.name as table_or_room_name")
.joins("left join booking_orders on booking_orders.order_id = orders.id
left join bookings on bookings.id = booking_orders.id
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
left join order_items on order_items.order_id = orders.id")
orders=Booking.select("sales.receipt_no, sales.sale_status as sale_status, orders.status as order_status,
orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id,
bookings.booking_id,orders.customer_id as customer_id,
sales.sale_id as sale_id,dining_facilities.name as table_name")
.joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("(orders.status = 'new' or orders.status = 'billed')")
# orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status, sales.sale_status as sale_status,
# orders.order_id as order_id,sales.customer_id as sale_customer_id,orders.customer_id as order_customer_id
# ,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name")
# .joins("left join booking_orders on booking_orders.order_id = orders.order_id
# left join bookings on bookings.booking_id = booking_orders.order_id
# left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
# left join order_items on order_items.order_id = orders.order_id
# left join sale_orders on sale_orders.order_id = orders.order_id
# left join sales on sales.sale_id = sale_orders.sale_id")
# .where("(orders.status = 'new' or orders.status = 'billed')")
# .group("orders.order_id")
# For PG
# .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
# .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id,orders.customer_id")
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
.group("orders.id")
end
def self.search(search)
if search
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
where("order_id LIKE ?", "%#{search}%")
else
find(:all)
end
end
private
def generate_custom_id
self.order_id = SeedGenerator.generate_id(self.class.name, "ODR")
end
def set_order_date
self.date = Time.now.utc
end
end

View File

@@ -1,5 +1,8 @@
class OrderItem < ApplicationRecord
self.primary_key = "order_items_id"
#primary key - need to be unique
before_create :generate_custom_id
#Associations
belongs_to :order, autosave: true
@@ -32,14 +35,33 @@ class OrderItem < ApplicationRecord
#logger.debug orderitem.to_yml
orderitem.save!
end
#Origami : Cashier : to show order items details
def self.get_order_items_details(order_id)
def self.get_order_items_details(booking_id)
# booking_orders = BookingOrder.where("booking_id=?",booking.booking_id)
# if booking_orders
# booking_orders.each do |book_order|
# order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
# .joins("left join orders on orders.order_id = order_items.order_id")
# .where("order_items.order_id=?",book_order.order)
# return order_details
# end
# else
# return false
# end
order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
.joins("left join orders on orders.id = order_items.order_id")
.where("order_items.order_id=?",order_id)
.joins("left join orders on orders.order_id = order_items.order_id")
.joins("left join booking_orders on booking_orders.order_id = order_items.order_id")
.joins("left join bookings on bookings.booking_id = booking_orders.booking_id")
.where("bookings.booking_id=?",booking_id)
return order_details
end
private
def generate_custom_id
self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI")
end
end

View File

@@ -5,10 +5,12 @@
class OrderQueueStation < ApplicationRecord
has_many :assigned_order_items
has_many :order_items
has_many :order_queue_process_by_zones
has_many :zones, through: :order_queue_process_by_zones
scope :active, -> {where(is_active: true)}
def process_order (order)
def process_order (order)
oqs_stations = OrderQueueStation.active
order_items = order.order_items
@@ -20,10 +22,10 @@ class OrderQueueStation < ApplicationRecord
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
order_items.each do |order_item|
if (pq_item == order_item.item_code)
#Same Order_items can appear in two location.
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
end
end

Some files were not shown because too many files have changed in this diff Show More