diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index cefa64fb..237bf321 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1,4 +1,7 @@ $(function() { + + type = $('#type').val(); + modify_order = $('#modify_order').val(); //click menu sidebar menu category $(".product").on("click", function(){ var url = $(this).attr('data-ref'); @@ -83,9 +86,17 @@ $(function() { //show menu item list when click menu category function show_menu_item_list(url_item){ - var menu_list = $('.menu_items_list'); menu_list.empty(); + + if (modify_order=="true" && type =="true") { + url_item = '../../../addorders/'+url_item; + }if(modify_order=="false" && type =="true"){ + url_item = 'addorders/'+url_item + }else{ + url_item = url_item; + } + //Start Ajax $.ajax({ type: "GET", @@ -112,8 +123,10 @@ $(function() { if (JSON.stringify(menu_items[field].item_sets)!='[]') { fa_plus = ''; add = ''; - menu_item_box = 'set_item_box'; + menu_item_box = 'add_icon'; data_target = 'sx_item_set_detailModal'; + data_modal = 'modal' + add_icon = "set_item_box" code = menu_items[field].code; name = menu_items[field].name; instances = menu_items[field].instances; @@ -133,6 +146,8 @@ $(function() { add = 'add' menu_item_box = 'menu_item_box'; data_target = 'sx_item_detailModal'; + data_modal = '' + add_icon = "add_icon" $(instances).each(function(i){ if (instances[i].is_default === true) { @@ -149,39 +164,51 @@ $(function() { } if (menu_items[field].image) { - image_path = menu_items[field].image; + if (modify_order) { + image_path = "../../"+menu_items[field].image; + }else{ + image_path = menu_items[field].image; + } + }else{ - image_path = "/image/logo.png"; + if (modify_order) { + image_path = "../../image/logo.png"; + }else{ + image_path = "image/logo.png"; + } } + - row = '
' - +'
' + row = '
' + +'
' +'
'+ menu_items[field].name +'
' - +"
" - +"" - +add+ '' - +'
' - +'
' - - +"
" + +JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"' >" + +"" + +add+ '' + +'
' + +'
' + +"
" - +"
" - +"" - +"
" + // +"
" + // +"" + // +"
" - +''; @@ -203,9 +230,11 @@ $(function() { $('.set_change_qty').val(1); change_qty_plus_minus("set_count","set_plus","set_minus"); data = $(this).parent().children().children('.add_icon'); - - instances = $(this).data('instance'); + // data = $(this).parent().siblings('.add_icon'); + //instances = $(this).data('instance'); item_sets = $(this).data('item-sets'); + instances = $(this).data('instances'); + // item_sets = $(data).attr('data-item-sets'); for(var field in item_sets) { @@ -259,11 +288,11 @@ $(function() { $('#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_name').text($(this).attr('data-name')); + $('#set_item_code').text($(this).attr('data-item-code')); + $('#set_total_price').text($(this).attr('data-price')); // $('#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); }); // click instance for add item set @@ -423,7 +452,8 @@ $(function() { change_qty_plus_minus("count","plus","minus"); - data = $(this).parent().children().children('.add_icon'); + // data = $(this).parent().children().children('.add_icon'); + data = $(this).parent().siblings('.add_icon'); $('#total_price').text(data.attr('data-price')); attributes = $(this).data('id'); @@ -432,9 +462,19 @@ $(function() { item_options = $(this).data('option'); if (data.attr('data-image')) { - image = ""; + if (modify_order) { + image = ""; + }else{ + image = ""; + } + }else{ - image = ""; + if (modify_order) { + image = ""; + }else{ + image = ""; + } + } $('#modal_box_img').append(image); @@ -708,53 +748,118 @@ $(function() { } } - // Pay Discount for Payment + // Create Order $("#create_order").on('click', function(e){ + $(this).attr('disabled', 'disabled'); e.preventDefault(); $("#oqs_loading_wrapper").show(); - var table_id = $('#table_id').text(); - var customer_id = $('#customer_id').text(); - var booking_id = $('#booking_id').text(); + + type = $('#type').val(); + if (type == 'true') { + type = 'cashier' + + var table_type = $('#table_type').text(); + var table_id = $('#table_id').val(); + var customer_id = $('#customer_id').val(); + var booking_id = $('#booking_id').text(); + var ajax_url = 'addorders/create'; + }else{ + type = 'cashier' + var table_type = $('#table_type').text(); + var table_id = $('#table_id').text(); + var customer_id = $('#customer_id').text(); + var booking_id = $('#booking_id').text(); + var ajax_url = '../addorders/create'; + } if (!booking_id.length > 0) { - var params = {'order_source': "cashier", 'order_type': "dine_in", + var params = {'order_source': type, 'order_type': "dine_in", 'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id, 'table_id': table_id, 'order_items': order_items }; } - var table_type = $('#table_type').text(); + var order_items = JSON.stringify(get_order_item_rows()); - var ajax_url = '../addorders/create'; - var params = {'order_source': "cashier", 'order_type': "dine_in", + var params = {'order_source': type, 'order_type': "dine_in", 'customer_id': customer_id, 'guest_info': "", 'table_id': table_id, 'order_items': order_items }; + if (table_id.length>0) { + $.ajax({ + type: "POST", + url: ajax_url, + data: params, + dataType: "json", + success:function(result){ + + if(table_type == "Table"){ + window.location.href = "/origami/table/" + table_id + } + else { + window.location.href = "/origami/room/" + table_id + } + } + }); + }else{ + $(this).removeAttr('disabled', ''); + $("#oqs_loading_wrapper").hide(); + + swal("Opps","Please Select Table or Room","warning"); + } + }); + + + // Pay Discount for Payment + $("#create_pay_order").on('click', function(e){ + $(this).attr('disabled', 'disabled'); + e.preventDefault(); + type = "quick_service" + $("#oqs_loading_wrapper").show(); + console.log(modify_order) + if (modify_order == "true") { + console.log($('#sale_id').text()) + var ajax_url = '../../../quick_service/update_modify_order'; + var table_type = $('#table_type').text(); + var table_id = $('#table_id').text(); + var customer_id = $('#customer_id').text(); + var booking_id = $('#booking_id').text(); + var sale_id = $('#sale_id').text(); + }else{ + var ajax_url = 'addorders/create'; + var table_type = $('#table_id').find("option:selected").data('type'); + var table_id = $('#table_id').val(); + var customer_id = $('#customer_id').val(); + var booking_id = $('#booking_id').text(); + var sale_id = "" + } + + if (!booking_id.length > 0) { + + var params = {'order_source': type, 'order_type': "dine_in", + 'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id, + 'table_id': table_id, + 'order_items': order_items }; + } + var order_items = JSON.stringify(get_order_item_rows()); + + var params = {'order_source': type, 'order_type': "dine_in", + 'customer_id': customer_id, 'guest_info': "", + 'table_id': table_id, + 'order_items': order_items,'sale_id': sale_id }; + console.log(params) $.ajax({ type: "POST", url: ajax_url, data: params, dataType: "json", - success:function(result){ - // $("#oqs_loading_wrapper").hide(); - // swal({ - // title: "Information !", - // text: 'Order has been successfully created', - // confirmButtonColor: "green", - // confirmButtonText: "Yes!", - // closeOnConfirm: false, - // }, function (isConfirm) { - // if (isConfirm) { - if(table_type == "Table"){ - window.location.href = "/origami/table/" + table_id - } - else { - window.location.href = "/origami/room/" + table_id - } - // } - // }); - } + success:function(result){ + console.log(result) + if (result.status) { + window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment" + } + } }); }); @@ -869,11 +974,21 @@ $(function() { $("#back").on("click", function(){ var table_id = $('#table_id').text(); var table_type = $('#table_type').text(); - if(table_type == "Table"){ - window.location.href = "/origami/table/" + table_id - }else { - window.location.href = "/origami/room/" + table_id - } + type = $('#type').val(); + if (type == 'true') { + var table_type = $('#table_id').find("option:selected").data('type'); + var table_id = $('#table_id').val(); + window.location.href = "/origami/dashboard" + }else{ + var table_type = $('#table_type').text(); + var table_id = $('#table_id').text(); + + if(table_type == "Table"){ + window.location.href = "/origami/table/" + table_id + }else { + window.location.href = "/origami/room/" + table_id + } + } }); // Get Selected Class @@ -984,6 +1099,14 @@ $(function() { //show menu item list when click menu category function show_sub_category_list(url,sub_category){ + if (modify_order == "true" && type =="true") { + var url = "../../../addorders/"+url; + }if(modify_order=="false" && type =="true"){ + var url = 'addorders/'+url; + }else{ + var url = url; + } + var menu_list = $('.sub_category_list'); menu_list.empty(); //Start Ajax @@ -998,7 +1121,12 @@ $(function() { data = data.sub_category; if (data.length>0) { - $(sub_category).removeClass('hidden'); + if ((sub_category.hasClass('hidden'))) { + $(sub_category).removeClass('hidden'); + }else{ + $(sub_category).addClass('hidden'); + } + for(var i in data) { row = '
  • - + monetization_on <%= t :origami %> diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index ab813ec6..ff72d2bc 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -1,17 +1,72 @@ + <%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'addorder', 'data-turbolinks-track': 'reload' %> +<% type = request.path_info.include?('quick_service')%> +<% modify_order = request.path_info.include?('modify_order')%> + +
    -
    - + + <% if type && modify_order%> + + + <%elsif !modify_order && type%> + + + Select + + + <%else%> + + <%end%>
    -
    -
    +
    + <% if type %> +
    +
    + ORDER DETAILS +
    + + <% if modify_order %> + <% if @table.nil? %> +
    Table :
    + + + <% else%> +
    Table : <%=@table.name%>
    + + + <% end%> + + + + + <% else%> + + <% end%> +
    + <% else %> +
    ORDER DETAILS | Table-<%=@table.name%> -
    + <% end%> +
    -
    - +
    +
    @@ -73,19 +197,33 @@ - +
    #Price
    - +
    +
    + <% end %> +
    +
    +
    +
    <%= t :customer %>
    + + <% if !@total_customer.nil? %> + + + + + <% end %> + <% if !@total_dinein.nil? %> + + + + + <% end %> + <% if !@total_takeaway.nil? %> + + + + + <% end %> + <% if !@total_other_customer.nil? %> + + + + + <% end %> + <% if !@total_membership.nil? %> + + + + + <% end %> +
    <%= t("views.right_panel.detail.total") %> <%= t :customer %> : <%= @total_customer %>
    <%= t("views.right_panel.detail.dine_in") %> : <%= @total_dinein.total_dinein_cus %>
    <%= t("views.right_panel.detail.takeaway") %> : <%= @total_takeaway.total_take_cus %>
    <%= t :customer %> : <%= @total_other_customer.total_cus %>
    <%= t("views.right_panel.detail.membership") %> : <%= @total_membership.total_memb_cus %>
    +
    +
    +
    +
    +
    +
    +
    <%= t("views.right_panel.detail.order") %>
    + + <% if !@total_order.nil? %> + + + + + <% end %> + + <% if !@total_accounts.nil? %> + <% @total_accounts.each do |account| %> + + + + + <% end %> + <% end %> + <% if !@top_items.nil? %> + + + + + <% end %> + <% if !@total_foc_items.nil? %> + + + + + <% end %> +
    <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.order") %> : <%= @total_order.total_order %>
    <%= account.title %> (Account) : + <% @account_data.each do |data| %> + <% acc = account.title %> + <%= data[""+acc+""] %> <% if !data[''+acc+''].nil? %> ( <%= data[''+acc+'_amount'] %> ) <% end %> + <% end %> +
    <%= t :top %> <%= t("views.right_panel.detail.item") %> : <%= @top_items.item_name %> +
    (<%= @top_items.item_total_price %>)
    <%= t("views.right_panel.detail.total") %> <%= t("views.btn.foc") %> <%= t("views.right_panel.detail.item") %> : <%= @total_foc_items.to_int %>
    +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 72f4fd3c..ba03f8d7 100755 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -13,8 +13,14 @@
    + <%if !@table.nil?%> + <%else%> + + + <%end%> +

    Receipt No: <%=@sale_data.receipt_no rescue ' '%>

    @@ -225,18 +231,22 @@
    diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 96f69da9..8c275785 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -2,7 +2,6 @@ -
    @@ -14,13 +13,15 @@
    Table No : <%=@table_no%>
    +
    Sale ID : <% if @sale_data %><%=@sale_data.sale_id %><% end %>
    Customer : <%= @sale_data.customer.name%>
    -
    Checkin Time : <%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %>
    +
    Checkin Time : <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %> + <%end%>
    @@ -296,13 +297,23 @@ + <% if @cashier_type=="quick_service" %> +
    + + + +
    - +
    \ No newline at end of file diff --git a/app/views/origami/pending_order/index.html.erb b/app/views/origami/pending_order/index.html.erb new file mode 100644 index 00000000..a3df293c --- /dev/null +++ b/app/views/origami/pending_order/index.html.erb @@ -0,0 +1,47 @@ +
    +
    + +
    +
    +
    + PENDING ORDER +
    +
    +
    +
    + <% @sale.each do |sale| %> +
    +
    + <%= sale.receipt_no %><%= sale.sale_status %> +
    +
    + <% end %> +
    +
    +
    +
    +
    + +
    + + +
    +
    +
    + diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb new file mode 100644 index 00000000..c7233400 --- /dev/null +++ b/app/views/origami/pending_order/show.html.erb @@ -0,0 +1,147 @@ +
    +
    + +
    +
    +
    + PENDING ORDER +
    +
    +
    +
    + <% @sales.each do |sale| %> +
    +
    + <%= sale.receipt_no %><%= sale.sale_status %> +
    +
    + <% end %> +
    +
    +
    +
    +
    + + + +
    +
    +
    +
    INVOICE DETAILS | Table <%= @dining.name rescue "" %>
    +
    +
    +
    +
    +   Receipt No: + <%= @sale.receipt_no rescue '' %> + +
    +
    + Date: <%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>   +
    +
    +
    +
    +   Customer : <%= @sale.customer.name rescue "-" %> + +
    + +
    +
    +
    + + + + + + + + + + <% + sub_total = 0 + @sale.sale_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + + <% #unless sale_item.price <= 0 %> + + + + + + <% + + #end + end + + %> + +
    ItemsQTYPrice
    <%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
    +
    +
    + +
    +
    +
    + +
    + + + +
    +
    +
    + diff --git a/app/views/origami/quick_service/index.html.erb b/app/views/origami/quick_service/index.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index d250e0b7..1d29e563 100755 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -103,11 +103,12 @@
    - +