14
@people = Person.find(:all)
20
first, last = name.split(/ /)
22
last = nil if last == ""
24
joinSQL, condSQLs, condParams = Organization.all_join(session,{ :entity => "Person"})
25
joinSQL = "INNER JOIN organizations_people ON organizations_people.person_id = people.id INNER JOIN organizations ON organizations_people.organization_id = organizations.id #{joinSQL}"
26
joinSQL = nil if condSQLs.empty?
28
condSQLs << "people.lastname LIKE ? AND people.firstname LIKE ?"
29
condParams << (last + "%")
30
condParams << (first + "%")
32
condSQLs << "people.lastname LIKE ? OR people.firstname LIKE ?"
33
condParams << (first + "%")
34
condParams << (first + "%")
36
# people = Person.find(:all, :conditions => ["lastname LIKE ? OR firstname LIKE ?",first + "%",first+"%"], :limit => limit)
38
conditions = [condSQLs.collect{|c| "(#{c})"}.join(' AND ')] + condParams unless condSQLs.empty?
40
conditions = ["people.lastname IS NOT NULL AND people.lastname <> ''"]
42
@people = Person.find(:all, :conditions => conditions, :joins => joinSQL, :limit => limit, :order => "people.lastname ASC, people.firstname ASC")
44
@people = Person.find(:all)
16
47
respond_to do |format|
17
48
format.html # index.html.erb
18
49
format.xml { render :xml => @people }
50
format.json { render :json => @people }