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
|
||||
|
||||
@@ -1,7 +1,38 @@
|
||||
class Origami::CustomersController < BaseOrigamiController
|
||||
#Form to add customer -
|
||||
def index
|
||||
|
||||
|
||||
end
|
||||
def create
|
||||
|
||||
# GET /crm/customers/1
|
||||
# GET /crm/customers/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
|
||||
|
||||
def add_customer
|
||||
|
||||
@sale_id = params[:sale_id]
|
||||
filter = params[:filter]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("name").page(params[:page])
|
||||
else
|
||||
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page])
|
||||
end
|
||||
@crm_customer = Customer.new
|
||||
@membership = Customer.get_member_group
|
||||
if @membership["status"] == true
|
||||
@member_group = @membership["data"]
|
||||
end
|
||||
respond_to do |format|
|
||||
# format.html { render :template => "crm/customers/index" }
|
||||
format.html { render action: "index"}
|
||||
format.json { render json: @crm_customers }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -17,7 +17,12 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@booking_orders = Order.get_booking_order_table()
|
||||
@booking_rooms = Order.get_booking_order_rooms()
|
||||
@orders = Order.get_orders()
|
||||
<<<<<<< HEAD
|
||||
end
|
||||
=======
|
||||
|
||||
end
|
||||
>>>>>>> d65882ac5bcdce934116e65b66a8a3cb34965ba3
|
||||
|
||||
def item_show
|
||||
selection(params[:booking_id],1)
|
||||
@@ -45,4 +50,23 @@ class Origami::HomeController < BaseOrigamiController
|
||||
str
|
||||
end
|
||||
end
|
||||
|
||||
def update_sale_by_customer
|
||||
|
||||
sale = Sale.find(params[:sale_id])
|
||||
status = sale.update_attributes(customer_id: params[:customer_id])
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def get_customer
|
||||
@customer = Customer.find(params[:customer_id])
|
||||
|
||||
render :json => @customer.to_json
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user