Merge branch 'addorder' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-08-23 19:55:37 +06:30
7 changed files with 245 additions and 86 deletions

View File

@@ -9,13 +9,39 @@ class Origami::CustomersController < BaseOrigamiController
end
def get_customer
filter = params[:filter]
type = params[:type]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
@crm_customers = Customer.search(filter)
@crm_customers = Customer.search(filter)
# search account no from paypar
if !@crm_customers.present? && type == "card"
response = Customer.search_paypar_account_no(filter)
if response["status"] == true
@crm_customers = Customer.new
@crm_customers.name = response["customer_data"]["name"]
@crm_customers.contact_no = response["customer_data"]["phone"]
@crm_customers.email = response["customer_data"]["email"]
@crm_customers.date_of_birth = response["customer_data"]["DOB"]
@crm_customers.nrc_no = response["customer_data"]["NRC"]
@crm_customers.address = response["customer_data"]["address"]
@crm_customers.card_no = 121212
@crm_customers.paypar_account_no = filter
@crm_customers.membership_id = response["customer_data"]["id"]
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
@crm_customers.customer_type = "Dinein"
@crm_customers.tax_profiles = ["1", "2"]
@crm_customers.save
else
@crm_customers = {:status=> response["status"],:message=>response["message"] }
end
end
end
puts @crm_customers
render :json => @crm_customers.to_json
end