merge with crm
This commit is contained in:
@@ -4,21 +4,23 @@ class Crm::CustomersController < BaseCrmController
|
||||
# GET /crm/customers
|
||||
# GET /crm/customers.json
|
||||
def index
|
||||
@sale_id = 0
|
||||
filter = params[:filter]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("name").page(params[:page])
|
||||
@crm_customers = Customer.order("customer_id").page(params[:page])
|
||||
#@products = Product.order("name").page(params[:page]).per(5)
|
||||
else
|
||||
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page])
|
||||
end
|
||||
#@crm_customers = Customer.all
|
||||
@crm_customer = Customer.new
|
||||
@membership = Customer.get_member_group
|
||||
if @membership["status"] == true
|
||||
@member_group = @membership["data"]
|
||||
end
|
||||
@crm_customer = Customer.new
|
||||
@crm_customer.valid?
|
||||
|
||||
|
||||
# @membership = Customer.get_member_group
|
||||
# if @membership["status"] == true
|
||||
# @member_group = @membership["data"]
|
||||
# end
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @crm_customers }
|
||||
@@ -49,8 +51,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
respond_to do |format|
|
||||
if @crm_customers.save
|
||||
|
||||
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
@@ -71,40 +71,37 @@ class Crm::CustomersController < BaseCrmController
|
||||
}
|
||||
)
|
||||
|
||||
if response["status"] == true
|
||||
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] != 0
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' }
|
||||
|
||||
if params[:sale_id].nil?
|
||||
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer', notice: 'Customer was successfully created.' }
|
||||
else
|
||||
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: 'Customer was successfully created.' }
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' }
|
||||
end
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
|
||||
|
||||
@crm_customers.destroy
|
||||
|
||||
if params[:sale_id] != 0
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
|
||||
if params[:sale_id].nil?
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
|
||||
else
|
||||
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] }
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
|
||||
else
|
||||
if params[:sale_id] != 0
|
||||
format.html { redirect_to crm_customers_path}
|
||||
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
|
||||
|
||||
else
|
||||
format.html { redirect_to '/crm/customers/'+params[:sale_id]+'/assign_sale_id', notice: response["message"] }
|
||||
end
|
||||
|
||||
|
||||
if params[:sale_id].nil?
|
||||
|
||||
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 }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -161,7 +158,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
# DELETE /crm/customers/1
|
||||
# DELETE /crm/customers/1.json
|
||||
def get_sale_id
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
@crm_customers = Customer.all
|
||||
@crm_customer = Customer.new
|
||||
@@ -184,6 +180,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def customer_params
|
||||
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth, :membership_type, :membership_authentication_code)
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user