diff --git a/app/assets/javascripts/CRM.js b/app/assets/javascripts/CRM.js index fc535ff7..c7457bed 100644 --- a/app/assets/javascripts/CRM.js +++ b/app/assets/javascripts/CRM.js @@ -17,4 +17,5 @@ //= require turbolinks //= require cable //= require jquery-ui -//= require bootstrap-datepicker \ No newline at end of file +//= require bootstrap-datepicker +//= require bootstrap/modal \ No newline at end of file diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 9ad540ab..e7b85110 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -17,46 +17,71 @@ //= require cable $(document).ready(function(){ + // auto refresh every 10 seconds // setTimeout(function(){ // window.location.reload(1); // }, 10000); $('.queue_station').on('click',function(){ - var orderZone=$(this).children().children().children('.order-zone').text(); - var orderItem=$(this).children().children().children('.order-item').text(); - var orderQty=$(this).children().children().children('.order-qty').text(); - var orderBy=$(this).children().children().children().children('.order-by').text(); - var orderAt=$(this).children().children().children().children('.order-at').text(); - var orderCustomer=$(this).children().children('.order-customer').text(); + var orderZone=$(this).children().children().children('.order-zone').text().trim(); + // var orderItem=$(this).children().children().children('.order-item').text(); + //var assigned_item_id = $(this).children().find(".assigned-order-item").text(); + var orderQty = $(this).children().children().children('.order-qty').text(); + var orderBy = $(this).children().children().children().children('.order-by').text(); + var orderAt = $(this).children().children().children().children('.order-at').text(); + var orderCustomer = $(this).children().children('.order-customer').text(); + var order_status = $(this).children().children('.order-status').text(); $('#order-title').text("ORDER DETAILS - " + orderZone); $('#order-by').text(orderBy); $('#order-at').text(orderAt); $('#order-customer').text(orderCustomer); $('#order-from').text(orderZone); + // clear order items + $("#oqs-order-details-table").children("tbody").empty(); - $('#order-items').text(orderItem); - $('#order-qty').text(orderQty); + // Call get_order_items() for Order Items by dining + $.ajax({ + type: 'GET', + url: '/oqs/' + orderZone, + data: { 'status' : order_status }, + success: function(res){ + for (i = 0; i < res.length; i++) { + var data = JSON.stringify(res[i]); + var parse_data = JSON.parse(data); + + var order_item_row = "" + + "" + parse_data.item_name + "" + + "" + parse_data.qty + "" + + ""; + $("#oqs-order-details-table").children("tbody").append(order_item_row); + } + } + }) + + // $('#order-items').text(orderItem); + // $('#order-qty').text(orderQty); $('.queue_station').removeClass('selected-item'); $(this).addClass('selected-item'); }); // complete for queue item - $('.order-complete').on('click',function(e){ + $('.order-complete').on('click',function(e){ //e.preventDefault(); - var _self = $(this); // To know in ajax return - var assigned_item_id=$(this).attr('id').substr(15); + var _self = $(this); // To know in ajax return + var assigned_item_id=$(this).attr('id').substr(15); var params = { 'id':assigned_item_id }; - + + // Call update_delivery_status() for changed delivery and move to delivery $.ajax({ type: 'POST', url: '/oqs/update_delivery', data: params, dataType: 'json', - success: function(data){ - for (i = 0; i < data.length; i++) { + success: function(data){ + for (i = 0; i < data.length; i++) { var queue_station = $('#assigned_queue_' + data[i]).parent().parent(".queue_station"); var station = queue_station.parent().parent().attr('id'); @@ -65,7 +90,7 @@ $(document).ready(function(){ // Remove a queue card from current station queue_station.children('.card-footer').remove(); - + // Add removed queue card from station to completed $("#completed").children('.card-columns').append(queue_station); @@ -73,33 +98,35 @@ $(document).ready(function(){ var station_count=parseInt($("#"+station+"_count").text()) - 1; $("#"+station+"_count").text(station_count); } - - // update queue item count in completed station + + // update queue item count in completed station $("#completed_count").text(parseInt($("#completed_count").text()) + data.length); alert("updated!"); // Page reload location.reload(); } - }); + }); }); + // Print Order Item $('#print_order_item').on('click',function(){ - var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); + var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); var params = { 'id':assigned_item_id }; $.ajax({ type: 'GET', - url: '/oqs/print/print/'+assigned_item_id, + url: '/oqs/print/print/'+assigned_item_id, success: function(data){ } }); }); + // Print Order Summary $('#print_order_summary').on('click',function(){ - var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); + var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); var params = { 'id':assigned_item_id }; $.ajax({ type: 'GET', - url: '/oqs/print/print_order_summary/'+assigned_item_id, + url: '/oqs/print/print_order_summary/'+assigned_item_id, success: function(data){ } }); }); diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index b39a4c6e..78a21c3b 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -121,7 +121,7 @@ $(document).ready(function(){ // Bill Request $('#request_bills').click(function() { - var order_id=$(".selected-item").find(".orders-id").text(); + var order_id=$(".selected-item").find(".orders-id").text().substr(0,16); if(order_id!=""){ window.location.href = '/origami/' + order_id + '/request_bills' } @@ -133,7 +133,8 @@ $(document).ready(function(){ // Discount for Payment $('#discount').click(function() { - var order_id=$(".selected-item").find(".orders-id").text(); + var order_id=$(".selected-item").find(".orders-id").text().substr(0,16); + if(order_id!=""){ window.location.href = '/origami/' + order_id + '/discount' } @@ -148,7 +149,7 @@ $(document).ready(function(){ $("#pay-discount").on('click', function(e){ e.preventDefault(); var sale_id = $('#sale-id').text(); - var sale_item_id = $('.selected-item').attr('id'); + var sale_item_id = $('.selected-item').attr('id').substr(0,16); var sub_total = $('#order-sub-total').text(); var grand_total = $('#order-grand-total').text(); var discount_type = $('#discount-type').val(); @@ -178,7 +179,7 @@ $(document).ready(function(){ // Payment for Bill $('#pay-bill').click(function() { - var sale_id=$(".selected-item").find(".orders-id").text(); + var sale_id=$(".selected-item").find(".orders-id").text().substr(0,16); if(sale_id!=""){ window.location.href = '/origami/sale/'+ sale_id + "/payment" } @@ -190,7 +191,7 @@ $(document).ready(function(){ }); $('#customer').click(function() { - var sale = $(".selected-item").find(".orders-id").text(); + var sale = $(".selected-item").find(".orders-id").text().substr(0,16); if (sale.substring(0, 3)=="SAL") { var sale_id = sale }else{ @@ -202,7 +203,7 @@ $(document).ready(function(){ }); $('#re-print').click(function() { - var sale_id = $(".selected-item").find(".orders-id").text(); + var sale_id = $(".selected-item").find(".orders-id").text().substr(0,16); window.location.href = '/origami/'+ sale_id + "/reprint" @@ -227,20 +228,24 @@ $(document).ready(function(){ dataType: "json", success: function(data) { $("#customer_name").text(data["customer"].name); - $.each(data["response_data"]["data"], function (i) { - if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ - var balance = data["response_data"]["data"][i]["balance"]; - if (data["response_data"]["status"]==true) { - $('.rebate_amount').removeClass('hide'); - row = - '' + data["response_data"]["data"][i]["accountable_type"] +'' - +'' + balance + ''; + if (data["response_data"]["data"].length) { + $.each(data["response_data"]["data"], function (i) { + if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ + var balance = data["response_data"]["data"][i]["balance"]; + if (data["response_data"]["status"]==true) { + $('.rebate_amount').removeClass('hide'); + row = + '' + data["response_data"]["data"][i]["accountable_type"] +'' + +'' + balance + ''; - $(".rebate_amount").html(row); - } + $(".rebate_amount").html(row); + } - } - }); + } + }); + }else{ + $('.rebate_amount').addClass('hide'); + } } }); //End Ajax diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss index a88efe96..8ddc1605 100644 --- a/app/assets/stylesheets/CRM.scss +++ b/app/assets/stylesheets/CRM.scss @@ -3,6 +3,7 @@ @import "theme"; @import "jquery-ui"; @import "bootstrap-datepicker3"; +@import "bootstrap/modal"; /* Show it is fixed to the top */ // body { @@ -10,4 +11,15 @@ // padding-top: 4.5rem; // } +.selected-item { + color: #fff !important; + background-color: #ccc !important; +} +.assign { + color: #fff !important; + background-color: red; +} +.assign .text-muted{ + color: #fff !important; +} diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 6b1fb225..03909dc4 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -15,13 +15,29 @@ class Api::BillController < Api::ApiController @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee) else @status = true + @sale_id = booking.sale_id end end elsif (params[:order_id]) @sale = Sale.new @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee) - end + + @sale_data = Sale.find_by_sale_id(@sale_id) + @sale_items = SaleItem.where("sale_id=?",@sale_id) + + unique_code = "ReceiptBillPdf" + customer= Customer.where('customer_id=' + @sale_data.customer_id) + + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + + # Calculate Food and Beverage Total + + food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total) end diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 08847f6f..c383fafb 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -31,7 +31,7 @@ class Api::OrdersController < Api::ApiController @order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile @order.items = params[:order_items] @order.guest = params[:guest_info] - @order.table_id = params[:table_id] + @order.table_id = params[:table_id] # this is dining facilities's id @order.new_booking = true @order.employee_name = current_login_employee.name #Create Table Booking or Room Booking diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 4cacae00..290f6ca1 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -117,7 +117,7 @@ class Crm::CustomersController < BaseCrmController # format.json { render :index, status: :created, location: @crm_customers } else - @crm_customers.destroy + # @crm_customers.destroy if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} else diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 41655d98..251b0781 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -4,7 +4,8 @@ class Crm::DiningQueuesController < BaseCrmController # GET /crm/dining_queues # GET /crm/dining_queues.json def index - @dining_queues = DiningQueue.all + today = DateTime.now.strftime('%Y-%m-%d') + @dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? ", today).order("queue_no asc") end # GET /crm/dining_queues/1 @@ -38,7 +39,7 @@ class Crm::DiningQueuesController < BaseCrmController printer = Printer::ReceiptPrinter.new(print_settings) printer.print_queue_no(print_settings,@dining_queue) - format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' } + format.html { redirect_to crm_dining_queues_path, notice: 'Queue was successfully created.' } format.json { render :show, status: :created, location: @dining_queue } else format.html { render :new } @@ -52,7 +53,7 @@ class Crm::DiningQueuesController < BaseCrmController def update respond_to do |format| if @dining_queue.update(dining_queue_params) - format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully updated.' } + format.html { redirect_to crm_dining_queues_path, notice: 'Queue was successfully updated.' } format.json { render :show, status: :ok, location: @dining_queue } else format.html { render :edit } @@ -71,6 +72,27 @@ class Crm::DiningQueuesController < BaseCrmController end end + def assign + @queue = DiningQueue.find(params[:id]) + @tables = DiningFacility.where("status = 'available' ") + respond_to do |format| + format.html # index.html.erb + end + end + + def assign_table + queue = DiningQueue.find(params[:id]) + table_id = params[:table_id] + + queue.update_attributes(dining_facility_id: table_id,status:"Assign") + DiningFacility.find(table_id).update_attributes(status: "occupied") + respond_to do |format| + format.html { redirect_to crm_dining_queues_path, notice: 'Table was successfully assigned.' } + format.json { head :no_content } + end + end + + private # Use callbacks to share common setup or constraints between actions. def set_dining_queue @@ -79,6 +101,6 @@ class Crm::DiningQueuesController < BaseCrmController # Never trust parameters from the scary internet, only allow the white list through. def dining_queue_params - params.require(:dining_queue).permit(:name, :contact_no, :queue_no) + params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status) end end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 7af42166..58aac67c 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -1,27 +1,65 @@ class Oqs::HomeController < BaseOqsController def index queue_stations=OrderQueueStation.all - + @queue_items_details = queue_items_query(0) - @queue_completed_item = queue_items_query(1) - + @queue_completed_item = queue_items_query(1) + @queue_stations_items=Array.new # Calculate Count for each station tab - queue_stations.each do |que| + queue_stations.each do |que| i=0 - @queue_items_details.each do |qid| - if qid.station_name == que.station_name - i=i+1 - end - end - @queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i }) + @queue_items_details.each do |qid| + if qid.station_name == que.station_name + i=i+1 + end + end + @queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i }) end @queue_stations_items end + # Get Order items + def get_order_items + items = [] + table_name = params[:table_id] + status = params[:status] + dining = DiningFacility.find_by_name(table_name); + # oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) + # if status == "" + # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi| + # oi = OrderItem.find_by_item_code(aoi.item_code) + # items.push(oi) + # end + # else + # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi| + # oi = OrderItem.find_by_item_code(aoi.item_code) + # items.push(oi) + # end + # end + + booking = Booking.find_by_dining_facility_id(dining.id) + BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo| + order=Order.find(bo.order_id) + order.order_items.each do |oi| + items.push(oi) + end + end + + # booking_id = dining.get_new_booking + # BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo| + # order=Order.find(bo.order_id); + # order.order_items.each do |oi| + # items.push(oi) + # end + # end + + render :json => items.to_json + end + def show end @@ -35,24 +73,33 @@ class Oqs::HomeController < BaseOqsController # update delivery status for completed same order items assigned_items.each do |ai| ai.delivery_status=true - ai.save + ai.save removed_item.push(ai.assigned_order_item_id) - end - render :json => removed_item.to_json + end + render :json => removed_item.to_json end # Query for OQS with status def queue_items_query(status) + # AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") + # .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id + # left join dining_facilities as df on df.zone_id = oqpz.zone_id + # left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id + # left join orders as od ON od.order_id = assigned_order_items.order_id + # left join order_items as odt ON odt.item_code = assigned_order_items.item_code + # left join customers as cus ON cus.customer_id = od.customer_id") + # .where("assigned_order_items.delivery_status = #{status}") + # .group("assigned_order_items.assigned_order_item_id") + # .order("odt.item_name DESC") AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") - .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id - left join dining_facilities as df on df.zone_id = oqpz.zone_id - left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id + .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id left join orders as od ON od.order_id = assigned_order_items.order_id left join order_items as odt ON odt.item_code = assigned_order_items.item_code - left join customers as cus ON cus.customer_id = od.customer_id") + left join customers as cus ON cus.customer_id = od.customer_id + left join booking_orders as bo on bo.order_id = assigned_order_items.order_id + left join bookings as bk on bk.booking_id = bo.booking_id + left join dining_facilities as df on df.id = bk.dining_facility_id") .where("assigned_order_items.delivery_status = #{status}") .group("assigned_order_items.assigned_order_item_id") - .order("odt.item_name DESC") end end - diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index ecbc94e7..9fc2a2d7 100644 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -6,13 +6,13 @@ class Oqs::PrintController < ApplicationController assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); - # printer for each stations - printer_name = assigned_item.order_queue_station.printer_name + # order queue stations + oqs = assigned_item.order_queue_station # print when complete click print_settings=PrintSetting.find_by_unique_code(unique_code) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_item(printer_name,assigned_item.order_id, assigned_item.item_code ) + order_queue_printer.print_order_item(oqs,assigned_item.order_id, assigned_item.item_code ) # update print status for completed same order items assigned_items.each do |ai| @@ -28,13 +28,13 @@ class Oqs::PrintController < ApplicationController assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); - # printer for each stations - printer_name = assigned_item.order_queue_station.printer_name + # order queue stations + oqs = assigned_item.order_queue_station # print when complete click print_settings=PrintSetting.find_by_unique_code(unique_code) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_summary(printer_name,assigned_item.order_id) + order_queue_printer.print_order_summary(oqs,assigned_item.order_id) # update print status for completed same order items assigned_items.each do |ai| diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index dbde3293..1aca9b2d 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -1,8 +1,8 @@ class Origami::HomeController < BaseOrigamiController def index if params[:booking_id] != nil - type=params[:booking_id].split('-')[0]; - # Sale + type=params[:booking_id].split('-')[0]; + # Sale if type == "SAL" @selected_item = Sale.find(params[:booking_id]) @selected_item_type="Sale" @@ -10,23 +10,23 @@ class Origami::HomeController < BaseOrigamiController else @selected_item = Order.find(params[:booking_id]) @selected_item_type="Order" - end - end + end + end @completed_orders = Order.get_completed_order() @booking_orders = Order.get_booking_order_table() - @booking_rooms = Order.get_booking_order_rooms() + @booking_rooms = Order.get_booking_order_rooms() @orders = Order.get_orders() - end + end def item_show selection(params[:booking_id],1) - end + end def selection(selected_id, is_ajax) str = [] - type=selected_id.split('-')[0]; - # Sale + type=selected_id.split('-')[0]; + # Sale if type == "SAL" @order_details = SaleItem.get_order_items_details(params[:booking_id]) @order_details.each do |ord_detail| @@ -39,6 +39,7 @@ class Origami::HomeController < BaseOrigamiController str.push(ord_detail) end end + if is_ajax == 1 render :json => str.to_json else @@ -54,21 +55,21 @@ class Origami::HomeController < BaseOrigamiController else sale = Order.find(params[:sale_id]) end - + status = sale.update_attributes(customer_id: params[:customer_id]) - + if status == true render json: JSON.generate({:status => true}) else render json: JSON.generate({:status => false, :error_message => "Record not found"}) - end + end end def get_customer @customer = Customer.find(params[:customer_id]) - + response = Customer.get_member_account(@customer) respond_to do |format| diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index ca497b81..44de8eb2 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -12,7 +12,7 @@ class Origami::PaymentsController < BaseOrigamiController sale_payment = SalePayment.new sale_payment.process_payment(saleObj, @user, cash, "cash") - unique_code = "ReceiptBillPdf" + unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) # get member information @@ -20,11 +20,10 @@ class Origami::PaymentsController < BaseOrigamiController # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) - # Calculate Food and Beverage Total food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) - printer = Printer::ReceiptPrinter.new(print_settings) + printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info) end end @@ -41,14 +40,14 @@ class Origami::PaymentsController < BaseOrigamiController @sale_data = Sale.find_by_sale_id(sale_id) #get customer amount - @customer = Customer.find(@sale_data.customer_id) + @customer = Customer.find(@sale_data.customer_id) # get member information response = Customer.get_member_account(@customer) @balance = 0.00 @accountable_type = '' - if response["data"]==true + if response["status"]==true response["data"].each do |res| if res["accountable_type"] == "RebateAccount" @balance = res["balance"] @@ -84,19 +83,19 @@ class Origami::PaymentsController < BaseOrigamiController saleObj = Sale.find(sale_id) - unique_code = "ReceiptBillPdf" + unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) # get member information member_info = Customer.get_member_account(customer) - + # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) - printer = Printer::ReceiptPrinter.new(print_settings) + printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info) end diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index 6a0a52ae..b63e1ca8 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -71,6 +71,11 @@ class Settings::OrderQueueStationsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_order_queue_station_params - params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] }) +# <<<<<<< HEAD + params.require(:order_queue_station).permit(:station_name, :is_active, :auto_print, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) +# ======= +# Don't Know { zone_ids: [] } +# params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] }) +# >>>>>>> b093a993ba002c92659bbb34338c55c031c11d87 end end diff --git a/app/jobs/order_queue_processor_job.rb b/app/jobs/order_queue_processor_job.rb index e92faa36..5b3423dc 100644 --- a/app/jobs/order_queue_processor_job.rb +++ b/app/jobs/order_queue_processor_job.rb @@ -1,7 +1,7 @@ class OrderQueueProcessorJob < ApplicationJob queue_as :default - def perform(order_id) + def perform(order_id, table_id) # Do something later #Order ID order = Order.find(order_id) @@ -10,7 +10,7 @@ class OrderQueueProcessorJob < ApplicationJob #Execute orders and send to order stations if order oqs = OrderQueueStation.new - oqs.process_order(order) + oqs.process_order(order, table_id) end end diff --git a/app/models/customer.rb b/app/models/customer.rb index 0cbf8d58..de9846f2 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -9,28 +9,8 @@ class Customer < ApplicationRecord validates_presence_of :name, :contact_no, :email validates :contact_no, uniqueness: true validates :email, uniqueness: true - - paginates_per 50 - # def self.get_member_group - - # membership = MembershipSetting.find_by_membership_type("paypar_url") - # memberaction = MembershipAction.find_by_membership_type("get_all_member_group") - # app_token = membership.auth_token.to_s - - # url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - # response = HTTParty.get(url, - # :body => { app_token: app_token}.to_json, - # :headers => { - # 'Content-Type' => 'application/json', - # 'Accept' => 'application/json' - # } - # ) - # puts response.body, response.code, response.message, response.headers.inspect - - # return response; - - # end + paginates_per 50 def self.get_member_account(customer) membership = MembershipSetting.find_by_membership_type("paypar_url") @@ -38,13 +18,19 @@ class Customer < ApplicationRecord merchant_uid = memberaction.merchant_account_id.to_s auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s +# urltest =self.url_exist?(url) + begin response = HTTParty.get(url, :body => { membership_id: customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' - } + }, + :timeout => 10 ) + rescue Net::OpenTimeout + response = { status: false } + end return response; @@ -59,6 +45,35 @@ class Customer < ApplicationRecord end end +# require "net/http" +# def self.url_exist?(url_string) +# url = URI.parse(url_string) + + +# req = Net::HTTP.new(url.host, url.port) +# puts "hhhhhhhhhhhh" +# puts req.to_json +# req.use_ssl = (url.scheme == 'https') +# puts "aaaaaaaaaaaa" +# puts req.use_ssl? +# path = url.path if url.path.present? +# puts "bbbbbbbbbbbbb" +# puts path +# res = req.request_head(path || '/') +# puts "cccccccccccccc" +# puts res.to_json +# puts "ddddddddd" +# puts res.kind_of?(Net::HTTPRedirection) +# if res.kind_of?(Net::HTTPRedirection) +# url_exist?(res['location']) # Go after any redirect and make sure you can access the redirected URL +# else +# ! %W(4 5).include?(res.code[0]) # Not from 4xx or 5xx families +# end +# rescue Errno::ENOENT +# false #false if can't find the server +# end + + # def self.search(search) # where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",) # end diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index a3f8948f..6f898989 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -9,8 +9,24 @@ class DiningFacility < ApplicationRecord scope :active, -> {where(is_active: true)} def get_current_booking - puts "enter booking" - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) + puts "enter booking" + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) + + if booking.count > 0 then + return booking[0].booking_id + else + return nil + end + end + + def get_new_booking + # query for new + # if status + # to ask when req bill booking_status? + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id is null and checkout_at is null").limit(1) + # else + # booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id not null").limit(1) + # end if booking.count > 0 then return booking[0].booking_id diff --git a/app/models/dining_queue.rb b/app/models/dining_queue.rb index 09f8b6b5..d710d67f 100644 --- a/app/models/dining_queue.rb +++ b/app/models/dining_queue.rb @@ -1,7 +1,9 @@ class DiningQueue < ApplicationRecord - + belongs_to :dining_facility, :optional => true def self.generate_queue_no - queue_no = DiningQueue.all.count + 1 + today = DateTime.now.strftime('%Y-%m-%d') + dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? ", today).order("queue_no desc") + queue_no = dining_queues.count + 1 return queue_no end -end +end \ No newline at end of file diff --git a/app/models/order.rb b/app/models/order.rb index f3ae798c..14fd8cda 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -199,7 +199,7 @@ class Order < ApplicationRecord #Process order items and send to order queue def process_order_queue #Send to background job for processing - OrderQueueProcessorJob.perform_later(self.id) + OrderQueueProcessorJob.perform_later(self.id, self.table_id) end @@ -231,7 +231,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id @@ -246,7 +246,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='completed'") - .group("sales.sale_id,bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") + .group("sales.sale_id") # For PG #bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id end @@ -262,7 +262,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 874f2fb0..0350049c 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -10,26 +10,29 @@ class OrderQueueStation < ApplicationRecord scope :active, -> {where(is_active: true)} - def process_order (order) + def process_order (order, table_id) oqs_stations = OrderQueueStation.active + dining=DiningFacility.find(table_id) + oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) order_items = order.order_items #Assign OQS id to order Items oqs_stations.each do |oqs| #Get List of items - - pq_items = JSON.parse(oqs.processing_items) - - #Loop through the processing items + pq_items = JSON.parse(oqs.processing_items) + + #Loop through the processing items pq_items.each do |pq_item| #Processing through the looping items order_items.each do |order_item| if (pq_item == order_item.item_code) - #Same Order_items can appear in two location. - AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + if oqs.id == oqpbz.order_queue_station_id + #Same Order_items can appear in two location. + AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + end end end - - end + end end #Print OQS where printing is require diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 9b3f5205..dae1ad53 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -1,25 +1,44 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker - def print_order_item(printer_name,order_id, item_code) + def print_order_item(oqs,order_id, item_code) #Use CUPS service #Generate PDF #Print order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code) pdf = OrderItemPdf.new(order_item[0]) pdf.render_file "tmp/receipt.pdf" - self.print("tmp/receipt.pdf", printer_name) + if oqs.print_copy + self.print("tmp/receipt.pdf", oqs.printer_name) + self.print("tmp/receipt.pdf", oqs.printer_name) + else + self.print("tmp/receipt.pdf", oqs.printer_name) + end end - def print_order_summary(printer_name,order_id) + def print_order_summary(oqs,order_id) #Use CUPS service #Generate PDF #Print order=print_query('order_summary',order_id) - filename = "tmp/order_summary_#{order_id}" + ".pdf" - pdf = OrderSummaryPdf.new(order) - pdf.render_file filename - - self.print(filename, printer_name) + # For Print Per Item + if oqs.cut_per_item + order.each do|odi| + pdf = OrderItemPdf.new(odi) + pdf.render_file "tmp/receipt.pdf" + if oqs.print_copy + self.print("tmp/receipt.pdf", oqs.printer_name) + self.print("tmp/receipt.pdf", oqs.printer_name) + else + self.print("tmp/receipt.pdf", oqs.printer_name) + end + end + # For Print Order Summary + else + filename = "tmp/order_summary_#{order_id}" + ".pdf" + pdf = OrderSummaryPdf.new(order) + pdf.render_file filename + self.print(filename, oqs.printer_name) + end end # Query for OQS with status diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 92468b0e..bfef5588 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -52,7 +52,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker self.print(filename) end - + def print_receipt_payment_by_foc(sale_id) #Use CUPS service #Generate PDF @@ -70,6 +70,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker #Generate PDF #Print pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info) + pdf.render_file "tmp/receipt_bill.pdf" self.print("tmp/receipt_bill.pdf") end diff --git a/app/models/sale.rb b/app/models/sale.rb index 9683c2b2..3714c21e 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -23,6 +23,8 @@ class Sale < ApplicationRecord if (booking) Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s #get all order attached to this booking and combine into 1 invoice + + puts booking.booking_orders.length booking.booking_orders.each do |order| if booking.sale_id status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by) @@ -199,7 +201,7 @@ class Sale < ApplicationRecord #tax_profile - list by order_by tax_profiles = TaxProfile.all.order("order_by asc") - #Creat new tax records + # #Creat new tax records tax_profiles.each do |tax| sale_tax = SaleTax.new(:sale => self) sale_tax.tax_name = tax.name diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index c49e9317..a999b6a8 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -30,6 +30,7 @@ class SaleItem < ApplicationRecord # end end + # Calculate food total and beverage total def self.calculate_food_beverage(sale_items) food_prices=0 beverage_prices=0 @@ -45,6 +46,7 @@ class SaleItem < ApplicationRecord return food_prices, beverage_prices end + # get food price or beverage price for item def self.get_price(sale_item_id) food_price=0 beverage_price=0 diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 465a8e5b..715c7479 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -265,13 +265,17 @@ class SalePayment < ApplicationRecord campaign_type_id = memberaction.additional_parameter["campaign_type_id"] auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, + + begin + response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, receipt_no: receipt_no,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' - }) - puts "haha" + }, :timeout => 10) + rescue Net::OpenTimeout + response = { status: false } + end puts response.to_json end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 2d67989d..6cacc391 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -11,7 +11,6 @@ class ReceiptBillPdf < Prawn::Document self.item_height = 15 self.item_description_width = (self.page_width-20) / 2 self.label_width = 100 - # @item_width = self.page_width.to_i / 2 # @qty_width = @item_width.to_i / 3 # @double = @qty_width * 1.3 @@ -36,7 +35,6 @@ class ReceiptBillPdf < Prawn::Document if member_info != nil member_info(member_info) end - footer end @@ -121,9 +119,9 @@ class ReceiptBillPdf < Prawn::Document pad_top(15) { text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size, :overflow => :shrink_to_fix - text_box "#{price.to_i}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{qty.to_i}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{total_price.to_i}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{total_price}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } move_down 3 end @@ -174,7 +172,7 @@ class ReceiptBillPdf < Prawn::Document text "#{ st.tax_name }", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "( " +"#{ st.tax_payable_amount }" +" )" , :size => self.item_font_size,:align => :right + text "#{ st.tax_payable_amount }" , :size => self.item_font_size,:align => :right end end else @@ -206,10 +204,10 @@ class ReceiptBillPdf < Prawn::Document # show member information def member_info(member_info) - + move_down 7 - if member_info["status"] == true - member_info["data"].each do |res| + if member_info["status"] == true + member_info["data"].each do |res| move_down 5 y_position = cursor @@ -219,9 +217,9 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right end - - end - end + + end + end end def footer @@ -229,7 +227,7 @@ class ReceiptBillPdf < Prawn::Document stroke_horizontal_rule move_down 5 - text "*** Thank You ***", :left_margin => -10, :size => self.header_font_size,:align => :center + text "Thank You! See you Again", :left_margin => -10, :size => self.header_font_size,:align => :center move_down 5 end diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index d806ec34..04f3acf9 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -1,26 +1,8 @@
-
+
- - - - - -
-
-

