From 6945449523d0247d159cf0f8a24fb274d631bd93 Mon Sep 17 00:00:00 2001 From: Nweni Date: Mon, 12 Jun 2017 18:51:02 +0630 Subject: [PATCH] get update --- Gemfile | 2 +- Gemfile.lock | 2 ++ app/controllers/crm/customers_controller.rb | 18 +++++++------- app/models/order.rb | 27 ++++++++++----------- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Gemfile b/Gemfile index b08df141..02dca6af 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,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 6a7c6340..4235d035 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -110,6 +110,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) @@ -246,6 +247,7 @@ DEPENDENCIES kaminari (~> 0.16.3) listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) + pg prawn prawn-table puma (~> 3.0) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 01acd441..ad3bcc50 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -5,7 +5,7 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers.json def index filter = params[:filter] - + if filter.nil? @crm_customers = Customer.order("customer_id").page(params[:page]) #@products = Product.order("name").page(params[:page]).per(5) @@ -31,7 +31,7 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers/1.json def show @orders = Order.where("customer_id=?", params[:id]) - + if @orders @order_items = [] @orders.each do |bo| @@ -57,7 +57,7 @@ class Crm::CustomersController < BaseCrmController def create @crm_customers = Customer.new(customer_params) - + respond_to do |format| if @crm_customers.save name = customer_params[:name] @@ -72,7 +72,7 @@ class Crm::CustomersController < BaseCrmController url = membership.gateway_url.to_s + memberaction.gateway_url.to_s response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, - date_of_birth: date_of_birth, + dob: date_of_birth, member_group_id: member_group_id,merchant_uid:merchant_uid}.to_json, :headers => { 'Content-Type' => 'application/json', @@ -81,18 +81,18 @@ class Crm::CustomersController < BaseCrmController ) if response["status"] == true - + customer = Customer.find(@crm_customers.customer_id) status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) - + if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' } else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} - end + end # format.json { render :index, status: :created, location: @crm_customers } else - + @crm_customers.destroy if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} @@ -103,7 +103,7 @@ class Crm::CustomersController < BaseCrmController else if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'} else format.html { redirect_to crm_customers_path} format.json { render json: @crm_customers.errors, status: :unprocessable_entity } diff --git a/app/models/order.rb b/app/models/order.rb index 5a4d6e2d..20d9a7f0 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -244,21 +244,20 @@ 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'") -<<<<<<< HEAD - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") end - #Origami: Cashier : to view booking order Table - def self.get_booking_order_table - booking_orders = Booking.select("sales.receipt_no,orders.status as order_status, - bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") - .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") - .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - .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' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id,sales.customer_id,orders.order_id") - end + # #Origami: Cashier : to view booking order Table + # def self.get_booking_order_table + # booking_orders = Booking.select("sales.receipt_no,orders.status as order_status, + # bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") + # .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") + # .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") + # .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' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) + # .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.customer_id,sales.customer_id,orders.order_id") + # end #Origami: Cashier : to view order type Room def self.get_booking_order_rooms @@ -272,7 +271,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("sales.sale_status<>'completed' and sales.sale_status<>'complete' and booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id") end #Origami: Cashier : to view order type Room