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

This commit is contained in:
Yan
2017-10-12 10:16:00 +06:30
11 changed files with 188 additions and 41 deletions

View File

@@ -61,7 +61,7 @@ $(document).ready(function(){
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" data-date="'+data[field]["order_id"]+'">'
row ='<div class="card queue_station animated " data-date="'+data[field]["order_id"]+'">'
+'<div class="card-block">'
+'<h4 class="card-title">'
+'<span class="order-zone-type">'+data[field]["table_type"]+'- </span>'

View File

@@ -1,5 +1,81 @@
$(function(){
//click menu sidebar menu category
$(".product").on("click", function(){
var url = $(this).attr('data-ref');
show_product_list(url);
console.log(url)
});
//show menu item list when click menu category
function show_product_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) {
var menu_items_list = $('.menu_items_list');
menu_items_list.empty();
product = data;
for(var field in product) {
console.log(product[field].name);
if (product[field].unit_price > 0) {
console.log("hi");
qty = 1;
options = [];
item_attributes = [];
if (product[field].image_path) {
image_path = product[field].image_path.url;
}else{
image_path = "/image/logo.png";
}
row = '<div class="card custom-card testimonial-card animated fadeInRight" style="">'
+'<div class="custom-card-head card-head" style="line-height:14px;">'
+'<small class="col-md-9">'+ product[field].name +'</small>'
+"<div class='col-md-3 add_icon' data-item-code='"
+ product[field].item_code +"' data-name='"
+ product[field].name +"' data-qty = '"+ qty +"' data-price = '"
+ product[field].unit_price +"' data-instance-code = '"+ product[field].item_code +"' data-instance = '"
+ product[field].name +"' data-promotion-price = '"+ 1 +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '"
+ options +"' data-image='"+image_path+"'>"
+"<i class='fa fa-plus '"
+ 'style="margin-top:4px;">'
+'</i>'
+'</div>'
+'</div>'
+"<div class='menu_item_box' data-item-code='"
+ product[field].item_code +"' data-instance = '"
+JSON.stringify(item_attributes)+"' data-id = '"
+JSON.stringify(item_attributes)+"' data-item = '"
+JSON.stringify(item_attributes)+"' data-option = '"
+JSON.stringify(item_attributes)+"' data-item-sets = '"
+JSON.stringify(item_attributes)+"' data-toggle='modal' data-target='.sx_item_detailModal'>"
+"<div class='card-block custom-card-block'>"
+"<img id='logo' src='"+image_path+"'>"
+"</div>"
+'<div class="card-footer custom-card-footer">'
+'<small>'+ product[field].unit_price +'</small>'
+'</div>'
+'</div>';
$('.menu_items_list').append(row);
}
}
}
});
//end Ajax
}
//end show list function
//click menu sidebar menu category
$(".menu_category").on("click", function(){
var menu_id = $(this).find(".menu-id").text();
@@ -69,38 +145,38 @@ $(function(){
image_path = "/image/logo.png";
}
row = '<div class="card custom-card">'
+'<div class="custom-card-head card-head" style="line-height:14px;">'
+'<small class="col-md-9">'+ menu_items[field].name +'</small>'
+"<div class='col-md-3 add_icon' data-item-code='"
+ menu_items[field].code +"' data-name='"
+ menu_items[field].name +"' data-qty = '"+ qty +"' data-price = '"
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '"
+ options +"' data-image='"+image_path+"'>"
+"<i class='fa "+fa_plus+" '"
+ 'style="margin-top:4px;">'
+'</i></div>'
+'</div>'
row = '<div class="card custom-card testimonial-card animated fadeInRight" style="">'
+'<div class="custom-card-head card-head" style="line-height:14px;">'
+'<small class="col-md-9">'+ menu_items[field].name +'</small>'
+"<div class='col-md-3 add_icon' data-item-code='"
+ menu_items[field].code +"' data-name='"
+ menu_items[field].name +"' data-qty = '"+ qty +"' data-price = '"
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '"
+ options +"' data-image='"+image_path+"'>"
+"<i class='fa "+fa_plus+" '"
+ 'style="margin-top:4px;">'
+'</i>'
+'</div>'
+'</div>'
+"<div class='"+menu_item_box+"' data-item-code='"
+ menu_items[field].code +"' data-instance = '"
+JSON.stringify(menu_items[field].instances)+"' data-id = '"
+JSON.stringify(menu_items[field].attributes)+"' data-item = '"
+JSON.stringify(item_attributes)+"' data-option = '"
+JSON.stringify(menu_items[field].options)+"' data-item-sets = '"
+JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"'>"
+"<div class='"+menu_item_box+"' data-item-code='"
+ menu_items[field].code +"' data-instance = '"
+JSON.stringify(menu_items[field].instances)+"' data-id = '"
+JSON.stringify(menu_items[field].attributes)+"' data-item = '"
+JSON.stringify(item_attributes)+"' data-option = '"
+JSON.stringify(menu_items[field].options)+"' data-item-sets = '"
+JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"'>"
+"<div class='card-block custom-card-block'>"
+"<img id='logo' src='"+image_path+"'>"
+"<div class='card-block custom-card-block'>"
+"<img id='logo' src='"+image_path+"'>"
+"</div>"
+"</div>"
+'<div class="card-footer custom-card-footer">'
+'<small>'+ price +'</small>'
+'</div>'
+'</div>';
+'<div class="card-footer custom-card-footer">'
+'<small>'+ price +'</small>'
+'</div>'
+'</div>';
$('.menu_items_list').append(row);
}
}

View File

@@ -34,7 +34,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
if (oqs_id == items[field]["order_queue_station_id"]) {
row ='<div class="card queue_station queue_station_box" data-date="'+items[field]["order_id"]+'">'
row ='<div class="card queue_station animated shake queue_station_box" data-date="'+items[field]["order_id"]+'">'
+'<strong class="hidden">'+items[field]["order_id"]+'</strong>'
+'<div class="card-block">'
+'<h4 class="card-title">'

View File

@@ -9,6 +9,7 @@
background-color: #54A5AF;
padding:5px;
color :#fff;
}
.custom-card {

View File

@@ -43,6 +43,9 @@ class Origami::AddordersController < BaseOrigamiController
end
end
def get_all_product()
@product = Product.all
end
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
@@ -53,6 +56,7 @@ class Origami::AddordersController < BaseOrigamiController
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
items_arr.push(items)
}
# begin
@order = Order.new
@order.source = params[:order_source]

View File

@@ -38,6 +38,41 @@ class Order < ApplicationRecord
booking.save!
self.default_values
# cashier already opened?
if self.save!
self.adding_line_items
#Add Order Table and Room relation afrer order creation
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
#Send order to queue one it done!
process_order_queue
#send order to broadcast job
send_order_broadcast(booking)
return true, booking
end
return false
end
def custom_generate
booking = nil
if self.new_booking
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
:booking_status => "assign" })
table = DiningFacility.find(self.table_id)
table.status = "occupied"
table.save
else
booking = Booking.find(self.booking_id)
end
booking.save!
self.default_values
# cashier already opened?
if self.save!
@@ -58,7 +93,6 @@ class Order < ApplicationRecord
return false
end
#Main Method - to update order / add items
def modify
@@ -71,7 +105,12 @@ class Order < ApplicationRecord
#loop to add all items to order
self.items.each do |item|
menu_item = MenuItem.search_by_item_code(item[:item_instance_code])
if menu_item.nil?
menu_item = Product.search_by_product_code(item[:item_instance_code])
end
#if (!menu_item.nil?)
Rails.logger.debug menu_item