Customer Profile

@@ -51,11 +33,8 @@
-
-
-
-
+

Membership Detail

@@ -78,8 +57,22 @@ + - + + + +

Order Details

@@ -114,9 +107,8 @@
-
-

Sale Details

+

Sale Details

@@ -146,7 +138,6 @@
-
diff --git a/app/views/crm/dining_queues/_form.html.erb b/app/views/crm/dining_queues/_form.html.erb index 7f02ac15..320bac40 100644 --- a/app/views/crm/dining_queues/_form.html.erb +++ b/app/views/crm/dining_queues/_form.html.erb @@ -10,7 +10,7 @@

- <%= f.button :submit %> + <%= f.button :submit,"Create Queue" %>
<% end %> diff --git a/app/views/crm/dining_queues/assign.html.erb b/app/views/crm/dining_queues/assign.html.erb new file mode 100644 index 00000000..5de532cc --- /dev/null +++ b/app/views/crm/dining_queues/assign.html.erb @@ -0,0 +1,44 @@ + +
+
+ +
+
+
+ +
+ <%= form_tag crm_assign_table_path, :method => :post do %> + +
+ + + +
+
+ +
+ + + +
+ +
+
+
+ +
+ <% end %> +
+
+ diff --git a/app/views/crm/dining_queues/index.html.erb b/app/views/crm/dining_queues/index.html.erb index e7834b98..7050885d 100644 --- a/app/views/crm/dining_queues/index.html.erb +++ b/app/views/crm/dining_queues/index.html.erb @@ -1,38 +1,69 @@ - - -
-
- - - - - - - - - +
+
+ +
+ <% @i = 0 %> . + <% @dining_queues.each do |queue| %> +
+
" style="border:1px solid #ccc;margin-bottom: 10px "> +
+ + +

