diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb
index 518f4e33..ae6820df 100644
--- a/app/controllers/crm/customers_controller.rb
+++ b/app/controllers/crm/customers_controller.rb
@@ -14,9 +14,9 @@ class Crm::CustomersController < BaseCrmController
#@crm_customers = Customer.all
@crm_customer = Customer.new
-
- # puts @crm_customer.valid?
-
+ if flash["errors"]
+ @crm_customer.valid?
+ end
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
@@ -104,7 +104,9 @@ class Crm::CustomersController < BaseCrmController
else
if params[:sale_id]
+ flash[:errors] = @crm_customers.errors
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
+ format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
else
flash[:errors] = @crm_customers.errors
format.html { redirect_to crm_customers_path}
@@ -148,7 +150,8 @@ end
else
- format.html { render :index }
+ flash[:errors] = @crm_customers.errors
+ format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
end
diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb
index 14af5f49..7d0b5502 100644
--- a/app/controllers/origami/customers_controller.rb
+++ b/app/controllers/origami/customers_controller.rb
@@ -24,12 +24,10 @@ class Origami::CustomersController < BaseOrigamiController
end
# @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(2)
@crm_customer = Customer.new
- # @membership = Customer.get_member_group
- # if @membership["status"] == true
- # @member_group = @membership["data"]
- # end
- # puts "Errrrrrrrrrrrrrrrrr"
- # puts @crm_customer.valid?
+
+ if flash["errors"]
+ @crm_customer.valid?
+ end
respond_to do |format|
diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb
index 04ba5e32..ba36500c 100644
--- a/app/views/crm/customers/index.html.erb
+++ b/app/views/crm/customers/index.html.erb
@@ -75,9 +75,7 @@
<%= f.input :name, :class => "form-control col-md-6 name" %>
- <% if flash[:errors] && !flash[:errors].empty? then -%>
- <%= flash[:errors]["name"] %>
- <% end -%>
+
@@ -85,16 +83,12 @@
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
- <% if flash[:errors] && !flash[:errors].empty? then -%>
- <%= flash[:errors]["contact_no"] %>
- <% end -%>
+
<%= f.input :email, :class => "form-control col-md-6 email" %>
- <% if flash[:errors] && !flash[:errors].empty? then -%>
- <%= flash[:errors]["email"] %>
- <% end -%>
+
@@ -110,9 +104,7 @@
<%= member.name %>
<%end %>
- <% if flash[:errors] && !flash[:errors].empty? then -%>
- <%= flash[:errors]["member_group_id"] %>
- <% end -%>
+
diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb
index fb851d68..42b559e2 100644
--- a/app/views/layouts/CRM.html.erb
+++ b/app/views/layouts/CRM.html.erb
@@ -19,7 +19,10 @@
<% flash.each do |type, message| %>
- <%= message %>
+
+ <% if !flash["errors"]%>
+ <%=message%>
+ <% end %>
<% end %>
<%= yield %>
diff --git a/app/views/layouts/origami.html.erb b/app/views/layouts/origami.html.erb
index ef5f3789..179d9ae1 100644
--- a/app/views/layouts/origami.html.erb
+++ b/app/views/layouts/origami.html.erb
@@ -17,10 +17,13 @@
<%= render 'layouts/header_orgiami' %>
<% flash.each do |type, message| %>
-
-
- <%= message %>
-
+ <% if !flash["errors"]%>
+
+
+ <%=message%>
+
+ <% end %>
+
<% end %>
<%= yield %>
diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb
index 80150220..f7b4a692 100644
--- a/app/views/origami/customers/index.html.erb
+++ b/app/views/origami/customers/index.html.erb
@@ -78,25 +78,17 @@
<%= f.input :name, :class => "form-control col-md-6 name" %>
- <% if flash[:errors] && !flash[:errors].empty? then -%>
- <%= flash[:errors]["name"] %>
- <% end -%>
+
<%= f.input :company, :class => "form-control col-md-6 company" %>
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
- <% if flash[:errors] && !flash[:errors].empty? then -%>
- <%= flash[:errors]["contact_no"] %>
- <% end -%>
- <%= f.input :email, :class => "form-control col-md-6 email" %>
- <% if flash[:errors] && !flash[:errors].empty? then -%>
- <%= flash[:errors]["email"] %>
- <% end -%>
+ <%= f.input :email, :class => "form-control col-md-6 email" %>
@@ -111,11 +103,7 @@
<%end %>
-
- <% if flash[:errors] && !flash[:errors].empty? then -%>
- <%= flash[:errors]["member_group_id"] %>
- <% end -%>
-
+