Merge branch 'addorder' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -14,6 +14,12 @@ $(function(){
|
|||||||
$("#total_price").text(qty*price);
|
$("#total_price").text(qty*price);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#set_change_qty").change(function(){
|
||||||
|
qty = $(this).val();
|
||||||
|
price = $("#set_total_price").text();
|
||||||
|
$("#set_total_price").text(qty*price);
|
||||||
|
});
|
||||||
|
|
||||||
//show menu item list when click menu category
|
//show menu item list when click menu category
|
||||||
function show_menu_item_list(url_item){
|
function show_menu_item_list(url_item){
|
||||||
var menu_list = $('.menu_items_list');
|
var menu_list = $('.menu_items_list');
|
||||||
@@ -98,22 +104,12 @@ $(function(){
|
|||||||
//end Ajax
|
//end Ajax
|
||||||
}
|
}
|
||||||
//end show list function
|
//end show list function
|
||||||
//click item row for add order
|
//click item row for item set
|
||||||
$(document).on('click', '.set_item_box', function(event){
|
$(document).on('click', '.set_item_box', function(event){
|
||||||
$(".instance-list").empty();
|
$(".instance-list").empty();
|
||||||
data = $(this).parent().children().children('.add_icon');
|
$(".options-list").empty();
|
||||||
|
|
||||||
item_options = $(this).data('option');
|
data = $(this).parent().children().children('.add_icon');
|
||||||
for(var field in item_options) {
|
|
||||||
value = item_options[field]["values"];
|
|
||||||
type = item_options[field]["type"];
|
|
||||||
row = "<p style='font-size:15px'>"+type+"</p>"
|
|
||||||
$(value).each(function(i){
|
|
||||||
row +="<button class='btn btn-default option_btn "+ type +"' data-type='"+type+"' data-value='"
|
|
||||||
+value[i]+"'>"+value[i]+"</button>";
|
|
||||||
});
|
|
||||||
$(".opt-list").append(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
instances = $(this).data('instance');
|
instances = $(this).data('instance');
|
||||||
item_sets = $(this).data('item-sets');
|
item_sets = $(this).data('item-sets');
|
||||||
@@ -123,21 +119,25 @@ $(function(){
|
|||||||
$(value).each(function(i){
|
$(value).each(function(i){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: '../../settings/menu_item_instances/get_instance/'+value[i]["id"],
|
url: '../../api/restaurant/menu_item_instances/'+value[i]["id"],
|
||||||
data: {id:value[i]},
|
data: {id:value[i]},
|
||||||
success:function(result){
|
success:function(result){
|
||||||
// var image_path = ""
|
|
||||||
console.log(result)
|
row = '<div class="col-md-4 " >'
|
||||||
row = '<div class="col-md-4 instance_box" >'
|
+"<div class='card instance_box' data-name='"+result["name"]
|
||||||
+'<div class="card">'
|
+"' data-code='"+result["code"]
|
||||||
|
+"' data-price='"+result["price"]
|
||||||
|
+"' data-option='"+JSON.stringify(result["options"])
|
||||||
|
+"'>"
|
||||||
+'<div class="card-head" style="line-height:14px;">'
|
+'<div class="card-head" style="line-height:14px;">'
|
||||||
+'<small class="">'+result["name"]+'</small>'
|
+'<small class="">'+result["name"]+'</small>'
|
||||||
+'</div>'
|
+'</div>'
|
||||||
+'<div class="card-block">'
|
+'<div class="card-block">'
|
||||||
+'<img id="" src="/image/logo.png">'
|
+'<img id="" src="/image/logo.png" height="40px">'
|
||||||
+'</div>'
|
+'</div>'
|
||||||
+'<div class="card-footer">'
|
+'<div class="card-footer">'
|
||||||
+' <small>'+result["price"]+'</small>'
|
+' <small>'+result["price"]+'</small>'
|
||||||
|
+' <small style="float:right" id="instance_option"></small>'
|
||||||
+'</div>'
|
+'</div>'
|
||||||
+'</div>'
|
+'</div>'
|
||||||
+' </div>'
|
+' </div>'
|
||||||
@@ -146,16 +146,97 @@ $(function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#change_qty').val(1);
|
$('#set_change_qty').val(1);
|
||||||
$('#item_instances').text(instances);
|
$('#set_item_instances').text(instances);
|
||||||
$('#title_name').text(data.attr('data-name'));
|
$('#set_name').text(data.attr('data-name'));
|
||||||
$('#item_code').text(data.attr('data-item-code'));
|
$('#set_item_code').text(data.attr('data-item-code'));
|
||||||
$('#total_price').text(data.attr('data-price'));
|
$('#set_total_price').text(data.attr('data-price'));
|
||||||
$('#unit_price').text(data.attr('data-price'));
|
$('#set_unit_price').text(data.attr('data-price'));
|
||||||
});
|
});
|
||||||
|
// click instance for add item set
|
||||||
|
$(document).on('click', '.instance_box', function(event){
|
||||||
|
|
||||||
|
$(".options-list").empty();
|
||||||
|
|
||||||
|
item_options = $(this).data('option');
|
||||||
|
code = $(this).data('code');
|
||||||
|
|
||||||
|
for(var field in item_options) {
|
||||||
|
value = item_options[field]["values"];
|
||||||
|
type = item_options[field]["type"];
|
||||||
|
row = "<p style='font-size:16px;margin-bottom:3px'>"+type+"</p>"
|
||||||
|
$(value).each(function(i){
|
||||||
|
row +="<button class='btn btn-default btn-sm option_btn "+ type +"' data-type='"
|
||||||
|
+type+"' data-value='"+value[i]+"' data-code='"+code+"' data-group='set_menu'>"
|
||||||
|
+value[i]+"</button>";
|
||||||
|
});
|
||||||
|
$(".options-list").append(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($(this).hasClass('selected-instance') == true){
|
||||||
|
sub_total = $('#set_total_price').text();
|
||||||
|
name = $(this).data('name');
|
||||||
|
price = $(this).data('price');
|
||||||
|
qty = $('#set_change_qty').val();
|
||||||
|
total = qty*price;
|
||||||
|
var total_price = +sub_total - +total;
|
||||||
|
$(this).removeClass('selected-instance');
|
||||||
|
$(".options-list").empty();
|
||||||
|
$(this).removeAttr('data-options');
|
||||||
|
$('#instance_option').text('')
|
||||||
|
}else {
|
||||||
|
sub_total = $('#set_total_price').text();
|
||||||
|
name = $(this).data('name');
|
||||||
|
price = $(this).data('price');
|
||||||
|
qty = $('#set_change_qty').val();
|
||||||
|
total = qty*price;
|
||||||
|
var total_price = +sub_total + +total;
|
||||||
|
$(this).addClass('selected-instance');
|
||||||
|
}
|
||||||
|
$('#set_total_price').text(total_price);
|
||||||
|
}); //End selecct attribute buttom
|
||||||
|
|
||||||
|
// click add order
|
||||||
|
$(document).on('click', '.set_order', function(event){
|
||||||
|
total_price = $('#set_total_price').text();
|
||||||
|
qty = parseInt($('#set_change_qty').val());
|
||||||
|
item_code = $('#set_item_code').text();
|
||||||
|
item_name = $('#set_name').text();
|
||||||
|
|
||||||
|
var items = $('.selected-instance');
|
||||||
|
|
||||||
|
attribute_arr = []
|
||||||
|
option_arr = []
|
||||||
|
var rowCount = $('.summary-items tbody tr').length+1;
|
||||||
|
$(items).each(function(i){
|
||||||
|
code = $(items[i]).attr('data-code');
|
||||||
|
name = $(items[i]).attr('data-name');
|
||||||
|
price = $(items[i]).attr('data-price');
|
||||||
|
option = $(items[i]).attr('data-options');
|
||||||
|
total = qty * price ;
|
||||||
|
option_arr.push(option);
|
||||||
|
row ="<tr class='item_box' data-price ='"
|
||||||
|
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
|
||||||
|
+name+ "' data-code='"+item_code+"' data-instance-code='"
|
||||||
|
+code+"' data-attributes='"
|
||||||
|
+attribute_arr+"' data-options ='"
|
||||||
|
+option_arr+"' data-row ='"+rowCount+ "'>"
|
||||||
|
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||||
|
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'</td>'
|
||||||
|
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||||
|
+'<td class="item-cell-price" id="item_price">'
|
||||||
|
+ parseFloat(total).toFixed(2)
|
||||||
|
+'</td>'
|
||||||
|
+'</tr>';
|
||||||
|
$(".summary-items tbody").append(row);
|
||||||
|
rowCount = rowCount + 1;
|
||||||
|
});
|
||||||
|
calculate_sub_total();
|
||||||
|
|
||||||
|
}); //End add order Click
|
||||||
|
|
||||||
//click item row for add order
|
//click item row for add order
|
||||||
$(document).on('click', '.menu_item_box', function(event){
|
$(document).on('click', '.menu_item_box', function(event){
|
||||||
$('.attributes-list').empty();
|
$('.attributes-list').empty();
|
||||||
@@ -214,8 +295,8 @@ $(function(){
|
|||||||
type = item_options[field]["type"];
|
type = item_options[field]["type"];
|
||||||
row = "<h4>"+type+"</h4>"
|
row = "<h4>"+type+"</h4>"
|
||||||
$(value).each(function(i){
|
$(value).each(function(i){
|
||||||
row +="<button class='btn btn-default option_btn "+ type +"' data-type='"+type+"' data-value='"
|
row +="<button class='btn btn-default option_btn "+ type +"' data-type='"
|
||||||
+value[i]+"'>"+value[i]+"</button>";
|
+type+"' data-value='"+value[i]+"' data-group='simple_menu'>"+value[i]+"</button>";
|
||||||
});
|
});
|
||||||
$(".options-list").append(row);
|
$(".options-list").append(row);
|
||||||
}
|
}
|
||||||
@@ -271,7 +352,8 @@ $(function(){
|
|||||||
$(document).on('click', '.option_btn', function(event){
|
$(document).on('click', '.option_btn', function(event){
|
||||||
value = $(this).data('value');
|
value = $(this).data('value');
|
||||||
type = $(this).data('type');
|
type = $(this).data('type');
|
||||||
options = $(".option_btn");
|
group = $(this).data('group');
|
||||||
|
options = $(".option_btn");
|
||||||
$(options).each(function(i){
|
$(options).each(function(i){
|
||||||
if ($(options[i]).attr('data-type')==type){
|
if ($(options[i]).attr('data-type')==type){
|
||||||
$('.'+type).removeClass("selected-option");
|
$('.'+type).removeClass("selected-option");
|
||||||
@@ -279,6 +361,19 @@ $(function(){
|
|||||||
});
|
});
|
||||||
$(this).addClass('selected-option');
|
$(this).addClass('selected-option');
|
||||||
|
|
||||||
|
if(group == "set_menu"){
|
||||||
|
code = $(this).data('code');
|
||||||
|
value = $(this).data('value');
|
||||||
|
|
||||||
|
instance = $(".selected-instance");
|
||||||
|
$(instance).each(function(i){
|
||||||
|
if ($(instance[i]).attr('data-code')==code){
|
||||||
|
$(instance[i]).attr('data-options',value);
|
||||||
|
$(instance[i]).children().children('#instance_option').text(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}); //End selecct attribute buttom
|
}); //End selecct attribute buttom
|
||||||
|
|
||||||
// click add order
|
// click add order
|
||||||
@@ -310,7 +405,7 @@ $(function(){
|
|||||||
show_item_detail(item_data);
|
show_item_detail(item_data);
|
||||||
calculate_sub_total();
|
calculate_sub_total();
|
||||||
|
|
||||||
}); //End Add Icon Click
|
}); //End add order Click
|
||||||
|
|
||||||
// click plus icon for add
|
// click plus icon for add
|
||||||
$(document).on('click', '.add_icon', function(event){
|
$(document).on('click', '.add_icon', function(event){
|
||||||
@@ -320,6 +415,7 @@ $(function(){
|
|||||||
}); //End Add Icon Click
|
}); //End Add Icon Click
|
||||||
|
|
||||||
function show_item_detail(data){
|
function show_item_detail(data){
|
||||||
|
console.log(data)
|
||||||
qty = parseInt(data.attr('data-qty'));
|
qty = parseInt(data.attr('data-qty'));
|
||||||
append = 0;
|
append = 0;
|
||||||
price = parseFloat(data.attr('data-price')).toFixed(2);
|
price = parseFloat(data.attr('data-price')).toFixed(2);
|
||||||
@@ -376,11 +472,11 @@ $(function(){
|
|||||||
// Pay Discount for Payment
|
// Pay Discount for Payment
|
||||||
$("#create_order").on('click', function(e){
|
$("#create_order").on('click', function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$( "#loading_wrapper" ).show();
|
$("#loading_wrapper").show();
|
||||||
var table_id = $('#table_id').text();
|
var table_id = $('#table_id').text();
|
||||||
var booking_id = $('#booking_id').text();
|
var booking_id = $('#booking_id').text();
|
||||||
if (!booking_id.length > 0) {
|
if (!booking_id.length > 0) {
|
||||||
console.log("hi")
|
|
||||||
var params = {'order_source': "cashier", 'order_type': "dine_in",
|
var params = {'order_source': "cashier", 'order_type': "dine_in",
|
||||||
'customer_id': "", 'guest_info': "",'booking_id':booking_id,
|
'customer_id': "", 'guest_info': "",'booking_id':booking_id,
|
||||||
'table_id': table_id,
|
'table_id': table_id,
|
||||||
@@ -390,7 +486,7 @@ $(function(){
|
|||||||
var order_items = JSON.stringify(get_order_item_rows());
|
var order_items = JSON.stringify(get_order_item_rows());
|
||||||
|
|
||||||
var ajax_url = '../addorders/create';
|
var ajax_url = '../addorders/create';
|
||||||
console.log(ajax_url)
|
|
||||||
|
|
||||||
var params = {'order_source': "cashier", 'order_type': "dine_in",
|
var params = {'order_source': "cashier", 'order_type': "dine_in",
|
||||||
'customer_id': "", 'guest_info': "",
|
'customer_id': "", 'guest_info': "",
|
||||||
@@ -403,10 +499,10 @@ $(function(){
|
|||||||
data: params,
|
data: params,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success:function(result){
|
success:function(result){
|
||||||
$( "#loading_wrapper" ).show();
|
$("#loading_wrapper").hide();
|
||||||
$.confirm({
|
$.confirm({
|
||||||
title: 'Infomation!',
|
title: 'Infomation!',
|
||||||
content: "result.status",
|
content: "Order has been successfully created",
|
||||||
buttons: {
|
buttons: {
|
||||||
confirm: {
|
confirm: {
|
||||||
text: 'Ok',
|
text: 'Ok',
|
||||||
@@ -501,6 +597,7 @@ $(function(){
|
|||||||
var item_row = $('.summary-items tbody tr');
|
var item_row = $('.summary-items tbody tr');
|
||||||
$(item_row).each(function(i){
|
$(item_row).each(function(i){
|
||||||
var order_item = {};
|
var order_item = {};
|
||||||
|
console.log($(item_row[i]).attr('data-options'));
|
||||||
order_item.order_item_id = $(item_row[i]).attr('data-row');
|
order_item.order_item_id = $(item_row[i]).attr('data-row');
|
||||||
order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
|
order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
|
||||||
order_item.quantity = $(item_row[i]).children('#item_qty').text();
|
order_item.quantity = $(item_row[i]).children('#item_qty').text();
|
||||||
|
|||||||
@@ -87,9 +87,16 @@ element.style {
|
|||||||
color: #fff !important;
|
color: #fff !important;
|
||||||
background-color: green !important;
|
background-color: green !important;
|
||||||
}
|
}
|
||||||
|
.card {
|
||||||
|
border: 2px solid rgba(0, 0, 0, 0.125) !important;
|
||||||
|
}
|
||||||
|
.selected-instance {
|
||||||
|
border: 2px solid #7a62d3 !important;
|
||||||
|
}
|
||||||
|
|
||||||
.attribute_btn {
|
.attribute_btn {
|
||||||
white-space: normal !important;
|
white-space: normal !important;
|
||||||
height: 40px;
|
|
||||||
/*width: 80px;*/
|
/*width: 80px;*/
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
@@ -97,7 +104,7 @@ element.style {
|
|||||||
|
|
||||||
.option_btn {
|
.option_btn {
|
||||||
white-space: normal !important;
|
white-space: normal !important;
|
||||||
height: 40px;
|
|
||||||
/*width: 80px;*/
|
/*width: 80px;*/
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
@@ -116,3 +123,33 @@ element.style {
|
|||||||
border: 1px solid #54A5AF;
|
border: 1px solid #54A5AF;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.card-footer{
|
||||||
|
padding:0.35rem 1.25rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Loading gif for payment*/
|
||||||
|
|
||||||
|
#loading_wrapper{
|
||||||
|
|
||||||
|
position: fixed;
|
||||||
|
background-color: #C8C8C8 ;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
left: 0;
|
||||||
|
opacity: 0.6;
|
||||||
|
top: 0;
|
||||||
|
z-index: 9999999;
|
||||||
|
}
|
||||||
|
#loading{
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
background-image: url('../../../image/loading-ajax.gif');
|
||||||
|
background-position: center center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
opacity: 1;
|
||||||
|
filter: alpha(opacity=100); /* ie */
|
||||||
|
-moz-opacity: 1; /* mozilla */
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class Api::Restaurant::MenuItemInstancesController < Api::ApiController
|
||||||
|
skip_before_action :authenticate
|
||||||
|
#Description
|
||||||
|
# Pull the default menu details and also other available (active) menus
|
||||||
|
# Input Params - order_id
|
||||||
|
def show
|
||||||
|
@id = MenuItemInstance.find(params[:id])
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -37,6 +37,7 @@ class Origami::AddordersController < BaseOrigamiController
|
|||||||
def create
|
def create
|
||||||
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
Rails.logger.debug "Order Source - " + params[:order_source].to_s
|
||||||
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
Rails.logger.debug "Table ID - " + params[:table_id].to_s
|
||||||
|
puts params[:order_items]
|
||||||
items_arr = []
|
items_arr = []
|
||||||
JSON.parse(params[:order_items]).each { |i|
|
JSON.parse(params[:order_items]).each { |i|
|
||||||
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
|
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
if(@id)
|
||||||
|
menu_item = MenuItem.find(@id.menu_item_id)
|
||||||
|
# Format for option json
|
||||||
|
opt_format = []
|
||||||
|
# Format for attributes json
|
||||||
|
menu_item.item_options.each do|opt|
|
||||||
|
menu_opt = MenuItemOption.find(opt)
|
||||||
|
if opt_format.count == 0
|
||||||
|
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
opt_format.each do |of|
|
||||||
|
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
||||||
|
if menu_opt.option_type == of[:type]
|
||||||
|
of[:values].push(menu_opt.name)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
||||||
|
opt_format.push(new_opt)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
json.success true
|
||||||
|
json.id @id.id
|
||||||
|
json.name @id.item_instance_name
|
||||||
|
json.code @id.item_instance_code
|
||||||
|
|
||||||
|
json.item_id @id.menu_item_id
|
||||||
|
json.attributes @id.item_attributes
|
||||||
|
json.price @id.price
|
||||||
|
json.is_default @id.is_default
|
||||||
|
|
||||||
|
json.options opt_format
|
||||||
|
else
|
||||||
|
json.success false
|
||||||
|
end
|
||||||
@@ -147,39 +147,41 @@
|
|||||||
<div class="modal-dialog modal-lg">
|
<div class="modal-dialog modal-lg">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" style="background-color: #54A5AF;">
|
<div class="modal-header" style="background-color: #54A5AF;">
|
||||||
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
|
<h4 class="modal-title" style="color:#fff;" id="set_name"></h4>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">×</button>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">×</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="row set-item">
|
<div class="row set-item">
|
||||||
<div class="col-md-5">
|
<div class="col-md-4">
|
||||||
|
<p style="text-align: center;"> <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %></p>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-md-6" style="margin-top:5px">Quantity</label>
|
<label class="col-md-6" style="margin-top:5px">Quantity</label>
|
||||||
<input type="number" name="qty" class="form-control col-md-5 input-number change_qty" id="change_qty" value="" min="1" max="100">
|
<input type="number" name="qty" class="form-control col-md-5 input-number change_qty" id="set_change_qty" value="" min="1" max="100">
|
||||||
</div>
|
</div>
|
||||||
<p class="hidden" id="unit_price"></p>
|
<p class="hidden" id="set_unit_price"></p>
|
||||||
<p class="hidden" id="instance_code"></p>
|
<p class="hidden" id="set_instance_code"></p>
|
||||||
<p class="hidden" id="instance_name"></p>
|
<p class="hidden" id="set_instance_name"></p>
|
||||||
<p class="hidden" id="promotion_price"></p>
|
<p class="hidden" id="set_promotion_price"></p>
|
||||||
<p class="hidden" id="item_instances"></p>
|
<p class="hidden" id="set_item_instances"></p>
|
||||||
<p class="hidden" id="item_code"></p>
|
<p class="hidden" id="set_item_code"></p>
|
||||||
<p></p>
|
<p></p>
|
||||||
<div class="opt-list">
|
<br><br><br><br>
|
||||||
<h4>Options</h4>
|
<div class="options-list">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-7">
|
<div class="col-md-8">
|
||||||
<div class="instance-list"></div>
|
<div class="instance-list"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<div class="mr-auto">
|
<div class="mr-auto">
|
||||||
<h4 class=" pull-left">Total : <span id="total_price"></span></h4>
|
<h4 class=" pull-left">Total : <span id="set_total_price"></span></h4>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-primary" data-dismiss="modal" id="close">Close</button>
|
<button type="button" class="btn btn-primary" data-dismiss="modal" id="close">Close</button>
|
||||||
<button type="button" class="btn btn-success add_to_order" data-dismiss="modal" id="add_to_order">Add to Order</button>
|
<button type="button" class="btn btn-success set_order" data-dismiss="modal" id="set_order">Add to Order</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,28 @@
|
|||||||
if(@id)
|
if(@id)
|
||||||
|
menu_item = MenuItem.find(@id.menu_item_id)
|
||||||
|
# Format for option json
|
||||||
|
opt_format = []
|
||||||
|
# Format for attributes json
|
||||||
|
menu_item.item_options.each do|opt|
|
||||||
|
menu_opt = MenuItemOption.find(opt)
|
||||||
|
if opt_format.count == 0
|
||||||
|
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
opt_format.each do |of|
|
||||||
|
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
||||||
|
if menu_opt.option_type == of[:type]
|
||||||
|
of[:values].push(menu_opt.name)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
||||||
|
opt_format.push(new_opt)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
json.success true
|
json.success true
|
||||||
json.id @id.id
|
json.id @id.id
|
||||||
json.name @id.item_instance_name
|
json.name @id.item_instance_name
|
||||||
@@ -8,6 +32,8 @@ if(@id)
|
|||||||
json.attributes @id.item_attributes
|
json.attributes @id.item_attributes
|
||||||
json.price @id.price
|
json.price @id.price
|
||||||
json.is_default @id.is_default
|
json.is_default @id.is_default
|
||||||
|
|
||||||
|
json.options opt_format
|
||||||
else
|
else
|
||||||
json.success false
|
json.success false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ Rails.application.routes.draw do
|
|||||||
resources :menu_item_attributes, only: [:index]
|
resources :menu_item_attributes, only: [:index]
|
||||||
resources :menu_item_options, only: [:index]
|
resources :menu_item_options, only: [:index]
|
||||||
resources :menu_sold_out, only: [:index]
|
resources :menu_sold_out, only: [:index]
|
||||||
|
resources :menu_item_instances, only: [:show]
|
||||||
get "item_sets" => "item_sets#index"
|
get "item_sets" => "item_sets#index"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -305,7 +306,7 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
get '/get_transactions_by_commissioner' => 'commissioners#get_transaction_by_commissioner', as:'get_transaction_by_commissioner'
|
get '/get_transactions_by_commissioner' => 'commissioners#get_transaction_by_commissioner', as:'get_transaction_by_commissioner'
|
||||||
|
|
||||||
get 'menu_item_instances/get_instance/:id' => 'menu_item_instances#get_instance',:as => "show_instance"
|
# get 'menu_item_instances/get_instance/:id' => 'menu_item_instances#get_instance',:as => "show_instance"
|
||||||
end
|
end
|
||||||
|
|
||||||
# commissions
|
# commissions
|
||||||
|
|||||||
Reference in New Issue
Block a user