<%= @i += 1 %> . Queue No

+

<%= queue.queue_no %>

+

+ Name : <%= queue.name %>
+ Contact : <%= queue.contact_no %> +
+ Status : <%= queue.status rescue '-' %> +

+
+
+ +
+ <% end %> +
+ + +
+
+ + +
-
- <% @dining_queues.each do |dining_queue| %> - - - - - - - <% end %> - -
NameContact NoQueue NoAction
<%= dining_queue.name %><%= dining_queue.contact_no %><%= dining_queue.queue_no %> - <%= link_to 'Edit', edit_crm_dining_queue_path(dining_queue) %> | <%= link_to 'Destroy', crm_dining_queue_path(dining_queue), method: :delete, data: { confirm: 'Are you sure?' } %>
+
+ \ No newline at end of file diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index f2120cde..18e72880 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -60,6 +60,7 @@

+
@@ -133,7 +134,7 @@
-
ORDER DETAILS -
+
ORDER DETAILS - Table
@@ -159,7 +160,7 @@
- +
@@ -167,17 +168,7 @@ - - - - - - +
Items
- - - -
diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 66d65aea..ff83dad4 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -82,10 +82,10 @@
-
+
<% @booking_orders.each do |bko| - # No Show completed + # No Show completed if bko.sale_status == 'completed' next end @@ -146,7 +146,7 @@
<% @booking_rooms.each do |rmo| - # No Show completed + # No Show completed if rmo.sale_status == 'completed' next end @@ -207,8 +207,8 @@
<% - @orders.each do |odr| - # No Show completed + @orders.each do |odr| + # No Show completed if odr.sale_status == 'completed' next end @@ -289,7 +289,7 @@

