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

* 'august_spring' of bitbucket.org:code2lab/sxrestaurant: (71 commits)
  Update
  Coupon / Voucher data change
  update menu_sync
  update addorder
  update addorder view
  add fields for Menu Sync
  update add oreder
  add menu api
  update add order and calculate subtotal
  update seed
  menu ui update
  update ability for setmenu
  fixed
  update show for foc
  add bootstrap file input and menu item img implemented
  update foc and pdf
  update menu item
  update receipt bill pdf for foc and credit
  add CarrierWave gems for menu image upload
  add CarrierWave gems for menu image upload
  ...
This commit is contained in:
Zin Lin Phyo
2017-08-21 13:30:28 +06:30
169 changed files with 4114 additions and 866 deletions

View File

@@ -36,6 +36,9 @@ gem 'tether-rails'
gem "font-awesome-rails"
gem 'rack-cors'
# image upload
gem 'carrierwave', '~> 1.0'
#Report and Printing gems
gem 'cups', '~> 0.0.7'
gem 'prawn'

View File

@@ -51,6 +51,10 @@ GEM
builder (3.2.3)
byebug (9.0.6)
cancancan (1.17.0)
carrierwave (1.1.0)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
chronic (0.10.2)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
@@ -250,6 +254,7 @@ DEPENDENCIES
bootstrap-datepicker-rails
byebug
cancancan (~> 1.10)
carrierwave (~> 1.0)
coffee-rails (~> 4.2)
cups (~> 0.0.7)
database_cleaner

