diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 32054b53..1df7a16e 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -880,13 +880,24 @@ $(function() { dataType: "json", success:function(result){ if (result.status) { + console.log(result) if (result.data == null){ - window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text(); + swal({ + title: "Please Open Shift !", + text: result.status, + type: "warning", + confirmButtonColor: "#DD6B55", + confirmButtonText: "Ok", + closeOnConfirm: false + }, function () { + window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text(); + }); + }else{ window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment" } } - } + } }); }); diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 623a4618..07c7428f 100755 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -314,7 +314,7 @@ tr.discount-item-row:hover { position: relative; left: 42%; top: 30%; - background-color: #d9534f; + background-color: #32ad1a; color: #fff; text-align: center; width: 200px; @@ -396,3 +396,27 @@ i.logout_icon{ color: #fff !important; background-color: #5DADE2 !important; } + +/* Start Is Member Modal */ +#is_memberModal .modal-body { + height: 200px !important; +} + +#is_memberModal .btn { + width: 80%; +} +/* End Is Member Modal */ + +/* Start iframe */ +iframe { + border: none; + overflow: hidden !important; + width: 400px; + height: 550px; +} + +#pdfModal .btn { + width: 150%; + height: 100%; +} +/* End iframe */ \ No newline at end of file diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index eb9dc653..3082687b 100755 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -143,7 +143,7 @@ class Crm::CustomersController < BaseCrmController :body => member_params, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10 ) @@ -269,7 +269,7 @@ end :body => member_params, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10 ) @@ -328,7 +328,7 @@ end :body => member_params, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10 ) diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb index e8d9615d..b123ac73 100755 --- a/app/controllers/oqs/edit_controller.rb +++ b/app/controllers/oqs/edit_controller.rb @@ -25,6 +25,13 @@ class Oqs::EditController < BaseOqsController order_item.item_order_by = current_user.name order_item.qty = qty_weight order_item.remark = remarks + if !order_item.set_menu_items.nil? + instance_item_sets = JSON.parse(order_item.set_menu_items) + instance_item_sets.each_with_index do |instance_item, instance_index| + instance_item_sets[instance_index]["quantity"] = qty_weight + end + order_item.set_menu_items = instance_item_sets.to_json + end order_item.save if ENV["SERVER_MODE"] != "cloud" #no print in cloud server diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 59da5387..8e390015 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -273,7 +273,7 @@ class Origami::DiscountsController < BaseOrigamiController auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10) rescue HTTParty::Error response = {"status": false, "message": "Can't open membership server " } diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 8c83a356..c764b92f 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -63,9 +63,9 @@ class Origami::PaymentsController < BaseOrigamiController # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate - member_info = Customer.get_member_account(customer) - current_balance = SaleAudit.paymal_search(sale_id) - # current_balance = 0 + # member_info = Customer.get_member_account(customer) + # current_balance = SaleAudit.paymal_search(sale_id) + current_balance = 0 end # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -152,8 +152,10 @@ class Origami::PaymentsController < BaseOrigamiController if customer.membership_id != nil && rebate && credit_data.nil? member_info = Customer.get_member_account(customer) - rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) - current_balance = SaleAudit.paymal_search(sale_id) + if member_info["status"] == true + rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) + current_balance = SaleAudit.paymal_search(sale_id) + end end #for card sale data diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 3bc08681..aa145b4f 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -8,9 +8,7 @@ class Origami::RequestBillsController < ApplicationController if !ShiftSale.current_shift.nil? order_id = params[:id] # order_id bk_order = BookingOrder.find_by_order_id(order_id) - puts params[:id] - puts bk_order - puts bk_order.booking_id + order = Order.find(order_id) check_booking = Booking.find_by_booking_id(bk_order.booking_id) if check_booking.sale_id.nil? @@ -29,6 +27,10 @@ class Origami::RequestBillsController < ApplicationController # Promotion Activation Promotion.promo_activate(@sale) + if order.source == "quick_service" + result = {:status=> @status, :data => @sale.sale_id } + render :json => result.to_json + end else @status = false @error_message = "No Current Open Shift for This Employee" diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb old mode 100644 new mode 100755 index 1790624a..16239750 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -77,6 +77,10 @@ class Origami::SplitBillController < BaseOrigamiController def create order_ids = params[:order_ids] + arr_order_ids = nil + if !params[:arr_order_ids].nil? + arr_order_ids = JSON.parse(params[:arr_order_ids]) + end orders = nil if !params[:orders].empty? orders = JSON.parse(params[:orders]) @@ -136,14 +140,15 @@ class Origami::SplitBillController < BaseOrigamiController order_id_count = 0 order_id = nil - order_items.each do |order_item| - order_item_count = 0 - order = Order.find(order_item["order_id"]) - if order.order_items.count == 1 - order_id = order.id - order_id_count += 1 - else - order_item_count += 1 + arr_order_ids.each do |order| + order.each do |odr| + data = Order.find(odr[0]) + if data.order_items.count == odr[1] + order_id = odr[0] + order_id_count += 1 + else + order_item_count += 1 + end end end @@ -158,10 +163,12 @@ class Origami::SplitBillController < BaseOrigamiController puts "order_id_count > 1" updated_order_id = Array.new - order_ids.each do |odr_id| - odr = Order.find(odr_id) - if odr.order_items.count > 1 - updated_order_id.push(odr_id) + arr_order_ids.each do |order| + order.each do |odr| + data = Order.find(odr[0]) + if data.order_items.count != odr[1] + updated_order_id.push(odr[0]) + end end end @@ -266,12 +273,32 @@ class Origami::SplitBillController < BaseOrigamiController end end else - # puts order_ids - if order_ids.count == 1 && order_id_count == 0 && order_item_count == 1 - BookingOrder.find_by_order_id(order_ids[0]).delete - BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]}) - order_items.each do |order_item| - update_order_item(order_ids[0], order_item) + if order_ids.count == 1 && order_item_count == 1 + if order_id_count == 0 + customer = Customer.find(params[:customer_id]) + order_type = "dine_in" + if !customer.nil? + if customer.customer_type == "Takeaway" + order_type = "takeaway" + elsif customer.customer_type == "Delivery" + order_type = "delivery" + end + end + + # begin + order = create_order(params,order_type,order_items.count,current_user) + + BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id}) + + order_items.each do |order_item| + update_order_item(order.order_id, order_item) + end + else + BookingOrder.find_by_order_id(order_ids[0]).delete + BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]}) + order_items.each do |order_item| + update_order_item(order_ids[0], order_item) + end end else customer = Customer.find(params[:customer_id]) @@ -366,4 +393,11 @@ class Origami::SplitBillController < BaseOrigamiController render :json => { status: true } end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end + end diff --git a/app/controllers/origami/voucher_controller.rb b/app/controllers/origami/voucher_controller.rb index c4b3c840..25352597 100755 --- a/app/controllers/origami/voucher_controller.rb +++ b/app/controllers/origami/voucher_controller.rb @@ -54,7 +54,7 @@ class Origami::VoucherController < BaseOrigamiController }.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10 ) rescue Net::OpenTimeout diff --git a/app/models/customer.rb b/app/models/customer.rb index 7f5a7a63..934d371f 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -34,7 +34,7 @@ class Customer < ApplicationRecord }.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10) rescue HTTParty::Error @@ -71,7 +71,7 @@ class Customer < ApplicationRecord }.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10 ) @@ -124,7 +124,7 @@ class Customer < ApplicationRecord :body => member_params, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }) rescue Net::OpenTimeout response = { status: false, message: "Server Time out" } @@ -201,7 +201,7 @@ class Customer < ApplicationRecord }.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10) rescue Net::OpenTimeout response = { "status": false , "message": "Connect To" } @@ -277,7 +277,7 @@ class Customer < ApplicationRecord }.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10) rescue Net::OpenTimeout response = { "status": false , "message": "Connect To" } @@ -312,7 +312,7 @@ class Customer < ApplicationRecord }.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10 ) diff --git a/app/models/sale.rb b/app/models/sale.rb index f0b5aeed..5d46aafc 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -884,7 +884,7 @@ def self.get_menu_item_query(order_by) "(CASE WHEN si.qty IS NOT NULL THEN SUM(si.qty) ELSE 0 END) as total_item," + "(CASE WHEN si.unit_price != mii.price THEN si.unit_price ELSE mii.price END) as unit_price," + "(CASE WHEN si.qty IS NOT NULL THEN (SUM(si.qty) * si.unit_price) ELSE 0 END) as grand_total," + - "mii.price as unit_price, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE mii.item_instance_name END) as product_name, + "mii.price as unit_price, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE CONCAT(menu_items.name,' - ',mii.item_instance_name) END) as product_name, mc.name as" + " menu_category_name,mc.id as menu_category_id, si.remark as status_type, si.price as price ") diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 1866a630..5809dc0f 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -85,7 +85,7 @@ class SalePayment < ApplicationRecord }.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10 ) rescue Net::OpenTimeout @@ -133,7 +133,7 @@ class SalePayment < ApplicationRecord auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10 ) @@ -455,7 +455,7 @@ class SalePayment < ApplicationRecord }.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10) rescue Net::OpenTimeout response = { "status": false , "message": " Connection timeout" } @@ -500,7 +500,8 @@ class SalePayment < ApplicationRecord end rebate_arr.push(data) end - + Rails.logger.debug "Rebage Response" + Rails.logger.debug rebate_arr.to_json total_amount = rebate_prices - payparcost - overall_dis if credit == 1 @@ -531,7 +532,7 @@ class SalePayment < ApplicationRecord }.to_json, :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' + 'Accept' => 'application/json; version=3' }, :timeout => 10) rescue Net::OpenTimeout response = { "status": false , "message": "Connect To" } diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 206c7a0a..604d99dd 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -491,8 +491,8 @@ class ReceiptBillA5Pdf < Prawn::Document end #individual payment per person - def individual_payment(sale_data, survey, precision, delimiter) - per_person = sale_data.grand_total.to_f / survey.total_customer.to_i + def individual_payment(sale_data, precision, delimiter) + per_person = sale_data.grand_total.to_i / sale_data.equal_persons.to_i stroke_horizontal_rule move_down line_move y_position = cursor diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index efc85c7f..fe1ee628 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -494,8 +494,8 @@ class ReceiptBillPdf < Prawn::Document end #individual payment per person - def individual_payment(sale_data, survey, precision, delimiter) - per_person = sale_data.grand_total.to_f / survey.total_customer.to_i + def individual_payment(sale_data, precision, delimiter) + per_person = sale_data.grand_total.to_i / sale_data.equal_persons.to_i stroke_horizontal_rule move_down line_move y_position = cursor diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index 3a953e81..5dcb86b0 100755 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -162,6 +162,9 @@