From c461cb94f2c0dd611b20077b319378de5495aa7f Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 6 Jun 2017 11:08:43 +0630 Subject: [PATCH 1/2] fixed --- Gemfile | 2 +- Gemfile.lock | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index bcbebe51..548c0ec4 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -# gem 'pg' + gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index badb3aa4..c776f86a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -119,6 +119,7 @@ GEM nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) + pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -252,6 +253,7 @@ DEPENDENCIES kaminari! listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) + pg prawn prawn-table puma (~> 3.0) From b847cde62c1b506c3d07bfdd7c6af780765638f8 Mon Sep 17 00:00:00 2001 From: Nweni Date: Tue, 6 Jun 2017 14:03:21 +0630 Subject: [PATCH 2/2] sale query updated --- app/controllers/origami/request_bills_controller.rb | 4 ++-- app/models/order.rb | 8 ++++---- app/views/origami/home/index.html.erb | 12 ++++++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 3fd7ffea..31766599 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -14,7 +14,7 @@ class Origami::RequestBillsController < BaseOrigamiController else @sale_data = Sale.find_by_sale_id(check_booking.sale_id) @sale_items = SaleItem.where("sale_id=?",check_booking.sale_id) - end + end unique_code="ReceiptBillPdf" @@ -30,7 +30,7 @@ class Origami::RequestBillsController < BaseOrigamiController def show sale_id = params[:sale_id] if Sale.exists?(sale_id) - @sale_data = Sale.find_by_id(sale_id) + @sale_data = Sale.find_by_sale_id(sale_id) end end diff --git a/app/models/order.rb b/app/models/order.rb index e2548906..036f9006 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -230,7 +230,7 @@ class Order < ApplicationRecord .joins("left join sale_orders on sale_orders.order_id = orders.order_id") .joins("left join sales on sales.sale_id = sale_orders.sale_id") .where("booking_orders.order_id IS NOT NULL 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") end @@ -243,7 +243,7 @@ class Order < ApplicationRecord .joins("left join sale_orders on sale_orders.order_id = orders.order_id") .joins("left join sales on sales.sale_id = sale_orders.sale_id") .where("booking_orders.order_id IS NOT NULL 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") end #Origami: Cashier : to view order type Room @@ -255,7 +255,7 @@ class Order < ApplicationRecord left join dining_facilities on dining_facilities.id = bookings.dining_facility_id left join order_items on order_items.order_id = orders.order_id") .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true) - .group("orders.order_id,order_items.order_items_id,dining_facilities.name") + .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no") end @@ -271,7 +271,7 @@ class Order < ApplicationRecord left join sale_orders on sale_orders.order_id = orders.order_id left join sales on sales.sale_id = sale_orders.sale_id") .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) - .group("orders.order_id,order_items.order_items_id,dining_facilities.name") + .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id") end private diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index cc8d2041..78f59422 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -25,7 +25,7 @@ <% if @booking_orders %> <% @booking_orders.each do |booking_order| %> - <% if !booking_order.order_status = 'new'%> + <% if booking_order.order_status != "new" %>

@@ -204,14 +204,17 @@ var old_order_id = 0 var old_table_name = "" var table_or_order_id = 0 - + var pay_sale_id = 0 function callOrderDetails(sale_order_id){ + var order_id = 0 + var sale_id = 0 var data_val = "" sale_order = sale_order_id.split("_")[0] + if (sale_order == 'sale') { - order_id = sale_order_id.split("_")[1] + sale_id = sale_order_id.split("_")[1] url = "origami/"+sale_order_id.split("_")[1] data_val = { sale_id: sale_order_id.split("_")[1]} @@ -222,6 +225,7 @@ function callOrderDetails(sale_order_id){ } table_or_order_id = order_id + pay_sale_id = sale_id var tbody = "" $("#append-table").html("") if (old_order_id != order_id){ @@ -312,7 +316,7 @@ $( document ).ready(function() { $( document ).ready(function() { $('#pay').click(function() { - window.location.href = '/origami/sale/'+ 10 + "/payment" + window.location.href = '/origami/sale/'+ pay_sale_id + "/payment" return false; }); });