BIN
app/assets/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -23,8 +23,90 @@ $(document).ready(function(){
// setTimeout(function(){
// window.location.reload(1);
// }, 10000);
$(".nav-completed").on("click", function(){
$("#completed").removeClass('hide')
$(".oqs_append").addClass('hide')
});
$('.queue_station').on('click',function(){
$(".oqs_click").on("click", function(){
$("#completed").addClass('hide')
$(".oqs_append").removeClass('hide')
var oqs_id = $(this).find(".oqs-id").text();
var url = 'oqs/get_items/'+oqs_id;
show_details(url);
}); //End Click
function show_details(url){
var oqs_append = $('.oqs_append');
oqs_append.empty();
var filter = $('.filter').text();
//Start Ajax
$.ajax({
type: "GET",
url: url,
data: {'filter':filter},
dataType: "json",
success: function(data) {
for(var field in data) {
var price = parseFloat(data[field].price).toFixed(2);
if (data[field]["options"] == "[]") {
var options = "";
}else{
var options = data.options;
}
var date = new Date(data[field]["created_at"]);
var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
row ='<div class="card queue_station">'
+'<div class="card-block">'
+'<h4 class="card-title">'
+'<span class="order-zone-type">'+data[field]["table_type"]+'- </span>'
+'<span class="order-zone">'+ data[field]["zone"] +'</span>'
+'<small class="pull-right">'+ data[field]["order_id"] +'- </small>'
+'</h4>'
+'<h4>'
+'<span class="order-item">'+ data[field]["item_name"] +'- </span>'
+'<span class="order-qty">'+ data[field]["qty"] +'- </span>'
+'</h4>'
+'<p class="card-text item-options">'+ options +'</p>'
+'<p class="card-text">'
+'<small class="text-muted">Order at'
+'<span class="order-at">'+ show_date +'</span> - '
+'<span class="order-by">'+ data[field]["item_order_by"] +'</span> '
+'</small> '
+'</p>'
+'<p class="hidden order-customer">'+ data[field]["customer_name"] +'</p> '
+'<p class="hidden assigned-order-item">'+ data[field]["assigned_order_item_id"] +'</p> '
+'</div>'
+'<div class="card-footer">'
+'<button id="edit_'+ data[field]["assigned_order_item_id"]+'" class="btn btn-warning order-item order-item-edit">EDIT</button>'
+' <button id="assigned_queue_' + data[field]["assigned_order_item_id"] +'" class="btn btn-primary order-item order-complete">COMPLETE</button>'
+'</div>'
+'</div>';
$('.oqs_append').append(row);
}
}
});
//end Ajax
}
$(document).on('click', '.queue_station', function(event){
var orderZone=$(this).children().children().children('.order-zone').text().trim();
// var orderItem=$(this).children().children().children('.order-item').text();
var assigned_item_id = $(this).children().find(".assigned-order-item").text();
@@ -41,7 +123,6 @@ $(document).ready(function(){
$('#order-from').text(orderZone);
// clear order items
$("#oqs-order-details-table").children("tbody").empty();
// Call get_order_items() for Order Items by dining
$.ajax({
type: 'GET',
@@ -68,14 +149,15 @@ $(document).ready(function(){
$(this).addClass('selected-item');
});
$(".order-item-edit").on('click', function(){
$(document).on('click', '.order-item-edit', function(event){
var _self = $(this); // To know in ajax return
var assigned_item_id=$(this).attr('id').substr(5);
window.location.href = '/oqs/'+ assigned_item_id + "/edit"
});
// complete for queue item
$('.order-complete').on('click',function(e){
$(document).on('click', '.order-complete', function(event){
//e.preventDefault();
var _self = $(this); // To know in ajax return
var assigned_item_id=$(this).attr('id').substr(15);
@@ -117,10 +199,11 @@ $(document).ready(function(){
});
// Print Order Item
$('#print_order_item').on('click',function(){
$(document).on('click', '#print_order_item', function(event){
var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text();
var options = $('.selected-item').children('.card-block').find('.item-options').text();
var params = { 'options':options };
$.ajax({
type: 'GET',
url: '/oqs/print/print/'+assigned_item_id,
@@ -129,7 +212,8 @@ $(document).ready(function(){
});
// Print Order Summary
$('#print_order_summary').on('click',function(){
// $('#print_order_summary').on('click',function(){
$(document).on('click', '#print_order_summary', function(event){
var table_name=$('.selected-item').children().children().children('.order-zone').text().trim();
var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
var params = { 'table_name':table_name };

View File

@@ -20,6 +20,36 @@
//= require jquery-ui
//= require bootstrap-datepicker
$(document).on('turbolinks:load', function() {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
// Image Upload
$("#simple_menu_item_image_path").fileinput({
previewFileType: "image",
allowedFileExtensions: ["jpg", "gif", "png"],
browseClass: "btn btn-success",
browseLabel: "Pick Image",
browseIcon: "<i class=\"fa fa-image\"></i> ",
removeClass: "btn btn-danger",
removeLabel: "Delete",
removeIcon: "<i class=\"fa fa-trash\"></i> ",
showUpload: false,
// uploadClass: "btn btn-info",
// uploadLabel: "Upload",
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
previewTemplates: {
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
'</div>\n',
}
});
});
$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
$('.dropdown-toggle').dropdown();
@@ -31,14 +61,6 @@ function export_to(path)
window.location = path+"?"+ form_params;
}
$(function () {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
});

12
app/assets/javascripts/fileinput.min.js vendored Executable file

File diff suppressed because one or more lines are too long

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,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/

12
app/assets/stylesheets/fileinput.min.css vendored Executable file

File diff suppressed because one or more lines are too long

View File

@@ -268,4 +268,3 @@ tr.discount-item-row:hover {
-moz-opacity: 1; /* mozilla */
}

View File

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

View File

@@ -26,7 +26,38 @@ ul.dropdown-menu li a{
background-color: transparent !important;
margin-bottom: 0px !important;
}
.page-header{
border-bottom :0px solid #000 !important;
margin :0px !important;
}
.center-text {
text-align:center;
background-color:#ddd;
}
.footer {
position: fixed;
bottom: 0;
left: 0;
height: auto;
background-color: #ef404a;
width: 100%;
}
.footer-header {
color : #ef404a;
font-weight:bold;
font-style:italic;
margin-bottom:0px;
}
.menu-item-img {
margin: 10px;
text-align: center;
}
.padding-10 {
padding: 10px;
}

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the Settings/ItemSets 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/Menu_item_sets 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,9 @@
class Api::Restaurant::ItemSetsController < Api::ApiController
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
@item_sets = ItemSet.all
end
end

View File

@@ -1,11 +1,11 @@
class Api::Restaurant::MenuController < Api::ApiController
class Api::Restaurant::MenuCategoriesController < Api::ApiController
skip_before_action :authenticate
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
@menus = Menu.all
@current_menu = Menu.current_menu
@menus = MenuCategory.all
@current_menu = MenuCategory.current_menu
end
@@ -21,10 +21,10 @@ class Api::Restaurant::MenuController < Api::ApiController
def menu_detail (menu_id)
if (menu_id)
#Pull this menu
menu = Menu.find_by_id(menu_id)
menu = MenuCategory.find_by_id(menu_id)
return menu
else
Menu.current_menu
MenuCategory.current_menu
end
end

View File

@@ -1,12 +1,11 @@
class Api::Restaurant::MenuController < Api::ApiController
skip_before_action :authenticate
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
@menus = Menu.all
@current_menu = Menu.current_menu
# @current_menu = Menu.current_menu
end
#Description

View File

@@ -6,8 +6,4 @@ class Api::Restaurant::MenuItemAttributesController < Api::ApiController
def index
@menu_attributes = MenuItemAttribute.all
end
end

View File

@@ -1,13 +1,8 @@
class Api::Restaurant::MenuItemOptionsController < Api::ApiController
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
@menu_options = MenuItemOption.all
end
end

View File

@@ -17,7 +17,6 @@ module TokenVerification
authenticate_with_http_token do |token, options|
#@current_user = User.find_by(api_key: token)
Rails.logger.debug "token - " + token.to_s
@user = Employee.authenticate_by_token(token)
if @user
return true

View File

@@ -17,6 +17,8 @@ class Crm::CustomersController < BaseCrmController
@crm_customer = Customer.new
@count_customer = Customer.count_customer
@taxes = TaxProfile.all.order("order_by asc")
# if flash["errors"]
# @crm_customer.valid?
# end
@@ -63,15 +65,21 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers/1/edit
def edit
@customer = Customer.find(params[:id])
end
# POST /crm/customers
# POST /crm/customers.json
def create
# Remove "" default first
params[:customer][:tax_profiles].delete_at(0)
@crm_customers = Customer.new(customer_params)
respond_to do |format|
if @crm_customers.save
# update tax profile
customer = Customer.find(@crm_customers.customer_id)
customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
@@ -188,10 +196,12 @@ end
# PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json
def update
# Remove "" default first
params[:customer][:tax_profiles].delete_at(0)
respond_to do |format|
if @crm_customer.update(customer_params)
# update tax profile
@crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
@@ -346,7 +356,7 @@ end
# Never trust parameters from the scary internet, only allow the white list through.
def customer_params
params.require(:customer).permit(:name, :company, :contact_no, :email,
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no)
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type)
end
end

View File

@@ -0,0 +1,126 @@
class Oqs::HomeController < BaseOqsController
def index
queue_stations=OrderQueueStation.all
# Query for OQS with delivery status false
@queue_items_details = queue_items_query(false)
# Query for OQS with delivery status true
@queue_completed_item = completed_order
@queue_stations_items=Array.new
# Calculate Count for each station tab
queue_stations.each do |que|
i = 0
zone_id = 0
@queue_items_details.each do |qid|
dining = DiningFacility.find_by_name(qid.zone)
que.order_queue_process_by_zones.each do |qz|
if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
zone_id = qid.zone_id
i=i+1
end
end
end
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
end
# @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
@queue_stations_items
end
# Get Order items
def get_order_items
items = []
table_name = params[:table_id]
status = params[:status]
dining = DiningFacility.find_by_name(table_name);
# oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
# if status == ""
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi|
# oi = OrderItem.find_by_item_code(aoi.item_code)
# items.push(oi)
# end
# else
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi|
# oi = OrderItem.find_by_item_code(aoi.item_code)
# items.push(oi)
# end
# end
booking = Booking.find_by_dining_facility_id(dining.id)
BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo|
order=Order.find(bo.order_id)
order.order_items.each do |oi|
items.push(oi)
end
end
# booking_id = dining.get_new_booking
# BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
# order=Order.find(bo.order_id);
# order.order_items.each do |oi|
# items.push(oi)
# end
# end
render :json => items.to_json
end
def show
end
# 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_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 delivery status
def queue_items_query(status)
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.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 AND odt.order_id = assigned_order_items.order_id
left join customers as cus ON cus.customer_id = od.customer_id
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = 0 AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
.group("assigned_order_items.assigned_order_item_id")
.order("assigned_order_items.created_at")
end
# Completed Order
def completed_order
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.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 AND odt.order_id = assigned_order_items.order_id
left join customers as cus ON cus.customer_id = od.customer_id
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
.group("assigned_order_items.order_id")
.limit(20)
.order("assigned_order_items.created_at")
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
end

View File

@@ -1,33 +1,44 @@
class Oqs::HomeController < BaseOqsController
def index
queue_stations=OrderQueueStation.all
@queue_stations = OrderQueueStation.all
# Query for OQS with delivery status false
@queue_items_details = queue_items_query(false)
# @queue_items_details = queue_items_query(false)
# Query for OQS with delivery status true
@queue_completed_item = completed_order
@queue_stations_items=Array.new
@filter = params[:filter]
@queue_completed_item = completed_order(@filter)
if !@filter.nil?
@count = queue_items_count_query(false,@filter)
@count.each do |count|
end
end
# @queue_stations_items=Array.new
# Calculate Count for each station tab
queue_stations.each do |que|
i = 0
zone_id = 0
@queue_items_details.each do |qid|
dining = DiningFacility.find_by_name(qid.zone)
que.order_queue_process_by_zones.each do |qz|
if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
zone_id = qid.zone_id
i=i+1
end
end
end
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
end
# @queue_stations.each do |que|
# i = 0
# zone_id = 0
# @queue_items_details.each do |qid|
# dining = DiningFacility.find_by_name(qid.zone)
# que.order_queue_process_by_zones.each do |qz|
# if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
# zone_id = qid.zone_id
# i=i+1
# end
# end
# end
# @queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
# end
# @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
@queue_stations_items
# # @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
# @queue_stations_items
end
# Get Order items
@@ -68,6 +79,13 @@ class Oqs::HomeController < BaseOqsController
render :json => items.to_json
end
def get_items_by_oqs
oqs_id = params[:id]
filter = params[:filter]
items = queue_items_query(false,oqs_id,filter)
render :json => items.to_json
end
def show
end
@@ -87,9 +105,22 @@ class Oqs::HomeController < BaseOqsController
render :json => removed_item.to_json
end
# Query for OQS with delivery status
def queue_items_query(status)
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
def queue_items_query(status,oqs_id=nil,filter)
if oqs_id == nil
oqs = ''
else
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
end
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
oqs.id as station_id, oqs.station_name,
oqs.is_active, oqpz.zone_id,
df.name as zone, df.type as table_type,
odt.order_id, odt.item_code, odt.item_name,
odt.price, odt.qty, odt.item_order_by, odt.options,
cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
@@ -98,14 +129,15 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("assigned_order_items.assigned_order_item_id")
.order("assigned_order_items.created_at")
end
# Completed Order
def completed_order
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
def completed_order(filter)
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
@@ -115,6 +147,7 @@ class Oqs::HomeController < BaseOqsController
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("assigned_order_items.order_id")
.limit(20)
.order("assigned_order_items.created_at")
@@ -123,4 +156,19 @@ class Oqs::HomeController < BaseOqsController
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
def queue_items_count_query(status,filter)
query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_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 AND odt.order_id = assigned_order_items.order_id
left join customers as cus ON cus.customer_id = od.customer_id
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("oqs.id")
end
end

View File

@@ -0,0 +1,22 @@
class Origami::AddordersController < BaseOrigamiController
before_action :set_dining, only: [:show]
def index
@tables = Table.all.active.order('zone_id asc').group("zone_id")
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
@all_table = Table.all.active.order('status desc')
@all_room = Room.all.active.order('status desc')
end
def show
@menu = MenuCategory.all
@table_id = params[:id]
end
private
def set_dining
@dining = DiningFacility.find(params[:id])
end
end

View File

@@ -38,13 +38,13 @@ class Origami::CustomersController < BaseOrigamiController
#@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
@count_customer = Customer.count_customer
@taxes = TaxProfile.all.order("order_by asc")
# if flash["errors"]
# @crm_customer.valid?
# end
@@ -60,6 +60,7 @@ class Origami::CustomersController < BaseOrigamiController
id = params[:sale_id][0,3]
customer_id = params[:customer_id]
customer = Customer.find(customer_id)
# Check and find with card no
# if(!customer_id.include? "CUS")
@@ -74,7 +75,7 @@ class Origami::CustomersController < BaseOrigamiController
status = sale.update_attributes(customer_id: customer_id)
sale.sale_orders.each do |sale_order|
order = Order.find(sale_order.order_id)
status = order.update_attributes(customer_id: customer_id)
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
end
else
@booking = BookingOrder.find_by_order_id(params[:sale_id])
@@ -82,13 +83,15 @@ class Origami::CustomersController < BaseOrigamiController
@orders.each do |bo|
order = Order.find(bo.order_id)
status = order.update_attributes(customer_id: customer_id)
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
end
end
if status == true
render json: JSON.generate({:status => true})
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end

View File

@@ -6,6 +6,8 @@ class Origami::HomeController < BaseOrigamiController
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("sale_status != 'new'")
@orders = Order.all.order('date desc')
@shop = Shop.find_by_id(1)
# @shift = ShiftSale.current_open_shift(current_user.id)
end
@@ -38,7 +40,6 @@ class Origami::HomeController < BaseOrigamiController
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
puts "enter"
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'

View File

@@ -163,6 +163,35 @@ class Origami::PaymentsController < BaseOrigamiController
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
end
def foc
cash = params[:cash]
sale_id = params[:sale_id]
sub_total = params[:sub_total]
member_info = nil
rebate_amount = nil
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "foc")
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
#shop detail
shop_details = Shop.find(1)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC")
end
end
def rounding_adj
saleObj = Sale.find(params[:sale_id])

View File

@@ -33,13 +33,19 @@ class Origami::ShiftsController < BaseOrigamiController
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes)
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
end
@@ -53,6 +59,21 @@ class Origami::ShiftsController < BaseOrigamiController
def sale_summary
@shift = ShiftSale.current_open_shift(current_user.id)
# @shift = ShiftSale.find_by_id(shift_id)
if @shift
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
end
end
end

View File

@@ -6,18 +6,19 @@ class Origami::VoidController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
sale.payment_status = 'void'
sale.sale_status = 'void'
sale.save
# update count for shift sale
if(sale.sale_status == "void")
if(sale.sale_status == "completed")
if sale.shift_sale_id != nil
shift = ShiftSale.find(sale.shift_sale_id)
shift.calculate(sale_id, "void")
end
end
sale.payment_status = 'void'
sale.sale_status = 'void'
sale.save
bookings = sale.bookings
bookings.each do |booking|
orders = booking.orders

View File

@@ -22,7 +22,7 @@ class Origami::VoucherController < BaseOrigamiController
def create
cash = params[:amount]
sale_id = params[:sale_id]
sale_id = params[:refnumber]
voucher_no = params[:refnumber]
if(Sale.exists?(sale_id))
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
@@ -37,11 +37,12 @@ class Origami::VoucherController < BaseOrigamiController
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
# app_token: token,membership_id:membership_id,
# campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,
# auth_token:auth_token
begin
response = HTTParty.get(url,
:body => { app_token: token,membership_id:membership_id,
campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,
auth_token:auth_token
:body => { voucher_no: voucher_no,membership_id:membership_id
}.to_json,
:headers => {
'Content-Type' => 'application/json',

View File

@@ -0,0 +1,74 @@
class Settings::ItemSetsController < ApplicationController
before_action :set_settings_item_set, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource except: [:create]
# GET /settings/item_sets
# GET /settings/item_sets.json
def index
@settings_item_sets = ItemSet.all
end
# GET /settings/item_sets/1
# GET /settings/item_sets/1.json
def show
end
# GET /settings/item_sets/new
def new
@settings_item_set = ItemSet.new
end
# GET /settings/item_sets/1/edit
def edit
end
# POST /settings/item_sets
# POST /settings/item_sets.json
def create
@settings_item_set = ItemSet.new(settings_item_set_params)
respond_to do |format|
if @settings_item_set.save
format.html { redirect_to settings_item_sets_path, notice: 'Item set was successfully created.' }
format.json { render :show, status: :created, location: @settings_item_set }
else
format.html { render :new }
format.json { render json: @settings_item_set.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/item_sets/1
# PATCH/PUT /settings/item_sets/1.json
def update
respond_to do |format|
if @settings_item_set.update(settings_item_set_params)
format.html { redirect_to settings_item_sets_path, notice: 'Item set was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_item_set }
else
format.html { render :edit }
format.json { render json: @settings_item_set.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/item_sets/1
# DELETE /settings/item_sets/1.json
def destroy
@settings_item_set.destroy
respond_to do |format|
format.html { redirect_to settings_item_sets_url, notice: 'Item set was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_item_set
@settings_item_set = ItemSet.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_item_set_params
params.require(:item_set).permit(:name, :alt_name, :min_selectable_qty, :max_selectable_qty)
end
end

View File

@@ -89,6 +89,6 @@ class Settings::MenuCategoriesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_category_params
params.require(:menu_category).permit(:code, :menu_id, :name, :alt_name, :order_by, :menu_category_id)
params.require(:menu_category).permit(:code, :menu_id, :name, :alt_name, :order_by, :menu_category_id, :is_available)
end
end

View File

@@ -21,12 +21,14 @@ class Settings::MenuItemInstancesController < ApplicationController
id = MenuItemInstance.findParentCategory(@item)
@category = MenuCategory.find(id)
@settings_menu_item_instances = MenuItemInstance.new
@item_sets = ItemSet.all
end
# GET /settings/menu_item_instances/1/edit
def edit
id = MenuItemInstance.findParentCategory(@item)
@category = MenuCategory.find(id)
@item_sets = ItemSet.all
end
# POST /settings/menu_item_instances
@@ -45,6 +47,18 @@ class Settings::MenuItemInstancesController < ApplicationController
id = MenuItemInstance.findParentCategory(catID)
category = MenuCategory.find(id)
# Bind for Item Sets
if params[:menu_item_instance][:item_sets].count > 1
params[:menu_item_instance][:item_sets].delete_at(0)
sets = ItemSet.find(params[:menu_item_instance][:item_sets])
if sets.count > 0
@settings_menu_item.item_sets = sets
end
end
respond_to do |format|
if @settings_menu_item_instances.save
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?)
@@ -70,6 +84,18 @@ class Settings::MenuItemInstancesController < ApplicationController
id = MenuItemInstance.findParentCategory(catID)
category = MenuCategory.find(id)
# Bind for Item Sets
if params[:menu_item_instance][:item_sets].count > 1
params[:menu_item_instance][:item_sets].delete_at(0)
sets = ItemSet.find(params[:menu_item_instance][:item_sets])
if sets.count > 0
@settings_menu_item.item_sets = sets
end
end
respond_to do |format|
if @settings_menu_item_instances.update(settings_menu_item_instance_params)
@@ -122,8 +148,6 @@ class Settings::MenuItemInstancesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_instance_params
params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :item_attributes, :is_on_promotion, :promotion_price, :is_available,:menu_category_id,:menu_item_id)
params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :item_attributes, :is_on_promotion, :promotion_price, :is_available,:menu_category_id,:menu_item_id, :is_default, :item_sets)
end
end

View File

@@ -70,6 +70,6 @@ class Settings::MenuItemOptionsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_option_params
params.require(:menu_item_option).permit(:name, :value)
params.require(:menu_item_option).permit(:option_type, :name, :value)
end
end

View File

@@ -0,0 +1,74 @@
class Settings::MenuItemSetsController < ApplicationController
before_action :set_settings_menu_item_set, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource except: [:create]
# GET /settings/menu_item_sets
# GET /settings/menu_item_sets.json
def index
@settings_menu_item_sets = MenuItemSet.all
end
# GET /settings/menu_item_sets/1
# GET /settings/menu_item_sets/1.json
def show
end
# GET /settings/menu_item_sets/new
def new
@settings_menu_item_set = MenuItemSet.new
end
# GET /settings/menu_item_sets/1/edit
def edit
end
# POST /settings/menu_item_sets
# POST /settings/menu_item_sets.json
def create
@settings_menu_item_set = MenuItemSet.new(settings_menu_item_set_params)
respond_to do |format|
if @settings_menu_item_set.save
format.html { redirect_to settings_menu_item_sets_path, notice: 'Menu item set was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item_set }
else
format.html { render :new }
format.json { render json: @settings_menu_item_set.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/menu_item_sets/1
# PATCH/PUT /settings/menu_item_sets/1.json
def update
respond_to do |format|
if @settings_menu_item_set.update(settings_menu_item_set_params)
format.html { redirect_to settings_menu_item_sets_path, notice: 'Menu item set was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_menu_item_set }
else
format.html { render :edit }
format.json { render json: @settings_menu_item_set.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/menu_item_sets/1
# DELETE /settings/menu_item_sets/1.json
def destroy
@settings_menu_item_set.destroy
respond_to do |format|
format.html { redirect_to settings_menu_item_sets_url, notice: 'Menu item set was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_menu_item_set
@settings_menu_item_set = MenuItemSet.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_set_params
params.require(:menu_item_set).permit(:item_set_id, :menu_item_id)
end
end

View File

@@ -1,6 +1,8 @@
class Settings::SetMenuItemsController < ApplicationController
before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy]
before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update]
before_action :set_settings_item_attribute, only: [:index, :show, :edit, :new, :update ,:create]
before_action :set_settings_item_option, only: [:index, :show, :edit, :new, :update ,:create]
# GET /settings/menu_items
# GET /settings/menu_items.json
def index
@@ -10,32 +12,52 @@ class Settings::SetMenuItemsController < ApplicationController
# GET /settings/menu_items/1
# GET /settings/menu_items/1.json
def show
@sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
# @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
@menu_item_instance = MenuItemInstance.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
end
# GET /settings/menu_items/new
def new
@settings_menu_item = MenuItem.new
@settings_menu_item.type = "SetMenuItem"
@item_sets = ItemSet.all
end
# GET /settings/menu_items/1/edit
def edit
@item_sets = ItemSet.all
end
# POST /settings/menu_items
# POST /settings/menu_items.json
def create
@settings_menu_item = MenuItem.new(settings_menu_item_params)
if params[:simple_menu_item][:menu_item_id] == ''
# if params[:set_menu_item][:menu_item_id] == ''
@settings_menu_item.menu_category_id = params[:menu_category_id]
end
# end
@settings_menu_item.created_by = current_login_employee.name
# Remove "" default first
params[:set_menu_item][:item_attributes].delete_at(0)
params[:set_menu_item][:item_options].delete_at(0)
# Bind for Item Sets
if params[:set_menu_item][:item_sets].count > 1
params[:set_menu_item][:item_sets].delete_at(0)
sets = ItemSet.find(params[:set_menu_item][:item_sets])
if sets.count > 0
@settings_menu_item.item_sets = sets
end
end
respond_to do |format|
if @settings_menu_item.save
menu_item = MenuItem.find(@settings_menu_item.id)
menu_item.update_attributes(item_attributes: params[:set_menu_item][:item_attributes], item_options: params[:set_menu_item][:item_options])
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item }
else
@@ -48,8 +70,27 @@ class Settings::SetMenuItemsController < ApplicationController
# PATCH/PUT /settings/menu_items/1
# PATCH/PUT /settings/menu_items/1.json
def update
# Remove "" default first
params[:set_menu_item][:item_attributes].delete_at(0)
params[:set_menu_item][:item_options].delete_at(0)
# Bind for Item Sets
if params[:set_menu_item][:item_sets].count > 1
params[:set_menu_item][:item_sets].delete_at(0)
sets = ItemSet.find(params[:set_menu_item][:item_sets])
if sets.count > 0
@settings_menu_item.item_sets = sets
end
end
@settings_menu_item.menu_category_id = params[:menu_category_id]
respond_to do |format|
if @settings_menu_item.update(settings_menu_item_params)
@settings_menu_item.update_attributes(item_attributes: params[:set_menu_item][:item_attributes], item_options: params[:set_menu_item][:item_options])
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_menu_item }
else
@@ -62,6 +103,8 @@ class Settings::SetMenuItemsController < ApplicationController
# DELETE /settings/menu_items/1
# DELETE /settings/menu_items/1.json
def destroy
path_to_file = @settings_menu_item.image_path.to_s
File.delete(path_to_file) if File.exist?(path_to_file)
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.' }
@@ -79,8 +122,16 @@ class Settings::SetMenuItemsController < ApplicationController
@category = MenuCategory.find(params[:menu_category_id])
end
def set_settings_item_attribute
@item_attributes = MenuItemAttribute.all.order("id asc").map{|a| [a.name, a.value]}
end
def set_settings_item_option
@item_options = MenuItemOption.all
end
# 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,:account_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, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets)
end
end

View File

@@ -1,6 +1,8 @@
class Settings::SimpleMenuItemsController < ApplicationController
before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy ]
before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update ,:create]
before_action :set_settings_item_attribute, only: [:index, :show, :edit, :new, :update ,:create]
before_action :set_settings_item_option, only: [:index, :show, :edit, :new, :update ,:create]
# GET /settings/menu_items
# GET /settings/menu_items.json
def index
@@ -10,29 +12,75 @@ class Settings::SimpleMenuItemsController < ApplicationController
# GET /settings/menu_items/1
# GET /settings/menu_items/1.json
def show
@sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
# @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
@menu_item_instance = MenuItemInstance.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
end
# GET /settings/menu_items/new
def new
@settings_menu_item = MenuItem.new
@item_sets = ItemSet.all
end
# GET /settings/menu_items/1/edit
def edit
@item_sets = ItemSet.all
end
# POST /settings/menu_items
# POST /settings/menu_items.json
def create
@settings_menu_item = MenuItem.new(settings_menu_item_params)
if params[:simple_menu_item][:menu_item_id] == ''
# if params[:simple_menu_item][:menu_item_id] == ''
@settings_menu_item.menu_category_id = params[:menu_category_id]
end
# end
@settings_menu_item.created_by = current_login_employee.name
# Remove "" default first
params[:simple_menu_item][:item_attributes].delete_at(0)
params[:simple_menu_item][:item_options].delete_at(0)
# attr_format = []
# param_count = params[:simple_menu_item][:item_attributes].count
# # Format for attributes json
# params[:simple_menu_item][:item_attributes].each do|attr_id|
# menu_attr = MenuItemAttribute.find(attr_id)
# if attr_format.count == 0
# attr_format.push({ type: menu_attr.attribute_type, value: [] })
# end
# attr_format.each do |af|
# if menu_attr.attribute_type == af[:type]
# af[:value].push(menu_attr.value)
# else
# new_attr = {type: menu_attr.attribute_type, value: [ menu_attr.value ] }
# attr_format.push(new_attr)
# end
# break if attr_format.count > param_count
# end
# param_count -= 1
# end
# @settings_menu_item.item_attributes = attr_format
# Bind for Item Sets
if params[:simple_menu_item][:item_sets].count > 1
params[:simple_menu_item][:item_sets].delete_at(0)
sets = ItemSet.find(params[:simple_menu_item][:item_sets])
if sets.count > 0
@settings_menu_item.item_sets = sets
end
end
respond_to do |format|
if @settings_menu_item.save
menu_item = MenuItem.find(@settings_menu_item.id)
menu_item.update_attributes(item_options: params[:simple_menu_item][:item_options])
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item }
else
@@ -45,8 +93,26 @@ class Settings::SimpleMenuItemsController < ApplicationController
# PATCH/PUT /settings/menu_items/1
# PATCH/PUT /settings/menu_items/1.json
def update
# Remove "" default first
params[:simple_menu_item][:item_attributes].delete_at(0)
params[:simple_menu_item][:item_options].delete_at(0)
# Bind for Item Sets
if params[:simple_menu_item][:item_sets].count > 1
params[:simple_menu_item][:item_sets].delete_at(0)
sets = ItemSet.find(params[:simple_menu_item][:item_sets])
if sets.count > 0
@settings_menu_item.item_sets = sets
end
end
@settings_menu_item.menu_category_id = params[:menu_category_id]
respond_to do |format|
if @settings_menu_item.update(settings_menu_item_params)
@settings_menu_item.update_attributes(item_attributes: params[:simple_menu_item][:item_attributes], item_options: params[:simple_menu_item][:item_options])
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_menu_item }
else
@@ -59,6 +125,8 @@ class Settings::SimpleMenuItemsController < ApplicationController
# DELETE /settings/menu_items/1
# DELETE /settings/menu_items/1.json
def destroy
path_to_file = @settings_menu_item.image_path.to_s
File.delete(path_to_file) if File.exist?(path_to_file)
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.' }
@@ -76,8 +144,16 @@ class Settings::SimpleMenuItemsController < ApplicationController
@category = MenuCategory.find(params[:menu_category_id])
end
def set_settings_item_attribute
@item_attributes = MenuItemAttribute.all.order("id asc") #.map{|a| [a.name, a.value]}
end
def set_settings_item_option
@item_options = MenuItemOption.all
end
# 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,:account_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, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets)
end
end

View File

@@ -3,18 +3,17 @@ class Transactions::OrdersController < ApplicationController
def index
filter = params[:filter]
count = params[:count]
from = params[:from]
to = params[:to]
if filter.nil? || from.nil? || to.nil?
if filter.nil? && from.nil? && to.nil? && count.nil?
orders = Order.order("order_id desc")
puts "ssssss"
else
orders = Order.search(filter,from,to)
# if order.count > 0
# orders = order
# else
# orders = Order.order("order_id desc")
# end
orders = Order.search(filter,from,to,count)
puts "aaaaa"
end
if !orders.nil?
@@ -22,6 +21,7 @@ class Transactions::OrdersController < ApplicationController
else
@orders = []
end
puts @orders.to_json
respond_to do |format|
format.html # index.html.erb
format.json { render json: @orders }

View File

@@ -1,5 +1,4 @@
module ApplicationHelper
def flash_class(level)
case level
when :notice then "alert alert-info fade-in"

View File

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

View File

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

View File

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

View File

@@ -4,18 +4,17 @@ class Ability
def initialize(user)
user ||= Employee.new
if user.role == 'administrator'
if user.role == "administrator"
can :manage, :all
elsif user.role == 'manager'
elsif user.role == "manager"
can :manage, Menu
can :manage, MenuCategory
can :manage, MenuItemAttribute
can :manage, MenuItemInstance
can :manage, MenuItemOption
can :manage, SetMenuItem
can :manage, ItemSet
can :manage, MenuItemSet
can :manage, OrderQueueStation
can :manage, Zone
can :manage, CashierTerminal
@@ -56,6 +55,8 @@ class Ability
can :create, :payment
can :reprint, :payment
can :rounding_adj, :payment
can :foc, :payment
can :move_dining, :movetable
can :moving, :movetable
@@ -70,7 +71,7 @@ class Ability
can :overall_void, :void
elsif user.role == 'cashier'
elsif user.role == "cashier"
# can :overall_void, :void
@@ -102,14 +103,9 @@ class Ability
can :move_dining, :moveroom
can :first_bill, :payment
can :show, :payment
can :create, :payment
can :reprint, :payment
can :manage, DiningQueue
elsif user.role == 'account'
elsif user.role == "account"
can :index, :dailysale
can :index, :saleitem
@@ -118,7 +114,7 @@ class Ability
can :index, :credit_payment
can :index, :void_sale
elsif user.role == 'supervisour'
elsif user.role == "supervisour"
can :edit, :sale_edit
can :item_void, :sale_edit
@@ -134,7 +130,5 @@ class Ability
can :reprint, :payment
can :rounding_adj, :payment
end
end
end

View File

@@ -35,7 +35,6 @@ class Employee < ApplicationRecord
end
def self.authenticate_by_token(session_token)
if (session_token)
user = Employee.find_by_token_session(session_token)
if user && user.session_expiry.utc > DateTime.now.utc

9
app/models/item_set.rb Normal file
View File

@@ -0,0 +1,9 @@
class ItemSet < ApplicationRecord
has_many :menu_item_sets
has_many :menu_items, through: :menu_item_sets
has_many :menu_instance_item_sets
has_many :menu_item_instances, through: :menu_instance_item_sets
validates_presence_of :name
end

View File

@@ -1,5 +1,5 @@
class MenuCategory < ApplicationRecord
before_create :generate_menu_category_code
# before_create :generate_menu_category_code
belongs_to :menu
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
@@ -37,7 +37,7 @@ class MenuCategory < ApplicationRecord
private
def generate_menu_category_code
self.code = SeedGenerator.generate_code(self.class.name, "C")
end
# def generate_menu_category_code
# self.code = SeedGenerator.generate_code(self.class.name, "C")
# end
end

View File

@@ -0,0 +1,4 @@
class MenuInstanceItemSet < ApplicationRecord
belongs_to :item_set
belongs_to :menu_item_instance
end

View File

@@ -1,20 +1,25 @@
class MenuItem < ApplicationRecord
before_create :generate_menu_item_code
# before_create :generate_menu_item_code
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 :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 :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
has_many :menu_item_sets
has_many :item_sets, through: :menu_item_sets
validates_presence_of :name, :type, :min_qty, :taxable
default_scope { order('item_code asc') }
scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') }
scope :set_menu_item, -> { where(type: 'SetMenuItem') }
# Item Image Uploader
mount_uploader :image_path, MenuItemImageUploader
def self.collection
MenuItem.select("id, name").map { |e| [e.name, e.id] }
end
@@ -70,10 +75,10 @@ class MenuItem < ApplicationRecord
end
private
# private
def generate_menu_item_code
self.item_code = SeedGenerator.generate_code(self.class.name, "I")
end
# def generate_menu_item_code
# self.item_code = SeedGenerator.generate_code(self.class.name, "I")
# end
end

View File

@@ -1,6 +1,6 @@
class MenuItemAttribute < ApplicationRecord
validates_presence_of :attribute_type, :name, :value
def self.collection
MenuItemAttribute.select("id, name").map { |e| [e.name, e.id] }
MenuItemAttribute.select("name, value").map { |e| [e.name, e.value] }
end
end

View File

@@ -1,6 +1,9 @@
class MenuItemInstance < ApplicationRecord
belongs_to :menu_item
before_create :generate_menu_item_instance_code
has_many :menu_instance_item_sets
has_many :item_sets, through: :menu_instance_item_sets
# before_create :generate_menu_item_instance_code
def self.findParentCategory(item)
if item.menu_category_id
@@ -11,9 +14,9 @@ class MenuItemInstance < ApplicationRecord
end
end
private
# private
def generate_menu_item_instance_code
self.item_instance_code = SeedGenerator.generate_code(self.class.name, "II")
end
# def generate_menu_item_instance_code
# self.item_instance_code = SeedGenerator.generate_code(self.class.name, "II")
# end
end

View File

@@ -1,4 +1,3 @@
class MenuItemOption < ApplicationRecord
validates_presence_of :name, :value
end

View File

@@ -0,0 +1,9 @@
class MenuItemSet < ApplicationRecord
belongs_to :item_set
belongs_to :menu_item
end
# class Settings::MenuItemSet < ApplicationRecord
# belongs_to :item_set_id
# belongs_to :menu_item_id
# end

View File

@@ -65,7 +65,6 @@ class Order < ApplicationRecord
end
def adding_line_items
if self.items
#re-order to
ordered_list = re_order_items(self.items)
@@ -320,12 +319,18 @@ class Order < ApplicationRecord
end
def self.search(filter,from,to)
if !from.nil? && !to.nil?
Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ?", from,to)
def self.search(filter,from,to,count)
if count.to_i > 0
item_count = "and item_count = '#{count}'"
else
# find(:all)
where("order_id LIKE ? OR item_count ='#{filter}'","%#{filter}%",)
item_count = ''
end
if from.present? && to.present?
Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ? #{item_count}", from,to)
elsif !from.present? && !to.present? && count.present?
Order.where("item_count = '#{count}'")
else
Order.where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
end
end

View File

@@ -22,14 +22,14 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# end
#Bill Receipt Print
def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes)
def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
#Use CUPS service
#Generate PDF
#Print
cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes)
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
pdf.render_file filename
self.print(filename)

View File

@@ -91,7 +91,7 @@ class Sale < ApplicationRecord
add_item(item)
end
# link_order_sale(order.id)
link_order_sale(order.id)
end
self.save!
@@ -295,25 +295,33 @@ class Sale < ApplicationRecord
total_tax_amount = 0
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(sale.customer_id)
# #Creat new tax records
tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
#include or execulive
# sale_tax.tax_payable_amount = total_taxable * tax.rate
# substract , to give after discount
total_tax = total_taxable - total_discount
#include or execulive
if tax.inclusive
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
end
end
sale.total_tax = total_tax_amount
@@ -321,12 +329,6 @@ class Sale < ApplicationRecord
# Tax Calculate
def apply_tax(total_taxable)
#if tax is not apply create new record
# self.sale_taxes.each do |existing_tax|
# #delete existing and create new
# existing_tax.delete
# end
#if tax is not apply create new record
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
#delete existing and create new
@@ -337,26 +339,37 @@ class Sale < ApplicationRecord
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
# #Creat new tax records
customer = Customer.find(self.customer_id)
#Create new tax records
tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
#include or execulive
# sale_tax.tax_payable_amount = total_taxable * tax.rate
# substract , to give after discount
total_tax = total_taxable - self.total_discount
#include or execulive
if tax.inclusive
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
end
end
self.total_tax = total_tax_amount
end
def product_get_unit_price(item_code)
@@ -401,7 +414,6 @@ class Sale < ApplicationRecord
end
def self.search(filter,from,to)
if filter.blank?
keyword = ''
else
@@ -418,7 +430,6 @@ class Sale < ApplicationRecord
end
def self.search_credit_sales(customer,filter,from,to)
if filter.blank?
keyword = ''
else
@@ -436,7 +447,7 @@ class Sale < ApplicationRecord
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and sp.payment_method = 'creditnote' #{keyword} #{custo}", from,to)
else
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.where("sp.payment_method =? #{keyword} #{custo}",'creditnote')
.where("sp.payment_method ='creditnote' #{keyword} #{custo}")
end
@@ -537,7 +548,6 @@ class Sale < ApplicationRecord
end
def self.get_by_range_by_saleitems(from,to,status,report_type)
query = Sale.select("
mi.item_code as code,(SUM(i.qty) * i.unit_price) as grand_total,
SUM(i.qty) as total_item," +
@@ -555,13 +565,8 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
query = query.where("(receipt_date between ? and ? and sale_status=?) AND i.unit_price <> 0",from,to,status)
end
def self.get_by_shiftsales(from,to,shift)
if !shift.blank?
ShiftSale.where("id =?",shift.id)
@@ -593,9 +598,7 @@ def self.get_item_query()
query = query.group('i.product_code ').order("mi.account_id, mi.menu_category_id")
end
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
# date_type_selection = get_sql_function_for_report_type(report_type)
query = self.get_item_query()

View File

@@ -46,6 +46,8 @@ class SalePayment < ApplicationRecord
payment_status = giftcard_payment
when "paypar"
payment_status = paypar_payment
when "foc"
payment_status = foc_payment
else
puts "it was something else"
end
@@ -164,6 +166,17 @@ class SalePayment < ApplicationRecord
return payment_status
end
def foc_payment
payment_status = false
self.payment_method = "foc"
self.payment_amount = self.received_amount
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
self.payment_status = "paid"
payment_method = self.save!
sale_update_payment_status(self.received_amount)
return payment_status
end
def creditnote_payment(customer_id)
payment_status = false
@@ -257,11 +270,15 @@ class SalePayment < ApplicationRecord
all_received_amount = 0.0
sObj = Sale.find(self.sale_id)
is_credit = 0
is_foc = 0
sObj.sale_payments.each do |spay|
all_received_amount += spay.payment_amount.to_f
if spay.payment_method == "creditnote"
is_credit = 1
end
if spay.payment_method == "foc"
is_foc = 1
end
end
if (self.sale.grand_total <= all_received_amount)
if is_credit == 0
@@ -269,9 +286,16 @@ class SalePayment < ApplicationRecord
else
self.sale.payment_status = "outstanding"
end
if is_foc == 0
self.sale.payment_status = "paid"
else
self.sale.payment_status = "foc"
end
self.sale.sale_status = "completed"
if MembershipSetting.find_by_rebate(1)
if MembershipSetting.find_by_rebate(1) && is_foc == 0
response = rebat(sObj)
if !response.nil?

View File

@@ -57,6 +57,11 @@ class ShiftSale < ApplicationRecord
self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f
self.total_rounding = self.total_rounding + saleobj.rounding_adjustment
self.total_receipt = self.total_receipt + 1
if saleobj.customer.customer_type == "Dinein"
self.dining_count = self.dining_count + 1
else
self.takeaway_count = self.takeaway_count + 1
end
self.save
end
@@ -79,6 +84,11 @@ class ShiftSale < ApplicationRecord
self.commercial_taxes = self.commercial_taxes.to_i - tax.to_f
self.total_rounding = self.total_rounding - saleobj.rounding_adjustment
self.total_void = self.total_void + saleobj.grand_total
if saleobj.customer.customer_type == "Dinein"
self.dining_count = self.dining_count - 1
else
self.takeaway_count = self.takeaway_count - 1
end
self.save
end
end
@@ -88,4 +98,40 @@ class ShiftSale < ApplicationRecord
closing_balance = shiftobj.grand_total + shiftobj.cash_in - shiftobj.cash_out + shiftobj.total_cash
return closing_balance
end
def self.get_by_shift_other_payment(shift)
other_payment = Sale.select("sale_payments.payment_method as name,
SUM(case when (sale_payments.payment_method='mpu') then (sale_payments.payment_amount) else 0 end) as mpu_amount,
SUM(case when (sale_payments.payment_method='visa') then (sale_payments.payment_amount) else 0 end) as visa_amount,
SUM(case when (sale_payments.payment_method='master') then (sale_payments.payment_amount) else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='jcb') then (sale_payments.payment_amount) else 0 end) as jcb_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount,
SUM(case when (sale_payments.payment_method='paypar') then (sale_payments.payment_amount) else 0 end) as paypar_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
end
def self.calculate_total_price_by_accounts(shift,type)
query = Sale.select("acc.title as account_name," +
"SUM(case when (acc.id=i.account_id) then (i.price) else 0 end) as total_price")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id "+
"JOIN accounts acc ON acc.id = i.account_id" +
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
if type == 'discount'
query = query.where("sales.shift_sale_id =? and sale_status = 'completed' and i.is_taxable = false and i.remark = 'Discount'", shift.id)
.group("acc.title").order("acc.id")
else
query = query.where("sales.shift_sale_id =? and sale_status = 'completed'", shift.id)
.group("acc.title").order("acc.id")
end
end
def self.get_total_member_discount(shift)
query = Sale.select("SUM(sales.total_discount) as member_discount")
.where("shift_sale_id =? and sale_status = 'completed' and discount_type = 'member_discount'", shift.id)
end
end

View File

@@ -1,8 +1,9 @@
class CloseCashierPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shift_sale,shop_details,sale_taxes)
self.page_width = PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = PrintSetting.where("name = ?","Close Cashier").first.page_height
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.margin = 5
self.price_width = 40
self.qty_width = 20
@@ -26,16 +27,11 @@ class CloseCashierPdf < Prawn::Document
self.header_font_size = 10
self.item_font_size = 8
header( shop_details)
stroke_horizontal_rule
shift_detail(shift_sale,sale_taxes)
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
end
def header (shop_details)
@@ -51,7 +47,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
end
def shift_detail(shift_sale,sale_taxes)
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -151,6 +147,10 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.total_taxes}", :size => self.item_font_size, :align => :right
end
move_down -5
stroke_horizontal_rule
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash Payment :", :size => self.item_font_size, :align => :right
@@ -166,7 +166,67 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.credit_sales}", :size => self.item_font_size, :align => :right
end
#start other payment details
if shift_sale.other_sales > 0
other_payment.each do |other|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Other Payment Details", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "MPU Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.mpu_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "VISA Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.visa_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "JCB Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.master_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Master Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.jcb_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Reedem Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.paypar_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "FOC :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.foc_amount.round(2)}", :size => self.item_font_size, :align => :right
end
end
else
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Other Payment :", :size => self.item_font_size, :align => :right
@@ -174,6 +234,23 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.other_sales}", :size => self.item_font_size, :align => :right
end
end
# end other payment details
move_down -5
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
total_amount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Amount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right
end
end
#end total amount by Account
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
@@ -183,14 +260,57 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
end
move_down -5
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
total_discount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Discount Amount :", :size => self.item_font_size, :align => :right
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right
end
end
#end total amount by Account
if total_member_discount[0].member_discount.present?
@member_discount = total_member_discount[0].member_discount rescue 0.0
@overall = shift_sale.total_discounts - @member_discount
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{@member_discount}", :size => self.item_font_size, :align => :right
end
else
@overall = shift_sale.total_discounts
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Overall Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{@overall}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Discount Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.total_discounts}", :size => self.item_font_size, :align => :right
end
move_down -5
stroke_horizontal_rule
move_down 7
sale_taxes.each do |tax|
y_position = cursor
@@ -224,6 +344,22 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.total_receipt}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Dining Count :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.dining_count}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Takeaway Count :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.takeaway_count}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Void:", :size => self.item_font_size, :align => :right
@@ -236,8 +372,6 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
move_down 5
move_down 5
end
end
end

View File

@@ -55,6 +55,7 @@ class ReceiptBillPdf < Prawn::Document
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
sign(sale_data)
footer(printed_status)
end
@@ -238,11 +239,9 @@ class ReceiptBillPdf < Prawn::Document
end
def sale_payment(sale_data,precision,delimiter)
stroke_horizontal_rule
move_down 5
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
y_position = cursor
if payment.payment_method == "paypar"
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
@@ -270,14 +269,11 @@ class ReceiptBillPdf < Prawn::Document
end
move_down 5
end
end
# show member information
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter)
if rebate_amount != nil
if rebate_amount["status"] == true
stroke_horizontal_rule
total = 0
@@ -414,6 +410,43 @@ class ReceiptBillPdf < Prawn::Document
end
end
def sign(sale_data)
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
if payment.payment_method == "creditnote"
y_position = cursor
stroke_horizontal_rule
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 70
stroke_horizontal_rule
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 73
text "Approved By" , :size => self.item_font_size,:align => :center
end
end
end
if sale_data.payment_status == "foc"
y_position = cursor
stroke_horizontal_rule
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 70
stroke_horizontal_rule
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 73
text "Acknowledged By" , :size => self.item_font_size,:align => :center
end
end
end
def footer(printed_status)
move_down 5
stroke_horizontal_rule
@@ -421,7 +454,7 @@ class ReceiptBillPdf < Prawn::Document
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do
text "#{printed_status}", :size => self.item_font_size,:align => :left
text "#{printed_status}",:style => :bold, :size => self.header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left
@@ -429,6 +462,5 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
end
end

View File

@@ -0,0 +1,58 @@
class MenuItemImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
def root
Rails.root.join 'public/'
end
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"image/menu_images"
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# def cache_dir
# '/tmp/images'
# end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url(*args)
# # For Rails 3.1+ asset pipeline compatibility:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process scale: [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process resize_to_fit: [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
%w(jpg jpeg gif png)
end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end

View File

@@ -0,0 +1,7 @@
json.array! @item_sets do |set|
json.id set.id
json.name set.name
json.alt_name set.alt_name
json.min_selectable_qty set.min_selectable_qty
json.max_selectable_qty set.max_selectable_qty
end

View File

@@ -5,13 +5,14 @@ json.valid_time_from menu.valid_time_from.strftime("%H:%M")
json.valid_time_to menu.valid_time_to.strftime("%H:%M")
if (menu.menu_categories)
json.menu_categories menu.menu_categories do |category|
json.categories menu.menu_categories do |category|
json.id category.id
json.name category.name
json.alt_name category.alt_name
json.is_available category.is_available
if category.menu_items
json.menu_items category.menu_items do |item|
json.items category.menu_items do |item|
json.partial! 'api/restaurant/menu/menu_item', item: item
end
end

View File

@@ -1,40 +1,70 @@
# Format for attributes json
attr_format = []
param_count = item.item_attributes.count
# Format for attributes json
item.item_attributes.each do|attr_id|
menu_attr = MenuItemAttribute.find(attr_id)
if attr_format.count == 0
attr_format.push({ type: menu_attr.attribute_type, value: [] })
end
attr_format.each do |af|
if menu_attr.attribute_type == af[:type]
af[:value].push(menu_attr.value)
else
new_attr = {type: menu_attr.attribute_type, value: [ menu_attr.value ] }
attr_format.push(new_attr)
end
break if attr_format.count > param_count
end
param_count -= 1
end
#Menu Item Information
json.id item.id
json.item_code item.item_code
json.name item.name
json.alt_name item.alt_name
json.image item.image_path.url
json.description item.description
json.Information item.information
json.type item.type
json.account_id item.account_id
json.min_qty item.min_qty
json.min_selectable_item item.min_selectable_item
json.max_selectable_item item.max_selectable_item
json.is_available item.is_available
json.is_sub_item item.is_sub_item
json.item_sets item.item_sets
json.attributes attr_format
json.options item.item_options
# json.min_selectable_item item.min_selectable_item
# json.max_selectable_item item.max_selectable_item
#Item instance
if item.menu_item_instances.count == 1 then
# if item.menu_item_instances.count == 1 then
# item_instance = item.menu_item_instances[0]
# json.price = item_instance.price
# json.is_available = item_instance.is_available
# json.is_on_promotion = item_instance.is_on_promotion
# json.promotion_price = item_instance.promotion_price
# json.item_attributes = item_instance.item_attributes
item_instance = item.menu_item_instances[0]
json.price = item_instance.price
json.is_available = item_instance.is_available
json.is_on_promotion = item_instance.is_on_promotion
json.promotion_price = item_instance.promotion_price
json.item_attributes = item_instance.item_attributes
elsif item.menu_item_instances.count > 1 then
json.item_instances item.menu_item_instances do |is|
json.item_instance_item_code = is.item_instance_code
json.item_instance_name = is.item_instance_name
json.price = is.price
json.is_available = is.is_available
json.is_on_promotion = is.is_on_promotion
json.promotion_price = is.promotion_price
json.item_attributes = is.item_attributes
json.instances item.menu_item_instances do |is|
json.code is.item_instance_code
json.name is.item_instance_name
json.price is.price
json.is_available is.is_available
json.is_default is.is_default
json.is_on_promotion is.is_on_promotion
json.promotion_price is.promotion_price
json.item_attributes is.item_attributes
json.item_sets is.item_sets
end
end
#Child Menu items
if (item.children) then
json.set_items item.children.each do |item|
json.partial! 'api/restaurant/menu/menu_item', item: item
end
end
# if (item.children) then
# json.set_items item.children.each do |item|
# json.partial! 'api/restaurant/menu/menu_item', item: item
# end
# end

View File

@@ -4,9 +4,11 @@ json.array! @menus do |menu|
json.valid_days menu.valid_days
json.valid_time_from menu.valid_time_from.strftime("%H:%M")
json.valid_time_to menu.valid_time_to.strftime("%H:%M")
if (@current_menu)
json.current_menu do
json.partial! 'api/restaurant/menu/menu', menu: @current_menu
end
end
json.partial! 'api/restaurant/menu/menu', menu: menu
# if (@current_menu)
# json.current_menu do
# json.partial! 'api/restaurant/menu/menu', menu: @current_menu
# end
# end
end

View File

@@ -0,0 +1,48 @@
if @menu.menu_items
json.menu_items @menu.menu_items do |item|
#Menu Item Information
# json.item_code item.item_code
# json.name item.name
# json.alt_name item.alt_name
# json.type item.type
# json.min_qty item.min_qty
# json.min_selectable_item item.min_selectable_item
# json.max_selectable_item item.max_selectable_item
#Item instance
# if item.menu_item_instances.count == 1 then
# item_instance = item.menu_item_instances[0]
# json.price item_instance.price
# json.is_available item_instance.is_available
# json.is_on_promotion item_instance.is_on_promotion
# json.promotion_price item_instance.promotion_price
# json.item_attributes item_instance.item_attributes
# elsif item.menu_item_instances.count > 1 then
# json.item_instances item.menu_item_instances do |is|
# json.item_instance_item_code is.item_instance_code
# json.item_instance_name is.item_instance_name
# json.price is.price
# json.is_available is.is_available
# json.is_on_promotion is.is_on_promotion
# json.promotion_price is.promotion_price
# json.item_attributes is.item_attributes
# end
# end
#Child Menu items
# if (item.menu_item_sets) then
# json.set_items item.menu_item_sets.each do |item|
# json.partial! 'api/restaurant/menu/menu_item', item: item
# end
#end
# if category.menu_items
# json.items category.menu_items do |item|
json.partial! 'api/restaurant/menu/menu_item', item: item
# end
# end
end
end

View File

@@ -1,4 +1,5 @@
json.array! @menu_attributes do |attribute|
json.id attribute.id
json.type attribute.attribute_type
json.name attribute.name
json.value attribute.value

View File

@@ -1,4 +1,6 @@
json.array! @menu_options do |option|
json.id option.id
json.type option.option_type
json.name option.name
json.value option.value
end

View File

@@ -1,4 +1,3 @@
<%= simple_form_for([:crm,@crm_customer]) do |f| %>
<%= f.error_notification %>

View File

@@ -3,24 +3,6 @@
<span class="patch_method"></span>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['card_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
<% end %>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
</div>
<div class="form-group">
<label>Salutation :</label><br>
<label>Mr</label>
@@ -102,6 +84,38 @@
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
</div>
<div class="form-group">
<label>Select Customer Type</label>
<select class="selectpicker form-control col-md-12" id="customer_type" name="customer[customer_type]" style="height: 40px" >
<% Lookup.where("lookup_type = ?", "customer_type" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</div>
<div class="form-group">
<%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control col-md-6 tax_profiles" %>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['card_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
<% end %>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
</div>
<div class="form-group">
<label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id" style="height: 40px" >
@@ -111,7 +125,6 @@
<%= member.name %></option>
<%end %>
</select>
</div>
<div class="form-group">
@@ -138,6 +151,11 @@
},100);
}
});
// $("#customer_card_no").click(function(){
// var ab=$("#customer_tax_profiles").val();
// console.log(JSON.stringify(ab));
// });
});

View File

@@ -0,0 +1,4 @@
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth,
:membership_id, :membership_type, :membership_authentication_code,
:salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :tax_profiles
json.url crm_customer_url(@crm_customer, format: :json)

View File

@@ -76,7 +76,7 @@
</div>
</div>
<%= render 'new_form', crm_customer: @crm_customer %>
<%= render 'new_form', crm_customer: @crm_customer, taxes: @taxes %>
<div class="col-lg-1 col-md-1 col-sm-1">
<br>
@@ -121,15 +121,24 @@ $(document).on('click',".customer_tr",function(){
update_sale(customer_id,sale_id);
}else{
var url = "customers/"+customer_id;
var url = "customers/" + customer_id + "/edit";
}
$("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'});
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
// Selected for Taxes
var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(taxes);
$.each(parse_taxes, function(i, value){
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected").css({'color':'#fff','background':'#215d9c'});
});
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
@@ -138,6 +147,7 @@ $(document).on('click',".customer_tr",function(){
$('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no);
$('#customer_card_no').val(data.card_no);
$('#customer_type').val(data.customer_type);
$('#paypar_account_no').val(data.paypar_account_no);
$('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth);

View File

@@ -1,4 +1,4 @@
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth,
:membership_id, :membership_type, :membership_authentication_code,
:salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no
:salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :tax_profiles
json.url crm_customer_url(@crm_customer, format: :json)

View File

@@ -5,13 +5,10 @@
<% elsif current_login_employee.role = "cashier" %>
<%= link_to "Cashier Station", origami_path %>
<% elsif current_login_employee = "account" %>
<%= link_to "Cashier Station", oishi_path %>
<% else %>
<%= link_to "Cashier Station", oishi_path %>
<% end %>
<% shop = Shop.first %>
@@ -228,28 +225,21 @@
<div class="footer">
<div class="card">
<div class="page-header" style="width:100%;text-align:center;background-color:#ddd;">
<h4 style="color : #ef404a;font-weight:bold;font-style:italic;margin-bottom:0px;"><%= shop.name %></h4>
<div class="page-header center-text">
<h4 class="footer-header">
<%= shop.name %>
</h4>
</div>
<div class="card-block" style="text-align:center;background-color:#ddd;padding:0rem;">
<div class="center-text">
<%= shop.address %>
</div>
<div class="card-block" style="text-align:center;background-color:#ddd;padding:0rem;">
<div class="center-text">
<%= shop.phone_no %>
</div>
</div>
</div>
<style type="text/css">
.footer {
position: fixed;
bottom: 0;
left: 0;
height: auto;
width: 100%;
}
.card {
margin-top: 10px;
box-sizing: border-box;
@@ -289,3 +279,4 @@
}
</style>

View File

@@ -13,6 +13,8 @@
<li><%= link_to "Order Queue Stations",settings_order_queue_stations_path, :tabindex =>"-1" %></li>
<hr class="hr_advance" />
<li><%= link_to "Menus ", settings_menus_path, :tabindex =>"-1" %></li>
<li><%= link_to "Item Sets ", settings_item_sets_path, :tabindex =>"-1" %></li>
<li><%= link_to "Menu Item Sets ", settings_menu_item_sets_path, :tabindex =>"-1" %></li>
<li><%= link_to "Menu Categories", settings_menu_categories_path, :tabindex =>"-1" %></li>
<li><%= link_to "Menu Item Attributes", settings_menu_item_attributes_path, :tabindex =>"-1" %></li>
<li><%= link_to "Menu Item Options",settings_menu_item_options_path, :tabindex =>"-1" %></li>
@@ -29,7 +31,7 @@
<hr class="hr_advance" />
<li><%= link_to "Accounts", settings_accounts_path, :tabindex =>"-1" %></li>
<hr class="hr_advance" />
<li><%= link_to "Promotion", settings_promotions_path, :tabindex =>"-1" %></li>]
<li><%= link_to "Promotion", settings_promotions_path, :tabindex =>"-1" %></li>
<li><%= link_to "Products", settings_products_path, :tabindex =>"-1" %></li>
</ul>
</li>

View File

@@ -11,7 +11,10 @@
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'settings', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'fileinput.min', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'fileinput.min', 'data-turbolinks-track': 'reload' %>
</head>
<body>
@@ -33,7 +36,6 @@
</div>
<% end %>
<%= yield %>
</div>
</body>
</html>

View File

@@ -0,0 +1,197 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-8 col-md-8 col-sm-8">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li>
<% # For Tab Disable for Station is inactive
status=""
@queue_stations_items.each do |qsi|
if qsi[:is_active] == false
status="disabled"
end
%>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href=<%= '#' + qsi[:station_name].gsub(' ', '_') %> role="tab" <%= status %>>
<%= qsi[:station_name] %>
<span class="badge badge-pill badge-default" id=<%= qsi[:station_name].gsub(' ', '_') + '_count' %>>
<%= qsi[:item_count] %>
</span>
<% if qsi[:is_ap] %>
<span>(ap)</span>
<% end %>
</a>
</li>
<% end %>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed -->
<div class="tab-pane active" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@queue_completed_item.each do |qid|
%>
<div class="card queue_station">
<div class="card-block">
<h4 class="card-title">
<span class="order-zone-type"><%= qid.type %> - </span>
<span class="order-zone"><%= qid.zone %></span>
<small class="pull-right"><%= qid.order_id %></small>
</h4>
<h4>
<span class="order-item">
<%= qid.item_name %>
</span> [x
<span class="order-qty">
<%= qid.qty %>
</span> ]
</h4>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
</span>
</small>
</p>
<p class="hidden order-status">completed</p>
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div>
</div>
<%
end
%>
</div>
</div>
<!-- End Panel 0 - Completed -->
<!-- Order Item for Queue Station -->
<%
@queue_stations_items.each do |qsi|
%>
<!-- Generated Pane -->
<div class="tab-pane" id=<%= qsi[:station_name].gsub(' ', '_') %> role="tabpanel">
<!--- Order Items -->
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@queue_items_details.each do |qid|
if qid.price != 0
if qid.zone_id == qsi[:zone_id] && qid.station_name == qsi[:station_name]
%>
<div class="card queue_station">
<div class="card-block">
<h4 class="card-title">
<span class="order-zone-type"><%= qid.type %> - </span>
<span class="order-zone"><%= qid.zone %></span>
<small class="pull-right"><%= qid.order_id %></small>
</h4>
<h4>
<span class="order-item"><%= qid.item_name %></span> [x
<span class="order-qty"><%= qid.qty %></span> ]
</h4>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
</span>
</small>
</p>
<!-- Hidden Fields for Items -->
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div>
<div class="card-footer">
<button id=<%= 'edit_' + qid.assigned_order_item_id.to_s %> class="btn btn-warning order-item order-item-edit">EDIT</button>
<button id=<%= 'assigned_queue_' + qid.assigned_order_item_id.to_s %> class="btn btn-primary order-item order-complete">COMPLETE</button>
</div>
</div>
<%
end
end
end
%>
<!--- end of Items-->
</div>
</div>
<!-- end of Pane -->
<% end %>
<!-- End Order Item for Queue Station -->
</div>
</div>
<!-- Column Two -->
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="card" >
<div class="card-header">
<div><strong id="order-title">ORDER DETAILS - Table</strong></div>
</div>
<div class="card-block">
<div class="card-title">
<table class="table">
<thead>
<tr>
<th style="width:33%; text-align:left">Order By</th>
<th style="width:33%; text-align:right">Order At</td>
<th style="width:33%; text-align:right">Customer</td>
</tr>
</thead>
<tbody>
<tr>
<td id="order-by" style="width:33%; text-align:left"></td>
<td id="order-at" style="width:33%; text-align:right"></td>
<td id="order-customer" style="width:33%; text-align:right"></td>
</tr>
<tr>
<td><strong>Table/Room</strong></td>
<td id="order-from" colspan="2"></td>
</tr>
</tbody>
</table>
</div>
<div class="card-text" style="min-height:360px; max-height:360px; overflow:auto">
<table class="table" id="oqs-order-details-table">
<thead>
<tr>
<th style="width:80%; text-align:left">Items</th>
<th style="width:20%; text-align:right">QTY</th>
</tr>
</thead>
<tbody>
<!-- Bind With JS -->
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Column Three--->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- OQS Buttons -->
<button type="button" title="Print Order Item" id="print_order_item" class="btn btn-primary btn-lg btn-block">Print</a>
<button type="button" class="btn btn-primary btn-lg btn-block" id="print_order_summary">Print <br/>Order<br/>Summary</button>
<a href="<%= dashboard_path %>" class="btn btn-primary btn-lg btn-block" role="button" aria-haspopup="true"> Back </a>
<!-- <button type="button" class="" id="print_order_summary">Print <br/>Order<br/>Summary</button> -->
</div>
</div>

View File

@@ -1,29 +1,54 @@
<br>
<div class="row">
<!-- Column One -->
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="col-md-6">
<%= form_tag oqs_root_path, :method => :get do %>
<div class="form-group col-md-8">
<input type="text" name="filter" class="form-control input-md" placeholder="">
</div>
<div class="form-group col-md-1">
<input type="submit" value="Search" class='btn btn-primary btn-md'>
</div>
<% end %>
</div>
</div>
<hr>
<!-- Column One -->
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
<!-- <li class="nav-item nav-search <%= @filter.to_s.length > 0? " " : "hide"%>">
<a class="nav-link <%= @filter.to_s.length > 0? "active" : " "%>" data-toggle="tab" href="#search" role="tab">Searching .. <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li> -->
<li class="nav-item nav-completed">
<a class="nav-link" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li>
<%
# For Tab Disable for Station is inactive
<% # For Tab Disable for Station is inactive
status=""
@queue_stations_items.each do |qsi|
if qsi[:is_active] == false
@queue_stations.each do |qsi|
if qsi.is_active == false
status="disabled"
end
%>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href=<%= '#' + qsi[:station_name].gsub(' ', '_') %> role="tab" <%= status %>>
<%= qsi[:station_name] %>
<span class="badge badge-pill badge-default" id=<%= qsi[:station_name].gsub(' ', '_') + '_count' %>>
<%= qsi[:item_count] %>
end %>
<li class="nav-item oqs_click" >
<p class="hidden oqs-id"><%= qsi.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab" <%= status %>>
<%= qsi.station_name %>
<% if @filter.nil? %>
<span class="badge badge-pill badge-default" id=""> <%= qsi.assigned_order_items.where("delivery_status=0").count %>
</span>
<% if qsi[:is_ap] %>
<%else%>
<span class="badge badge-pill badge-default" id="">
<% @count.each do |c|%>
<% if qsi.id == c.station_id %>
<%= c.total %>
<%end %>
<%end %>
</span>
<%end%>
<% if qsi.auto_print %>
<span>(ap)</span>
<% end %>
</a>
@@ -31,9 +56,11 @@
<% end %>
</ul>
<!-- Nav tabs - End -->
<p class="hidden filter"><%= @filter %></p>
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed -->
<div class="tab-pane active" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@@ -77,68 +104,16 @@
%>
</div>
</div>
<!-- End Panel 0 - Completed -->
<!-- Order Item for Queue Station -->
<%
@queue_stations_items.each do |qsi|
%>
<!-- Generated Pane -->
<div class="tab-pane" id=<%= qsi[:station_name].gsub(' ', '_') %> role="tabpanel">
<!--- Order Items -->
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@queue_items_details.each do |qid|
if qid.price != 0
if qid.zone_id == qsi[:zone_id] && qid.station_name == qsi[:station_name]
%>
<div class="card queue_station">
<div class="card-block">
<h4 class="card-title">
<span class="order-zone-type"><%= qid.type %> - </span>
<span class="order-zone"><%= qid.zone %></span>
<small class="pull-right"><%= qid.order_id %></small>
</h4>
<h4>
<span class="order-item"><%= qid.item_name %></span> [x
<span class="order-qty"><%= qid.qty %></span> ]
</h4>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
</span>
</small>
</p>
<!-- Hidden Fields for Items -->
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
<div class="card-columns oqs_append" style="padding-top:10px; column-gap: 1.2rem;">
</div>
<div class="card-footer">
<button id=<%= 'edit_' + qid.assigned_order_item_id.to_s %> class="btn btn-warning order-item order-item-edit">EDIT</button>
<button id=<%= 'assigned_queue_' + qid.assigned_order_item_id.to_s %> class="btn btn-primary order-item order-complete">COMPLETE</button>
</div>
</div>
<%
end
end
end
%>
<!--- end of Items-->
</div>
</div>
<!-- end of Pane -->
<% end %>
<!-- End Order Item for Queue Station -->
</div>
</div>
<!-- Column Two -->
<div class="col-lg-3 col-md-3 col-sm-3">
@@ -197,4 +172,6 @@
</div>
</div>
<script type="text/javascript">
</script>

View File

@@ -0,0 +1,108 @@
<div class="row">
<div class="col-lg-11 col-md-11 col-sm-11">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#table" role="tab">Tables</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#room" role="tab">Rooms</a>
</li>
</ul>
<div class="tab-content" style="max-height:650px; overflow:auto">
<div class="tab-pane active" id="table" role="tabpanel" style="max-height:; overflow:auto">
<% @tables.each do |zone| %>
<h3>Zone : <%=zone.zone.name%></h3>
<div class="card-columns" style="padding-top:10px; column-gap: 2.2rem;">
<% @all_table.each do |table| %>
<% if zone.zone_id == table.zone_id %>
<div class="card click_table <%= table.status=="available" ? "available" : "occupied"%>" data-id = "<%= table.id %>">
<div class="card-block">
<p class="hidden table-status"><%= table.status %></p>
<p style="text-align: center"><%= table.name %></p>
<p style="text-align: center">Seat : <%= table.seater %></p>
</div>
</div>
<% end %> <% end %>
</div>
<% end %>
</div>
<div class="tab-pane" id="room" role="tabpanel" style="max-height:; overflow:auto">
<% @rooms.each do |zone| %>
<h3>Zone : <%=zone.zone.name%></h3>
<div class="card-columns" style="padding-top:10px; column-gap: 2.2rem;">
<% @all_room.each do |room| %>
<% if zone.zone_id == room.zone_id %>
<div class="card click_table <%= room.status=="available" ? "available" : "occupied"%>" data-id = "<%= room.id %>">
<div class="card-block">
<p class="hidden table-status"><%= room.status %></p>
<p style="text-align: center"><%= room.name %></p>
<p style="text-align: center">Seat : <%= room.seater %></p>
</div>
</div>
<% end %> <% end %>
</div>
<% end %>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button>
</div>
</div>
<script>
$(document).on('click',".click_table",function(){
var dining_id = $(this).attr('data-id');
var status = $(this).find(".table-status").text();
if (status == "available") {
$.confirm({
title: 'Confirmation !',
content: 'Are you sure to assign this table',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami/addorders/'+dining_id;
}
}
}
});
} else {
$.confirm({
title: 'Alert!',
content: 'You cannot assign this table',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-red',
}
}
});
}
})
</script>
<style type="text/css">
.card-columns {
-webkit-column-count:5;
-moz-column-count:5;
column-count:5;
}
.occupied{
color: #fff !important;
background-color: red;
}
.available{
color: #fff !important;
background-color: #009900;
}
</style>

View File

@@ -0,0 +1,411 @@
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<ul class="nav nav-tabs flex-column" role="tablist" >
<% @menu.each do |menu| %>
<li class="nav-item menu_category" data-ref="<%= api_restaurant_menu_category_path menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%></a>
</li>
<% end %>
</ul>
</div>
<div class="col-md-7 col-lg-7 col-sm-7">
<div class="card-columns menu_items_list" style="column-gap: 10px;">
<!-- append data -->
</div>
</div>
<div class="col-md-3 col-lg-3 col-sm-3">
<div class="card-header">
<div>
<strong id="order-title">ORDER DETAILS </strong> | Table <%=@table_id%>
</div>
</div>
<div class="card-block">
<div class="card-text" style="max-height:550px; overflow:auto"">
<table class="table table-striped summary-items">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-qty">QTY</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="sub_total">0.00</strong></td>
</tr>
</table>
<button type="button" class="btn btn-success create" id="create_order" disabled="disabled">Create Order</button>
</div>
</div>
</div>
<!-- Large modal -->
<button class="btn btn-primary" data-toggle="modal" data-target=".sx_item_detailModal">Large modal</button>
<div class="modal fade sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color: #54A5AF;">
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">&times;</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-5">
<%= image_tag "logo.png" ,width: '', height: '', :style => '' %>
<br><br>
<div class="form-group">
<h4 class="col-md-12">Quantity</h4>
<input type="number" name="qty" class="form-control col-md-12 input-number" id="modal-qty" value="" min="1" max="100">
</div>
<div class="form-group row">
<h4 class="col-md-6">Total</h4>
<h4 class="col-md-6" id="total_price"> 2500 Ks</h4>
</div>
</div>
<div class="col-md-7">
<h4>Options</h4>
<h4>Attributes</h4>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal" id="close">Close</button>
<button type="button" class="btn btn-success" data-dismiss="modal" id="save_order">Add Order</button>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<table width="100%" class="table table-striped">
<thead>
<tr>
<th style="">Item Name</th>
<th style="">Quantity</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td class="item_name" id="modal-item-name"></td>
<td>
<input type="number" name="qty" class="form-control col-md-12 input-number" id="modal-qty" value="" min="1" max="100">
</td>
<td>
<button type="button" id="remove" class="btn btn-danger" data-dismiss="modal">Remove</button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal" id="close">Close</button>
<button type="button" class="btn btn-success" data-dismiss="modal" id="save">Update</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
//click menu sidebar menu category
$(".menu_category").on("click", function(){
var menu_id = $(this).find(".menu-id").text();
var url = $(this).attr('data-ref');
show_menu_item_list(url);
});
//End menu category Click
//show menu item list when click menu category
function show_menu_item_list(url_item){
var menu_list = $('.menu_items_list');
menu_list.empty();
//Start Ajax
$.ajax({
type: "GET",
url: url_item,
data: {},
dataType: "json",
success: function(data) {
console.log(data);
var menu_items_list = $('.menu_items_list');
menu_items_list.empty();
menu_items = data.menu_items;
console.log(data);
for(var field in menu_items) {
var code = menu_items[field].instances[0].code
var name = menu_items[field].instances[0].name
var price = parseFloat(menu_items[field].instances[0].price).toFixed(2);
var is_available = menu_items[field].instances[0].is_available
var is_on_promotion = menu_items[field].instances[0].is_on_promotion
var item_attributes = menu_items[field].instances[0].item_attributes
var promotion_price = menu_items[field].instances[0].promotion_price
row = '<div class="card">'
+'<div class="card-head" style="line-height:14px;">'
+'<small class="col-md-9">'+ menu_items[field].name +'</small>'
+'<div class="col-md-3 add_icon"'
+'data-id="'+ menu_items[field].name +'"'
+'data-item-code="'+ menu_items[field].item_code +'"'
+'data-name="'+ menu_items[field].name +'"'
+'data-price="'+ price +'"'
+'data-available="'+ is_available +'"'
+'data-promotion="'+ is_on_promotion +'"'
+'data-attributes="'+ item_attributes +'"'
+'data-instance-code="'+ code +'"'
+'data-instance="'+ name +'"'
+'data-promotion-price="'+ promotion_price +'"'
+'>'
+'<i class="fa fa-plus "'
+ 'style="margin-top:4px;">'
+'</i></div>'
+'</div>'
+'<div class="menu_item_box" data-toggle="modal" data-target=".sx_item_detailModal">'
+'<div class="card-block">'
+'<%= image_tag "logo.png" ,width: '75', height: '75', :style => '' %>'
+'</div>'
+'<div class="card-footer">'
+'<small>'+ price +'</small>'
+'</div>'
+'</div>';
$('.menu_items_list').append(row);
}
}
});
//end Ajax
}
//end show detail function
// click plus icon for add
$(document).on('click', '.add_icon', function(event){
var item_data = $(this);
show_item_detail(item_data);
calculate_sub_total();
}); //End Add Icon Click
function show_item_detail(data){
qty = 1;
append = 0;
price = parseFloat(data.attr('data-price')).toFixed(2);
instance_code = data.attr('data-instance');
if (instance_code == "undefined"){
instance = '';
}else{
instance = "("+data.attr('data-instance')+")";
}
var rowCount = $('.summary-items tbody tr').length+1;
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
if ($(item_row[i]).attr('data-code') == data.attr('data-item-code')) {
qty = parseInt($(item_row[i]).children('#item_qty').text()) +1;
$(item_row[i]).children('#item_qty').text(qty);
parseFloat($(item_row[i]).children('#item_price').text(price*qty)).toFixed(2);
append = 1;
}else{
qty = 1;
}
});
if (append===0) {
row ="<tr class='item_box' data-price ='"+price+ "'data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"+instance+ "'data-code='"+data.attr('data-item-code')+"'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance + '</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(price).toFixed(2)
+'</td>'
+'</tr>';
$(".summary-items tbody").append(row);
}
}
//click item row for update qty
$('.summary-items').on('click', '.item_box', function(){
$(this).attr('data-active',true);
name = $(this).children('#item_name').text();
qty = $(this).children('#item_qty').text();
$('#modal-item-name').text(name);
$('#modal-qty').val(qty);
});
//click item row for update qty
$(document).on('click', '.menu_item_box', function(event){
data = $(this).parent().children().children('.add_icon');
$('#title_name').text(data.attr('data-name'));
console.log(data);
});
//click remove buttom in modal box
$('#sx_itemModal').on('click','#remove', function(){
$('.summary-items tr').filter(function(){
if ($(this).attr('data-active') == 'true'){
$(this).remove();
}
});
calculate_sub_total();
});
//click close
$('#sx_itemModal').on('click','#close', function(){
$(".item_box").removeAttr("data-active");
});
//click save buttom after change qty
$('#sx_itemModal').on('click','#save', function(){
summary_items_filter();
calculate_sub_total();
});
//calculate subtotal
function calculate_sub_total(){
var total_price = 0;
var taxable_amount = 0;
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
var unit_price = parseFloat($(item_row[i]).attr('data-price'));
var qty = parseFloat($(item_row[i]).children('#item_qty').text());
total_price += qty*unit_price;
});
var fixed_total_price = parseFloat(total_price).toFixed(2);
var fixed_taxable_amount = parseFloat(taxable_amount).toFixed(2);
$('#sub_total').empty();
$('#sub_total').append(fixed_total_price);
if (fixed_total_price > 0) {
$('.create').removeAttr("disabled", false);
}else{
$('.create').attr("disabled", true);
}
}
function summary_items_filter(){
$('.summary-items tr').filter(function(){
if ($(this).attr('data-active') == 'true'){
qty = $('#modal-qty').val();
price = parseFloat($(this).attr('data-price'));
total_price = parseFloat(price*qty).toFixed(2);
$(this).find('#item_qty').text(qty);
$(this).find('.item-cell-price').text(total_price);
$(this).removeAttr('data-active');
}
});
}
});
</script>
<style type="text/css">
.card-head{
height: 40px;
background-color: #54A5AF;
padding:5px;
color :#fff;
}
.card-block {
padding: 0.3rem !important;
}
@media (min-width: 34em) {
.card-columns {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
}
}
@media (min-width: 48em) {
.card-columns {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
}
}
@media (min-width: 62em) {
.card-columns {
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
}
}
@media (min-width: 75em) {
.card-columns {
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
}
}
.nav-tabs .nav-item {
border-bottom: 1px solid #fff;
border-left: 1px solid #54A5AF;
border-right: 1px solid #54A5AF;
}
.nav > li > a{
color:#54A5AF;
}
.nav-tabs {
background-color: #eeeeee;
}
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link {
background-color: #fff;
border-left: 6px solid #111;
color:#54A5AF;
font-weight: bold;
border-color: #fff #fff #fff #54A5AF;
}
.modal-dialog {
left:auto;
right: auto;
width: 100%;
padding-top: 100px;
}
</style>

View File

@@ -82,22 +82,6 @@
<input type="hidden" id="type" name="type" value="<%= @dining_facility.type %>" />
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly />
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
</div>
<div class="form-group">
<label>Salutation :</label><br>
<label>Mr</label>
@@ -176,6 +160,37 @@
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
</div>
<div class="form-group">
<label>Select Customer Type</label>
<select class="selectpicker form-control col-md-12" id="customer_type" name="customer[customer_type]" style="height: 40px" >
<% Lookup.where("lookup_type = ?", "customer_type" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</div>
<div class="form-group">
<%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control col-md-6 tax_profiles" %>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly />
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
</div>
<div class="form-group">
<label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id">
@@ -292,6 +307,12 @@
data: {},
dataType: "json",
success: function(data) {
var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(taxes);
$.each(parse_taxes, function(i, value){
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected");
});
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
@@ -301,7 +322,8 @@
$('#customer_membership_type').val(data.membership_type);
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code);
$('#customer_card_no').val(data.card_no);
$('#customer_type').val(data.customer_type);
$('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no);
$('#paypar_account_no').val(data.paypar_account_no);

View File

@@ -108,9 +108,12 @@
<button id="cash_in" type="button" class="btn btn-block btn-primary"> Cash In </button>
<button id="cash_out" type="button" class="btn btn-block btn-primary"> Cash Out </button>
<!-- Temporary Disabled -->
<!-- <button id="sale_summary" type="button" class="btn btn-block btn-primary">Sale Sammary</button> -->
<%if current_login_employee.role == "cashier" && @shop.quick_sale_summary == true%>
<button id="sale_summary" type="button" class="btn btn-block btn-primary">Sale Summary</button>
<%end%>
<button id="close_cashier" type="button" class="btn btn-block btn-primary"> Close Cashier </button>
<%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %>
<button id="back" type="button" class="btn btn-block btn-primary"><i class="fa fa-home fa-lg"></i> Back
</button>

View File

@@ -305,11 +305,10 @@
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button>
<button type="button" id="add_order" class="btn btn-primary btn-block" >Add Order</button>
<% if @dining.bookings.length >= 1 %>
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<!-- <button type="button" class="btn btn-primary btn-block" >Add Order</button> -->
<button type="button" id="customer" class="btn btn-primary btn-block" disabled>Customer</button>
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" disabled>Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" disabled>Charges</button>
@@ -319,8 +318,6 @@
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button>
<button type="button" class="btn btn-primary btn-block" disabled> Void </button>
<% else %>
<!-- <button type="button" class="btn btn-primary btn-block" disabled>Add Order</button> -->
<button type="button" id="customer" class="btn btn-primary btn-block">Customer</button>
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" >Charges</button>
@@ -580,4 +577,9 @@ function show_customer_details(customer_id){
}
});
$('#add_order').on('click',function(){
var dining_id = "<%= @dining.id %>"
window.location.href = '/origami/addorders/'+ dining_id;
});
</script>

View File

@@ -258,7 +258,7 @@
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
<button type="button" class="btn btn-primary btn-block"> FOC </button>
<button type="button" class="btn btn-primary btn-block" id="foc"> FOC </button>
<button type="button" class="btn btn-primary btn-block" id="void"> Void </button>
</div>
@@ -443,4 +443,40 @@ function update_balance(){
$('#balance').text(result.toFixed(2));
}
$('#foc').click(function() {
$( "#loading_wrapper" ).show();
// payment
var cash = $('#amount_due').text();
var sub_total = $('#sub-total').text();
var sale_id = $('#sale_id').text();
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
$.ajax({type: "POST",
url: "<%= origami_payment_foc_path %>",
data: params,
success:function(result){
$( "#loading_wrapper" ).hide();
if (cash > 0) {
$.confirm({
title: 'Infomation!',
content: 'Thank you !',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami';
}
}
}
});
}
}
});
});
</script>

