'
+ success:function(result){
+
+ row = '
'
+ +"
"
+'
'
+''+result["name"]+''
+'
'
+'
'
- +'

'
+ +'

'
+'
'
+''
+'
'
+'
'
@@ -146,16 +146,97 @@ $(function(){
}
});
});
-
}
- $('#change_qty').val(1);
- $('#item_instances').text(instances);
- $('#title_name').text(data.attr('data-name'));
- $('#item_code').text(data.attr('data-item-code'));
- $('#total_price').text(data.attr('data-price'));
- $('#unit_price').text(data.attr('data-price'));
+ $('#set_change_qty').val(1);
+ $('#set_item_instances').text(instances);
+ $('#set_name').text(data.attr('data-name'));
+ $('#set_item_code').text(data.attr('data-item-code'));
+ $('#set_total_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 = "
"+type+"
"
+ $(value).each(function(i){
+ row +="
";
+ });
+ $(".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 ="
"
+ +'| '+rowCount+' | '
+ +'' + item_name+ ' ' + name +' | '
+ +'' + qty + ' | '
+ +''
+ + parseFloat(total).toFixed(2)
+ +' | '
+ +'
';
+ $(".summary-items tbody").append(row);
+ rowCount = rowCount + 1;
+ });
+ calculate_sub_total();
+
+ }); //End add order Click
+
//click item row for add order
$(document).on('click', '.menu_item_box', function(event){
$('.attributes-list').empty();
@@ -214,8 +295,8 @@ $(function(){
type = item_options[field]["type"];
row = "
"+type+"
"
$(value).each(function(i){
- row +="
";
+ row +="
";
});
$(".options-list").append(row);
}
@@ -271,13 +352,27 @@ $(function(){
$(document).on('click', '.option_btn', function(event){
value = $(this).data('value');
type = $(this).data('type');
- options = $(".option_btn");
+ group = $(this).data('group');
+ options = $(".option_btn");
$(options).each(function(i){
if ($(options[i]).attr('data-type')==type){
$('.'+type).removeClass("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
@@ -310,7 +405,7 @@ $(function(){
show_item_detail(item_data);
calculate_sub_total();
- }); //End Add Icon Click
+ }); //End add order Click
// click plus icon for add
$(document).on('click', '.add_icon', function(event){
@@ -320,6 +415,7 @@ $(function(){
}); //End Add Icon Click
function show_item_detail(data){
+ console.log(data)
qty = parseInt(data.attr('data-qty'));
append = 0;
price = parseFloat(data.attr('data-price')).toFixed(2);
@@ -376,11 +472,11 @@ $(function(){
// Pay Discount for Payment
$("#create_order").on('click', function(e){
e.preventDefault();
- $( "#loading_wrapper" ).show();
+ $("#loading_wrapper").show();
var table_id = $('#table_id').text();
var booking_id = $('#booking_id').text();
if (!booking_id.length > 0) {
- console.log("hi")
+
var params = {'order_source': "cashier", 'order_type': "dine_in",
'customer_id': "", 'guest_info': "",'booking_id':booking_id,
'table_id': table_id,
@@ -390,7 +486,7 @@ $(function(){
var order_items = JSON.stringify(get_order_item_rows());
var ajax_url = '../addorders/create';
- console.log(ajax_url)
+
var params = {'order_source': "cashier", 'order_type': "dine_in",
'customer_id': "", 'guest_info': "",
@@ -403,10 +499,10 @@ $(function(){
data: params,
dataType: "json",
success:function(result){
- $( "#loading_wrapper" ).show();
+ $("#loading_wrapper").hide();
$.confirm({
title: 'Infomation!',
- content: "result.status",
+ content: "Order has been successfully created",
buttons: {
confirm: {
text: 'Ok',
@@ -501,6 +597,7 @@ $(function(){
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
var order_item = {};
+ console.log($(item_row[i]).attr('data-options'));
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.quantity = $(item_row[i]).children('#item_qty').text();
diff --git a/app/assets/stylesheets/addorder.scss b/app/assets/stylesheets/addorder.scss
index 29ca7156..b819b47d 100644
--- a/app/assets/stylesheets/addorder.scss
+++ b/app/assets/stylesheets/addorder.scss
@@ -87,9 +87,16 @@ element.style {
color: #fff !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 {
white-space: normal !important;
- height: 40px;
+
/*width: 80px;*/
margin-bottom: 5px;
margin-right: 5px;
@@ -97,7 +104,7 @@ element.style {
.option_btn {
white-space: normal !important;
- height: 40px;
+
/*width: 80px;*/
margin-bottom: 5px;
margin-right: 5px;
@@ -115,4 +122,34 @@ element.style {
height: 80px;
border: 1px solid #54A5AF;
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 */
+
}
\ No newline at end of file
diff --git a/app/controllers/api/restaurant/menu_item_instances_controller.rb b/app/controllers/api/restaurant/menu_item_instances_controller.rb
new file mode 100644
index 00000000..be38f782
--- /dev/null
+++ b/app/controllers/api/restaurant/menu_item_instances_controller.rb
@@ -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
diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb
index 23a7bc26..1f9d70f3 100644
--- a/app/controllers/origami/addorders_controller.rb
+++ b/app/controllers/origami/addorders_controller.rb
@@ -37,6 +37,7 @@ class Origami::AddordersController < BaseOrigamiController
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s
+ puts params[:order_items]
items_arr = []
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"]}
diff --git a/app/views/api/restaurant/menu_item_instances/show.json.jbuilder b/app/views/api/restaurant/menu_item_instances/show.json.jbuilder
new file mode 100644
index 00000000..69302b8e
--- /dev/null
+++ b/app/views/api/restaurant/menu_item_instances/show.json.jbuilder
@@ -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
diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb
index b7f0cf1d..a1bd22dc 100644
--- a/app/views/origami/addorders/detail.html.erb
+++ b/app/views/origami/addorders/detail.html.erb
@@ -147,39 +147,41 @@
-
+
+
<%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %>
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
diff --git a/app/views/settings/menu_item_instances/get_instance.json.jbuilder b/app/views/settings/menu_item_instances/get_instance.json.jbuilder
index 136c1ff1..69302b8e 100644
--- a/app/views/settings/menu_item_instances/get_instance.json.jbuilder
+++ b/app/views/settings/menu_item_instances/get_instance.json.jbuilder
@@ -1,4 +1,28 @@
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
@@ -8,6 +32,8 @@ if(@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
diff --git a/config/routes.rb b/config/routes.rb
index fb4f70e6..87b69834 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -35,6 +35,7 @@ Rails.application.routes.draw do
resources :menu_item_attributes, only: [:index]
resources :menu_item_options, only: [:index]
resources :menu_sold_out, only: [:index]
+ resources :menu_item_instances, only: [:show]
get "item_sets" => "item_sets#index"
end
@@ -291,7 +292,7 @@ Rails.application.routes.draw do
resources :promotion_products
end
- 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
#--------- Transactions Sections ------------#