get update
This commit is contained in:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user