View File

@@ -0,0 +1,201 @@
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-10">
<h3 style="text-align: center;">Sales Summary Quick View </h3>
<table class="table table-striped">
<tbody>
<tr>
<th>Cashier </th>
<th>Cashier Terminal </th>
<th>Opening Date </th>
<th>Opening float </th>
<th>Received Amount </th>
<th>Cast In </th>
<th>Cast Out </th>
<th>Total Receipt </th>
<th>Dining Count </th>
<th>Takeaway Count </th>
<th>Total Void</th>
</tr>
<tr style="border-bottom:2px solid #000">
<td><%= @shift.employee.name%></td>
<td><%=@shift.cashier_terminal.name%></td>
<td><%= @shift.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %>
</td>
<td><%=@shift.opening_balance %></td>
<td><%=@shift.closing_balance %></td>
<td><%=@shift.cash_in %></td>
<td><%=@shift.cash_out %></td>
<th><%= @shift.total_receipt %></th>
<th><%= @shift.dining_count %></th>
<th><%= @shift.takeaway_count %></th>
<th>(<%= @shift.total_void.round(2) %>)</th>
</tr>
<tr>
<td colspan="5">
<table width="100%">
<% @total_amount_by_account.each do |amount| %>
<tr>
<th></th>
<td style="text-align: right;"> Total <%= amount.account_name %> Amount</td>
<td><%= amount.total_price.round(2) %></td>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Net Sales</th>
<th><%=@shift.nett_sales %></th>
</tr>
<% @total_discount_by_account.each do |amount| %>
<tr>
<th></th>
<td style="text-align: right;"> Total <%= amount.account_name %> Discount</td>
<td><%= amount.total_price.round(2) %></td>
</tr>
<%end%>
<% if !@total_member_discount[0].member_discount.nil?
@member_discount = @total_member_discount[0].member_discount rescue 0.0
@overall = @shift.total_discounts - @member_discount
%>
<tr>
<th></th>
<th style="text-align: right;"> Total Member Discount</th>
<th><%= @member_discount %></th>
</tr>
<%else @overall = @shift.total_discounts %>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Total Overall Discount</th>
<th><%= @overall %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Total Discount</th>
<th><%= @shift.total_discounts %></th>
</tr>
<% @sale_taxes.each do |tax| %>
<tr>
<th></th>
<td style="text-align: right;"> <%= tax.tax_name %> </td>
<td><%= tax.st_amount.round(2) %></td>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Total Tax </th>
<th><%=@shift.total_taxes %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Rounding Adj </th>
<th><%= @shift.total_rounding.round(2) %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Grand Total </th>
<th><%= @shift.grand_total.round(2) %></th>
</tr>
</table>
</td>
<td colspan="6">
<table width="100%">
<tr>
<th></th>
<th style="text-align: right;">Cash Payment </th>
<th><%=@shift.cash_sales %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;">Credit Payment </th>
<th><%=@shift.credit_sales %></th>
</tr>
<% @total_amount = 0
@other_payment.each do |other| %>
<tr>
<th></th>
<th style="text-align: right;">Other Payment Detail </th>
<th></th>
</tr>
<tr>
<th></th>
<td style="text-align: right;">MPU Payment </td>
<td><%=other.mpu_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">VISA Payment </td>
<td><%=other.visa_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.visa_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">JCB Payment </td>
<td><%=other.master_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.master_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">Master Payment </td>
<td><%=other.jcb_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">Reedem Payment </td>
<td><%=other.paypar_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;"><strong>FOC </strong></td>
<td><%=other.foc_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.foc_amount rescue 0.0 %>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;">Total Other Payment </th>
<th><%=@shift.other_sales %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;">Total Payment </th>
<th><%= @total_amount+@shift.cash_sales+@shift.credit_sales %></th>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<br><br><br>
<button id="close_cashier" type="button" class="btn btn-block btn-primary btn-lg"> Close Cashier
</button>
<button id="back" type="button" class="btn btn-block btn-primary btn-lg"><i class="fa fa-home fa-lg"></i> Back
</button>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#close_cashier').on('click',function(){
window.location.href = '/origami/shift/close';
})
$('#back').on('click',function(){
window.location.href = '/origami';
})
})
</script>