Customer :

- +
@@ -300,14 +300,14 @@ - + <% # For Sale Items sub_total = 0 if @selected_item_type == "Sale" @selected_item.sale_items.each do |sale_item| sub_total += (sale_item.qty*sale_item.unit_price) - %> + %> @@ -319,7 +319,7 @@ %> <% - # For Order Items + # For Order Items if @selected_item_type == "Order" @selected_item.order_items.each do |order_item| sub_total += (order_item.qty*order_item.unit_price) @@ -354,17 +354,17 @@ - + + + +
Price
<%= sale_item.product_name %> <%= sale_item.qty %>Discount: (<%=@selected_item.total_discount rescue 0%>)
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 995e13e9..9ac19b1a 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -235,7 +235,7 @@
- +
diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index 3d7607c4..e1363d8b 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -21,7 +21,7 @@ <% end %>
- +

@@ -66,7 +66,7 @@
00
-
Nett
+
Nett
Del
Clr
@@ -129,6 +129,9 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#used_amount').text(); $('#used_amount').text(cash.substr(0,cash.length-1)); + case 'nett': + alert($('#valid_amount').text()) + $('#used_amount').text($('#valid_amount').text()); break; } diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 9d5c4f88..4dd239e7 100644 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -44,7 +44,7 @@ <%= sale.receipt_date.strftime("#{sale.receipt_date.day.ordinalize} %b") rescue '-' %> <%=sale.receipt_no.to_s rescue ''%> - <%=sale.cashier_id rescue ''%> + <%=Employee.find(sale.cashier_id).name rescue ''%> <%= number_with_delimiter(sprintf("%.2f",sale.total_amount.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",sale.total_discount.to_f), :delimiter => ',') %> <%= number_with_delimiter(sprintf("%.2f",total_sales.to_f), :delimiter => ',') %> diff --git a/app/views/settings/order_queue_stations/_form.html.erb b/app/views/settings/order_queue_stations/_form.html.erb index d54b69b9..7a2cba43 100644 --- a/app/views/settings/order_queue_stations/_form.html.erb +++ b/app/views/settings/order_queue_stations/_form.html.erb @@ -9,6 +9,7 @@ div.form-inputs span{
<%= f.input :station_name %> <%= f.input :is_active %> + <%= f.input :printer_name %> <%= f.input :font_size %> <%= f.input :print_copy %> @@ -17,7 +18,7 @@ div.form-inputs span{ <%= f.input :cut_per_item %> <%= f.input :use_alternate_name %> <%= f.input :processing_items, as: :hidden %> - + <%= f.input :auto_print %>
diff --git a/app/views/settings/order_queue_stations/index.html.erb b/app/views/settings/order_queue_stations/index.html.erb index 03da3c23..287fb10b 100644 --- a/app/views/settings/order_queue_stations/index.html.erb +++ b/app/views/settings/order_queue_stations/index.html.erb @@ -17,6 +17,7 @@ Station name Is active + Auto Print Print copy Printer name Cut per item @@ -31,6 +32,7 @@ <%= link_to settings_order_queue_station.station_name, settings_order_queue_station_path(settings_order_queue_station) %> <%= settings_order_queue_station.is_active %> + <%= settings_order_queue_station.auto_print %> <%= settings_order_queue_station.print_copy %> <%= settings_order_queue_station.printer_name %> <%= settings_order_queue_station.cut_per_item %> diff --git a/app/views/settings/order_queue_stations/show.html.erb b/app/views/settings/order_queue_stations/show.html.erb index 1a80c2c0..e92ed0bb 100644 --- a/app/views/settings/order_queue_stations/show.html.erb +++ b/app/views/settings/order_queue_stations/show.html.erb @@ -18,6 +18,11 @@ <%= @settings_order_queue_station.is_active %>

+

+ Auto Print: + <%= @settings_order_queue_station.auto_print %> +

+

Processing items: <%= @settings_order_queue_station.processing_items %> diff --git a/app/views/transactions/orders/index.html.erb b/app/views/transactions/orders/index.html.erb index 29cd001c..80befdc1 100644 --- a/app/views/transactions/orders/index.html.erb +++ b/app/views/transactions/orders/index.html.erb @@ -34,7 +34,6 @@ Order status Order date Items Count - Action @@ -42,13 +41,13 @@ <% @orders.each do |order| %> - <%= order.order_id %> + <%= link_to order.order_id, transactions_order_path(order) %> <%= order.order_type %> <%= order.customer.name rescue '-' %> <%= order.status %> <%= order.date.strftime("%d-%m-%Y") %> <%= order.item_count %> - <%= link_to 'Show', transactions_order_path(order) %> + <% end %> diff --git a/app/views/transactions/orders/show.html.erb b/app/views/transactions/orders/show.html.erb index dc5bae88..f55cec28 100644 --- a/app/views/transactions/orders/show.html.erb +++ b/app/views/transactions/orders/show.html.erb @@ -8,13 +8,18 @@

  • <%= @order.order_id %>
  • + + + Back + +

    -
    +
    @@ -46,7 +51,7 @@ - + @@ -62,7 +67,7 @@ - + @@ -70,13 +75,16 @@ <% end %>
    Qty Unit Price Total PriceOption Status Order By Created at<%= order.qty %> <%= order.price %> <%= order.qty * order.price %> <%= order.options %> <%= order.order_item_status %> <%= order.item_order_by %> <%= order.created_at.strftime("%d-%m-%Y") %>
    - - Back - +
    +
    diff --git a/app/views/transactions/sales/index.html.erb b/app/views/transactions/sales/index.html.erb index b7e73219..2f437f3c 100644 --- a/app/views/transactions/sales/index.html.erb +++ b/app/views/transactions/sales/index.html.erb @@ -36,7 +36,6 @@ Cashier Sales status Receipt Date - Action @@ -44,14 +43,13 @@ <% if @sales != 0 %> <% @sales.each do |sale| %> - <%= sale.sale_id %> + <%= link_to sale.sale_id, transactions_sale_path(sale) %> <%= sale.receipt_no %> <%= sale.grand_total rescue '-' %> <%= sale.total_tax %> <%= sale.cashier_name rescue '-' %> <%= sale.sale_status %> <%= sale.receipt_date.strftime("%d-%m-%Y") %> - <%= link_to 'Show', transactions_sale_path(sale) %> <% end %> <% else %> diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 5f6365e5..1e5cc41a 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -8,11 +8,24 @@
  • <%= @sale.sale_id %>
  • + + + Back + + + + + Void Sale + + + Complete Sale + +
    -
    +
    @@ -29,7 +42,7 @@ -
    +
    @@ -53,7 +66,7 @@ <%= @sale.receipt_no %> <%= @sale.cashier_name rescue '-' %> <%= @sale.sale_status %> - <%= @sale.requested_at.strftime("%d-%m-%Y") %> + <%= @sale.requested_at %> Sale item name @@ -82,12 +95,13 @@ Discount <%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%> + <% @sale.sale_taxes.each do |r|%> - Tax - <%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%> + <%= r.tax_name %> + <%= number_with_precision(r.tax_payable_amount, :precision => 2, :delimiter => ',') rescue ' '%> - + <% end %> Grand Total @@ -99,21 +113,24 @@ Pay Amount <%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%> - - - Change - <%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%> - + <% @sale_receivables.each do |r|%> Payment <%= r.payment_method rescue ' '%> <%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> - - + + <% end %> + + + + Change + <%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%> + + @@ -160,7 +177,61 @@
    - +
    +
    +
    +

    Customer Profile

    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    Name<%= @customer.name %>
    Email<%= @customer.email %>
    Contact no<%= @customer.contact_no %>
    Company<%= @customer.company %>
    Date Of Birth<%= @customer.date_of_birth %>
    +
    +
    +
    +
    +

    Membership Detail

    +
    + + + <% if @membership == 0 %> + + + + <% else %> + <% @membership.each do |member| %> + + + + + <% end %> + + <% end %> + +
    "There is no membership data"
    <%= member["accountable_type"] %><%= member["balance"] %>
    +
    +
    +
    @@ -168,20 +239,19 @@
    - +
    -->
    diff --git a/config/routes.rb b/config/routes.rb index 19b07979..11494743 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -124,11 +124,15 @@ Rails.application.routes.draw do post "update_booking" , to: "bookings#update_booking", as: "update_booking"#assign and cancel get '/print/:id', to: "home#print_order"#print order for crm + get "/dining_queues/:id/assign" =>"dining_queues#assign", :as => "assign" + post "/dining_queues/assign_table" =>"dining_queues#assign_table", :as => "assign_table" + end #--------- Order Queue Station ------------# namespace :oqs do root "home#index" + get "/:table_id", to: "home#get_order_items" post 'update_delivery', to: "home#update_delivery_status" diff --git a/db/migrate/20170403151731_create_order_queue_stations.rb b/db/migrate/20170403151731_create_order_queue_stations.rb index 6ad93bb1..6c327b8e 100644 --- a/db/migrate/20170403151731_create_order_queue_stations.rb +++ b/db/migrate/20170403151731_create_order_queue_stations.rb @@ -9,6 +9,7 @@ class CreateOrderQueueStations < ActiveRecord::Migration[5.1] t.integer :font_size, :null => false, :default => 10 t.boolean :cut_per_item, :null => false, :default => false t.boolean :use_alternate_name, :null => false, :default => false + t.boolean :auto_print, :null => false, :default => false t.string :created_by, :null => false t.timestamps end diff --git a/db/migrate/20170612031153_create_dining_queues.rb b/db/migrate/20170617163811_create_dining_queues.rb similarity index 81% rename from db/migrate/20170612031153_create_dining_queues.rb rename to db/migrate/20170617163811_create_dining_queues.rb index 3cf26418..d4b3eacd 100644 --- a/db/migrate/20170612031153_create_dining_queues.rb +++ b/db/migrate/20170617163811_create_dining_queues.rb @@ -5,6 +5,7 @@ class CreateDiningQueues < ActiveRecord::Migration[5.1] t.string :contact_no t.string :queue_no t.string :status + t.references :dining_facility, foreign_key: true t.timestamps end diff --git a/dump.rdb b/dump.rdb index 7202f930..211fd505 100644 Binary files a/dump.rdb and b/dump.rdb differ diff --git a/lib/tasks/clear_data.rake b/lib/tasks/clear_data.rake index 552c2a60..9d4e0ddd 100644 --- a/lib/tasks/clear_data.rake +++ b/lib/tasks/clear_data.rake @@ -11,7 +11,7 @@ namespace :clear do Sale.delete_all SaleAudit.delete_all SalePayment.delete_all - + DiningFacility.update_all(status:'available') puts "Clear Data Done." end end