update add order

This commit is contained in:
Aung Myo
2018-02-16 14:30:53 +06:30
parent 1d62e3c082
commit 941204afc1
3 changed files with 89 additions and 112 deletions

View File

@@ -123,8 +123,10 @@ $(function() {
if (JSON.stringify(menu_items[field].item_sets)!='[]') { if (JSON.stringify(menu_items[field].item_sets)!='[]') {
fa_plus = ''; fa_plus = '';
add = ''; add = '';
menu_item_box = 'set_item_box'; menu_item_box = 'add_icon';
data_target = 'sx_item_set_detailModal'; data_target = 'sx_item_set_detailModal';
data_modal = 'modal'
add_icon = "set_item_box"
code = menu_items[field].code; code = menu_items[field].code;
name = menu_items[field].name; name = menu_items[field].name;
instances = menu_items[field].instances; instances = menu_items[field].instances;
@@ -144,6 +146,8 @@ $(function() {
add = 'add' add = 'add'
menu_item_box = 'menu_item_box'; menu_item_box = 'menu_item_box';
data_target = 'sx_item_detailModal'; data_target = 'sx_item_detailModal';
data_modal = ''
add_icon = "add_icon"
$(instances).each(function(i){ $(instances).each(function(i){
if (instances[i].is_default === true) { if (instances[i].is_default === true) {
@@ -164,11 +168,11 @@ $(function() {
}else{ }else{
image_path = "/image/logo.png"; image_path = "/image/logo.png";
} }
if (menu_item_box == "set_item_box") { // if (menu_item_box == "set_item_box") {
add_icon = "set_item_box"
}else{ // }else{
add_icon = "add_icon"
} // }
row = '<div class="card custom-card testimonial-card animated fadeInRight" style="">' row = '<div class="card custom-card testimonial-card animated fadeInRight" style="">'
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;">' +'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;">'
@@ -190,7 +194,10 @@ $(function() {
+ price +"' data-instance-code = '"+ code +"' data-instance = '" + price +"' data-instance-code = '"+ code +"' data-instance = '"
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '" + name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '" + JSON.stringify(item_attributes) +"' data-options = '"
+ options +"' data-image='"+image_path+"' >" + options +"' data-image='"+image_path+"' data-toggle='"
+data_modal+"' data-target='."+data_target+"' data-item-sets = '"
+JSON.stringify(menu_items[field].item_sets)+"'data-instances = '"
+JSON.stringify(menu_items[field].instances)+"'>"
+"<div class='card-block custom-card-block'>" +"<div class='card-block custom-card-block'>"
+"<img id='logo' height='125px' src='"+image_path+"'>" +"<img id='logo' height='125px' src='"+image_path+"'>"
@@ -218,10 +225,12 @@ $(function() {
$('.set_change_qty').val(1); $('.set_change_qty').val(1);
change_qty_plus_minus("set_count","set_plus","set_minus"); change_qty_plus_minus("set_count","set_plus","set_minus");
data = $(this).parent().children().children('.add_icon'); data = $(this).parent().children().children('.add_icon');
// data = $(this).parent().siblings('.add_icon');
instances = $(this).data('instance'); //instances = $(this).data('instance');
item_sets = $(this).data('item-sets'); item_sets = $(this).data('item-sets');
instances = $(this).data('instances');
// item_sets = $(data).attr('data-item-sets');
console.log(instances)
for(var field in item_sets) { for(var field in item_sets) {
$('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]); $('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]);
@@ -274,11 +283,11 @@ $(function() {
$('#set_change_qty').val(1); $('#set_change_qty').val(1);
$('#set_item_instances').text(instances); $('#set_item_instances').text(instances);
$('#set_name').text(data.attr('data-name')); $('#set_name').text($(this).attr('data-name'));
$('#set_item_code').text(data.attr('data-item-code')); $('#set_item_code').text($(this).attr('data-item-code'));
$('#set_total_price').text(data.attr('data-price')); $('#set_total_price').text($(this).attr('data-price'));
// $('#set_total_price').text(0); // $('#set_total_price').text(0);
$('#set_unit_price').text(data.attr('data-price')); $('#set_unit_price').text($(this).attr('data-price'));
// $('#set_unit_price').text(0); // $('#set_unit_price').text(0);
}); });
// click instance for add item set // click instance for add item set
@@ -735,7 +744,7 @@ $(function() {
if (type == 'true') { if (type == 'true') {
type = 'cashier' type = 'cashier'
var table_type = $('#table_id').find("option:selected").data('type'); var table_type = $('#table_type').text();
var table_id = $('#table_id').val(); var table_id = $('#table_id').val();
var customer_id = $('#customer_id').val(); var customer_id = $('#customer_id').val();
var booking_id = $('#booking_id').text(); var booking_id = $('#booking_id').text();
@@ -762,6 +771,7 @@ $(function() {
'customer_id': customer_id, 'guest_info': "", 'customer_id': customer_id, 'guest_info': "",
'table_id': table_id, 'table_id': table_id,
'order_items': order_items }; 'order_items': order_items };
if (table_id.length>0) {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: ajax_url, url: ajax_url,
@@ -777,6 +787,12 @@ $(function() {
} }
} }
}); });
}else{
$(this).removeAttr('disabled', '');
$("#oqs_loading_wrapper").hide();
swal("Opps","Please Select Table or Room","warning");
}
}); });

View File

@@ -3,7 +3,7 @@ class Origami::QuickServiceController < ApplicationController
def index def index
@menu = MenuCategory.all.active @menu = MenuCategory.all.active
@dining = DiningFacility.all.active @zone = Zone.all
@customer = Customer.all @customer = Customer.all
@tables = Table.all.active.order('status desc') @tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc') @rooms = Room.all.active.order('status desc')

View File

@@ -78,10 +78,11 @@
<!-- <i class="material-icons">reply</i> --> <!-- <i class="material-icons">reply</i> -->
Back Back
</button> </button>
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-6" id='pending_order' style=" padding: .5rem 0.15rem !important;">Pending Order <button type="button" class="btn btn-lg btn-primary waves-effect col-md-6" id='pending_order' style="padding: .5rem 0.15rem !important;">Pending Order
</button> </button>
<a class="btn btn-lg bg-blue waves-effect select_table col-md-3" data-toggle="modal" data-target="#TableModal" style=" padding: .5rem 0.15rem !important;">Select</a> <a class="btn btn-lg bg-blue waves-effect select_table col-md-3" data-toggle="modal" data-target="#TableModal" style=" padding: .5rem 0.15rem !important;">Select</a>
<input type="hidden" name="table_id" value="" id="table_id"> <input type="hidden" name="table_id" value="" id="table_id">
<%else%> <%else%>
<button type="button" class="btn btn-lg btn-block btn-default waves-effect" id='back'> <button type="button" class="btn btn-lg btn-block btn-default waves-effect" id='back'>
<i class="material-icons">reply</i>Back <i class="material-icons">reply</i>Back
@@ -110,7 +111,7 @@
<p class="hidden" id="customer_id"><%=@customer ? @customer.customer_id : ''%></p> <p class="hidden" id="customer_id"><%=@customer ? @customer.customer_id : ''%></p>
<p class="hidden" id="sale_id"><%=@sale_id%></p> <p class="hidden" id="sale_id"><%=@sale_id%></p>
<% else%> <% else%>
<p class="hidden" id="table_type"></p>
<% end%> <% end%>
</div> </div>
<% else %> <% else %>
@@ -361,84 +362,37 @@
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;">&times;</button> <button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;">&times;</button>
</div> </div>
<div class="modal-body" style="margin-top: -0.75rem;padding-top:5px"> <div class="modal-body" style="margin-top: -0.75rem;padding-top:5px">
<h5>Table</h5> <%@zone.each do |zone| %>
<h5>Zone : <%=zone.name%></h5>
<div class="card-columns" style="column-count: 7;"> <div class="card-columns" style="column-count: 7;">
<% @tables.each do |table| %> <%zone.tables.each do |table| %>
<% if table.status == 'occupied' %> <% if table.status == 'occupied' %>
<% if table.get_booking.nil? %> <% if table.get_booking.nil? %>
<% if table.get_checkout_booking.nil? %> <% if table.get_checkout_booking.nil? %>
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>" data-name="<%= table.name %>" style="margin-bottom: .5rem;"> <% color="red"%>
<% else %> <% else %>
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>" data-name="<%= table.name %>" style="margin-bottom: .5rem;"> <% color="orange"%>
<% end %> <% end %>
<div class="card-block">
<%= table.name %>
<!-- <span class="float-right font-12 new_text_<%= table.id %>"> billed</span>
<div style="font-size:12px;"></div> -->
</div>
</div>
<% else %> <% else %>
<% if table.get_checkout_booking.nil? %> <% if table.get_checkout_booking.nil? %>
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>" data-name="<%= table.name %>" style="margin-bottom: .5rem;"> <% color="blue"%>
<% else %> <% else %>
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>" data-name="<%= table.name %>" style="margin-bottom: .5rem;"> <% color="orange"%>
<% end %> <% end %>
<% end %>
<% else %>
<% color="green"%>
<% end %>
<div class="card tables <%=color%> text-white table_<%= table.id %>" data-id="<%= table.id %>" data-type="<%= table.type %>" data-name="<%= table.name %>">
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
<span class="float-right font-12 new_text_<%= table.id %>"> new</span>
</div> </div>
</div> </div>
<% end %> <%end%>
<% else %>
<div class="card tables green text-white table_<%= table.id %>" data-id="<%= table.id %>" data-name="<%= table.name %>" style="margin-bottom: .5rem;">
<div class="card-block">
<%= table.name %>
<span class="float-right font-12 new_text_<%= table.id %> hide"> new</span>
</div>
</div>
<% end %>
<% end %>
</div>
<hr style="margin: 5px 20px">
<h5>Room</h5>
<div class="card-columns" style="column-count: 7;">
<% @rooms.each do |table| %>
<% if table.status == 'occupied' %>
<% if table.get_booking.nil? %>
<% if table.get_checkout_booking.nil? %>
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>" data-name="<%= table.name %>" style="margin-bottom: .5rem;">
<% else %>
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>" data-name="<%= table.name %>" style="margin-bottom: .5rem;">
<% end %>
<div class="card-block">
<%= table.name %>
<!-- <span class="float-right font-12 new_text_<%= table.id %>"> billed</span>
<div style="font-size:12px;"></div> -->
</div>
</div>
<% else %>
<% if table.get_checkout_booking.nil? %>
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>" data-name="<%= table.name %>" style="margin-bottom: .5rem;">
<% else %>
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>" data-name="<%= table.name %>" style="margin-bottom: .5rem;">
<% end %>
<div class="card-block">
<%= table.name %>
<span class="float-right font-12 new_text_<%= table.id %>"> new</span>
</div>
</div>
<% end %>
<% else %>
<div class="card tables green text-white table_<%= table.id %>" data-id="<%= table.id %>" data-name="<%= table.name %>" style="margin-bottom: .5rem;">
<div class="card-block">
<%= table.name %>
<span class="float-right font-12 new_text_<%= table.id %> hide"> new</span>
</div>
</div>
<% end %>
<% end %>
</div>
</div> </div>
<%end%>
<div class="modal-footer p-r-30"> <div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button> <button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp; &nbsp; &nbsp;
@@ -447,6 +401,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<% end %> <% end %>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
@@ -455,18 +410,24 @@
$('.tables').removeClass('purple') $('.tables').removeClass('purple')
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
var name = $(this).attr("data-name"); var name = $(this).attr("data-name");
var type = $(this).attr("data-type");
$(this).css('background-color','purple'); $(this).css('background-color','purple');
$(this).addClass('purple') $(this).addClass('purple')
$('.confirm_table').attr("data-id",dining_id) $('.confirm_table').attr("data-id",dining_id)
$('.confirm_table').attr("data-name",name) $('.confirm_table').attr("data-name",name)
$('.confirm_table').attr("data-type",type)
}); });
$(".confirm_table").on('click', function () { $(".confirm_table").on('click', function () {
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
var name = $(this).attr("data-name"); var name = $(this).attr("data-name");
var type = $(this).attr("data-type");
$('#table_id').val(dining_id) $('#table_id').val(dining_id)
$('#table_type').text(type)
$('.select_table').text(name) $('.select_table').text(name)
console.log(type)
}); });
$('#pending_order').on('click', function () { $('#pending_order').on('click', function () {
window.location.href = '/origami/quick_service/pending_order'; window.location.href = '/origami/quick_service/pending_order';