View File

@@ -1,7 +1,7 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li>Credit Payment List Report</li>
<li>Void Sale Report</li>
</ul>
</div>

View File

@@ -0,0 +1,15 @@
<%= simple_form_for([:settings,@settings_item_set]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :name %>
<%= f.input :alt_name %>
<%= f.input :min_selectable_qty,input_html: {value: f.object.min_selectable_qty || '0'} %>
<%= f.input :max_selectable_qty,input_html: {value: f.object.max_selectable_qty || '0'} %>
</div>
<div class="form-actions">
<%= f.button :submit ,:class=>'btn btn-success'%>
<%= link_to 'Back', settings_item_sets_path,:class => 'btn btn-danger' %>
</div>
<% end %>

View File

@@ -0,0 +1,2 @@
json.extract! settings_item_set, :id, :name, :min_selectable_qty, :max_selectable_qty, :created_at, :updated_at
json.url settings_item_set_url(settings_item_set, format: :json)

View File

@@ -0,0 +1,3 @@
<h1>Editing Settings Item Set</h1>
<%= render 'form', settings_item_set: @settings_item_set %>

View File

@@ -0,0 +1,40 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li>
<li>Item Set</li>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")),new_settings_item_set_path,:class => 'btn btn-primary btn-md' %>
</span>
</ul>
</div>
<br>
<div class="card">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Alt Name</th>
<th>Min selectable qty</th>
<th>Max selectable qty</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<% @settings_item_sets.each do |item| %>
<tr>
<td><%= item.name %></td>
<td><%= item.alt_name %></td>
<td><%= item.min_selectable_qty %></td>
<td><%= item.max_selectable_qty %></td>
<td><%= link_to 'Show', settings_item_set_path(item),:class=>'btn btn-sm btn-success' %>
<%= link_to 'Edit', edit_settings_item_set_path(item),:class=>'btn btn-sm btn-primary' %>
<%= link_to 'Destroy', settings_item_set_path(item), method: :delete, data: { confirm: 'Are you sure?' } ,:class=>'btn btn-danger btn-sm'%></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -0,0 +1 @@
json.array! @settings_item_sets, partial: 'settings_item_sets/settings_item_set', as: :settings_item_set

View File

@@ -0,0 +1,4 @@
<h1>New Settings Item Set</h1>
<%= render 'form', settings_item_set: @settings_item_set %>

View File

@@ -0,0 +1,38 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= settings_item_sets_path %>">Item Set</a></li>
<span style="float: right">
</span>
</ul>
</div>
<div class="col-md-6">
<table class="table">
<tbody>
<tr>
<td><strong>Name:</strong></td>
<td><%= @settings_item_set.name %></td>
</tr>
<tr>
<td><strong>Alt Name:</strong></td>
<td><%= @settings_item_set.alt_name %></td>
</tr>
<tr>
<td><strong>Min selectable qty:</strong></td>
<td> <%= @settings_item_set.min_selectable_qty %></td>
</tr>
<tr>
<td><strong>Max selectable qty:</strong></td>
<td><%= @settings_item_set.max_selectable_qty %></td>
</tr>
</tbody>
</table>
<%= link_to 'Edit', edit_settings_item_set_path(@settings_item_set),:class=>'btn btn-primary' %>
<%= link_to 'Back', settings_item_sets_path,:class=>'btn btn-danger' %>
</div>

View File

@@ -0,0 +1 @@
json.partial! "settings_item_sets/settings_item_set", settings_item_set: @settings_item_set

View File

@@ -6,9 +6,9 @@
<%= f.input :code, label: "Category Code" %>
<%= f.input :name %>
<%= f.input :alt_name %>
<%= f.input :is_available %>
<%= f.input :order_by %>
<%= f.association :parent %>
</div>
<div class="form-actions">

View File

@@ -17,6 +17,7 @@
<th>Menu</th>
<th>Name</th>
<th>Alt name</th>
<th>Is Available</th>
<th>Order by</th>
<th>Parent</th>
<th></th>
@@ -31,6 +32,7 @@
<td><%= link_to settings_menu_category.name, settings_menu_category_path(settings_menu_category) %></td>
<td><%= settings_menu_category.alt_name rescue ''%></td>
<td><%= settings_menu_category.is_available rescue false%></td>
<td><%= settings_menu_category.order_by rescue ''%></td>
<td><%= settings_menu_category.parent.name rescue ''%></td>
<td><%= link_to 'Edit', edit_settings_menu_category_path(settings_menu_category) %> | <%= link_to 'Destroy', settings_menu_category_path(settings_menu_category), method: :delete, data: { confirm: 'Are you sure?' } %></td></td>

View File

@@ -1,6 +1,6 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li>
<li><a href="<%= settings_menus_path %>">Home</a></li>
<li><a href="<%= settings_menu_categories_path %>">Menus Categories</a></li>
<li>Details</li>
<span style="float: right">
@@ -16,6 +16,7 @@
<th>Menu</th>
<th>Name</th>
<th>Alt name</th>
<th>Is Available</th>
<th>Order by</th>
<th>Created At</th>
<th>Action</th>
@@ -27,6 +28,7 @@
<td><%= @settings_menu_category.menu.name %></td>
<td><%= @settings_menu_category.name rescue "-" %></td>
<td><%= @settings_menu_category.alt_name %></td>
<td><%= settings_menu_category.is_available rescue false%></td>
<td><%= @settings_menu_category.order_by %></td>
<td><%= @settings_menu_category.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td><%= link_to 'Edit', edit_settings_menu_menu_category_path(@settings_menu_category, @settings_menu_category) %></td>

View File

@@ -3,22 +3,33 @@
<%= f.error_notification %>
<div class="form-inputs">
<div class="col-md-8 panel">
<div class="form-group">
<%= f.input :item_instance_code %>
<%= f.input :item_instance_name %>
<%= f.input :price %>
<%= f.input :item_attributes, collection: MenuItemAttribute.collection, input_html: { multiple: true } %>
<%= f.input :is_on_promotion %>
<%= f.input :promotion_price %>
</div>
</div>
<div class="col-md-4">
<div class="panel padding-10">
<div class="form-group">
<%= f.input :is_available %>
<%= f.input :is_default %>
<%= f.input :item_sets, :collection => @item_sets, :input_html => { :multiple => true }, :class => "form-control item_sets" %>
</div>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
</div>
<% end %>

View File

@@ -11,6 +11,6 @@
<li>Edit</li>
</ul>
</div>
<%= render 'form', settings_menu_item_menu_item_instances: @settings_menu_item_instances %>
<%= render 'form', settings_menu_item_menu_item_instances: @settings_menu_item_instances, item_sets: @item_sets %>
</div>

View File

@@ -14,6 +14,6 @@
<li>New Menu Item Instance</li>
</ul>
</div>
<%= render 'form', settings_simple_menu_item_menu_item_instances: @settings_menu_item_instances %>
<%= render 'form', settings_simple_menu_item_menu_item_instances: @settings_menu_item_instances, item_sets: @item_sets %>
</div>

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