customer search
This commit is contained in:
@@ -10,9 +10,12 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
@crm_customers = Customer.order("customer_id").page(params[:page])
|
@crm_customers = Customer.order("customer_id").page(params[:page])
|
||||||
#@products = Product.order("name").page(params[:page]).per(5)
|
#@products = Product.order("name").page(params[:page]).per(5)
|
||||||
else
|
else
|
||||||
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) end
|
@crm_customers = Customer.search(filter)
|
||||||
|
|
||||||
|
end
|
||||||
#@crm_customers = Customer.all
|
#@crm_customers = Customer.all
|
||||||
@crm_customer = Customer.new
|
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
||||||
|
@crm_customer = Customer.new
|
||||||
|
|
||||||
if flash["errors"]
|
if flash["errors"]
|
||||||
@crm_customer.valid?
|
@crm_customer.valid?
|
||||||
@@ -52,7 +55,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
|
|
||||||
memberaction = MembershipAction.find_by_membership_type("get_all_member_account")
|
memberaction = MembershipAction.find_by_membership_type("get_all_member_account")
|
||||||
merchant_uid = memberaction.merchant_account_id.to_s
|
merchant_uid = memberaction.merchant_account_id.to_s
|
||||||
auth_token = memberaction.auth_token.to_s
|
auth_token = memberaction.auth_token.to_s
|
||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,17 @@ class Origami::CustomersController < BaseOrigamiController
|
|||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
filter = params[:filter]
|
filter = params[:filter]
|
||||||
|
|
||||||
|
filter = params[:filter]
|
||||||
|
|
||||||
if filter.nil?
|
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
|
else
|
||||||
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page params[:page]
|
@crm_customers = Customer.search(filter)
|
||||||
|
|
||||||
end
|
end
|
||||||
# @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(2)
|
#@crm_customers = Customer.all
|
||||||
|
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
||||||
@crm_customer = Customer.new
|
@crm_customer = Customer.new
|
||||||
|
|
||||||
if flash["errors"]
|
if flash["errors"]
|
||||||
|
|||||||
@@ -34,12 +34,17 @@ class Customer < ApplicationRecord
|
|||||||
|
|
||||||
def self.search(search)
|
def self.search(search)
|
||||||
if search
|
if search
|
||||||
find(:all, :conditions => ['name LIKE ?', "%#{search}%"])
|
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
||||||
|
where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
|
||||||
else
|
else
|
||||||
find(:all)
|
find(:all)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# def self.search(search)
|
||||||
|
# where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
|
||||||
|
# end
|
||||||
|
|
||||||
def lastest_invoices
|
def lastest_invoices
|
||||||
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
|
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-8">
|
<div class="col-lg-7 col-md-7 col-sm-7">
|
||||||
|
|
||||||
<div class="main-box-body clearfix">
|
<div class="main-box-body clearfix">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
@@ -42,20 +42,21 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @crm_customers.each do |crm_customer| %>
|
<% if @crm_customers.count > 0 %>
|
||||||
<tr>
|
<% @crm_customers.each do |crm_customer| %>
|
||||||
<td>
|
<tr>
|
||||||
<input type="radio" style="width:20px;" value="<%= crm_customer.customer_id %>" name="checkbox" class="checkbox_check" ></td>
|
<td>
|
||||||
<td><%= crm_customer.name %></td>
|
<input type="radio" style="width:20px;" value="<%= crm_customer.customer_id %>" name="checkbox" class="checkbox_check" ></td>
|
||||||
<td><%= crm_customer.company %></td>
|
<td><%= crm_customer.name %></td>
|
||||||
<td><%= crm_customer.contact_no %></td>
|
<td><%= crm_customer.company rescue '-' %></td>
|
||||||
<td><%= crm_customer.email %></td>
|
<td><%= crm_customer.contact_no %></td>
|
||||||
<td>
|
<td><%= crm_customer.email %></td>
|
||||||
<%= link_to 'Show', crm_customer_path(crm_customer) %>
|
<td><%= link_to 'Show', crm_customer_path(crm_customer) %></td>
|
||||||
|
|
||||||
</td>
|
</tr>
|
||||||
|
<% end %>
|
||||||
</tr>
|
<%else%>
|
||||||
|
<tr><td colspan="5"><p style="text-align:center"><strong>There are no record for your search</strong></p></td></tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -66,7 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4">
|
<div class="col-lg-4 col-md-4 col-sm-4">
|
||||||
|
|
||||||
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
||||||
|
|
||||||
@@ -115,6 +116,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<%end%>
|
<%end%>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||||
|
<a href="<%= crm_customers_path%>" class="btn btn-primary btn-lg ">
|
||||||
|
Back
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -217,6 +223,3 @@ $(function() {
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
|
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
|
||||||
|
|
||||||
<% if !flash["errors"]%>
|
<% if !flash["errors"]%>
|
||||||
<%=message%>
|
<%=message%>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6">
|
<td colspan="6">
|
||||||
<%= form_tag crm_customers_path, :method => :get do %>
|
<% path ="/origami/#{@sale_id}/customers" %>
|
||||||
|
<%= form_tag path, :method => :get do %>
|
||||||
<div class="input-append form-group pull-left">
|
<div class="input-append form-group pull-left">
|
||||||
<input type="text" name="filter" placeholder="Search" class="form-control input-sm col-md-8">
|
<input type="text" name="filter" placeholder="Search" class="form-control input-sm col-md-8">
|
||||||
<button type="submit" class="btn btn-primary btn-sm">Search</button>
|
<button type="submit" class="btn btn-primary btn-sm">Search</button>
|
||||||
@@ -42,17 +43,21 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @crm_customers.each do |crm_customer| %>
|
<% if @crm_customers.count > 0 %>
|
||||||
<tr>
|
<% @crm_customers.each do |crm_customer| %>
|
||||||
<td>
|
<tr>
|
||||||
<input type="radio" style="width:20px;" value="<%= crm_customer.customer_id %>" name="checkbox" class="checkbox_check" ></td>
|
<td>
|
||||||
<td><%= crm_customer.name %></td>
|
<input type="radio" style="width:20px;" value="<%= crm_customer.customer_id %>" name="checkbox" class="checkbox_check" ></td>
|
||||||
<td><%= crm_customer.company rescue '-' %></td>
|
<td><%= crm_customer.name %></td>
|
||||||
<td><%= crm_customer.contact_no %></td>
|
<td><%= crm_customer.company rescue '-' %></td>
|
||||||
<td><%= crm_customer.email %></td>
|
<td><%= crm_customer.contact_no %></td>
|
||||||
|
<td><%= crm_customer.email %></td>
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<%else%>
|
||||||
|
<tr><td colspan="5"><p style="text-align:center"><strong>There are no record for your search</strong></p></td></tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user