View File

@@ -3,4 +3,24 @@ class Product < ApplicationRecord
# Product Image Uploader
mount_uploader :image_path, ProductImageUploader
def self.search_by_product_code(item_code)
menu_item_hash = Hash.new
mt_instance = Product.find_by_item_code(item_code)
if (!mt_instance.nil?)
menu_item_hash[:type] = 'Product'
menu_item_hash[:account_id] = 1
menu_item_hash[:item_code] = mt_instance.item_code
menu_item_hash[:item_instance_code] = mt_instance.item_code
menu_item_hash[:name] = mt_instance.name.to_s
menu_item_hash[:alt_name] = mt_instance.alt_name.to_s
menu_item_hash[:price] = mt_instance.unit_price
menu_item_hash[:promotion_price] = 0
menu_item_hash[:is_on_promotion] = 0
menu_item_hash[:is_available] = 0
menu_item_hash[:taxable] = mt_instance.taxable
return menu_item_hash
end
end
end

View File

@@ -209,7 +209,7 @@ class CloseCashierPdf < Prawn::Document
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
text "#{other.jcb_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
@@ -217,7 +217,7 @@ class CloseCashierPdf < Prawn::Document
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
text "#{other.master_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor

View File

@@ -3,13 +3,15 @@
<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="<%= origami_get_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 %>
<% @menu.each do |menu| %>
<li class="nav-item menu_category" data-ref="<%= origami_get_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 %>
<li class="nav-item product" data-ref="<%= origami_get_all_product_path %>">
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
</li>
</ul>
</div>
<div class="col-md-7 col-lg-7 col-sm-7">

View File

@@ -0,0 +1,4 @@
json.array! @product, :id, :item_code, :name, :alt_name,:image_path,
:description,:information,:taxable,:unit_price, :created_at,
:updated_at, :created_by

View File

@@ -181,6 +181,7 @@ scope "(:locale)", locale: /en|mm/ do
get '/:addorders/:id' => "addorders#detail"
post '/:addorders/create' => "addorders#create", :defaults => { :format => 'json' }
get '/addorders/get_menu_category/:id' => "addorders#get_menu_category",:as => "get_menu_category", :defaults => { :format => 'json' }
get '/addorders/products/list' => "addorders#get_all_product",:as => "get_all_product", :defaults => { :format => 'json' }
resources :commissions
resources :commissioners