Loos
10 years ago
5 changed files with 60 additions and 26 deletions
@ -1,4 +1,12 @@ |
|||||
class Client < ActiveRecord::Base |
class Client < ActiveRecord::Base |
||||
has_one :bike |
has_one :bike |
||||
belongs_to :agency |
belongs_to :agency |
||||
|
|
||||
|
def self.waiting_list |
||||
|
clients = Client.all |
||||
|
non_voided_clients = clients.select{|client| !client.application_voided} |
||||
|
incomplete_clients = non_voided_clients.select{|client| !client.completion_date} |
||||
|
waiting_list = incomplete_clients.sort_by!{|client| client.application_date} |
||||
|
end |
||||
|
|
||||
end |
end |
||||
|
@ -1,24 +1,53 @@ |
|||||
.container |
.container |
||||
%h1 Clients |
.row |
||||
|
= link_to ' + New Client', new_client_path, class: "btn btn-default" |
||||
|
.row |
||||
|
%h1 Client Waiting List |
||||
|
|
||||
%table.table.table-striped.table-bordered.table-hover |
%table.table.table-striped.table-bordered.table-hover |
||||
%thead |
%thead |
||||
%tr |
|
||||
%th First Name |
|
||||
%th Last Name |
|
||||
%th Agency |
|
||||
%th |
|
||||
%th |
|
||||
%th |
|
||||
%tbody |
|
||||
- @clients.each do |client| |
|
||||
%tr |
%tr |
||||
%td= client.first_name |
%th Number |
||||
%td= client.last_name |
%th First Name |
||||
%td= client.agency.agency_name if client.agency |
%th Last Name |
||||
%td= link_to 'Show', client |
%th Application Date |
||||
%td= link_to 'Edit', edit_client_path(client) |
%th Agency |
||||
%td= link_to 'Destroy', client, method: :delete, data: { confirm: 'Are you sure?' } |
%th |
||||
|
%th |
||||
%br |
%th |
||||
= link_to ' + New Client', new_client_path, class: "btn btn-default" |
%tbody |
||||
|
- @waiting_list.each_with_index do |client, index| |
||||
|
%tr |
||||
|
%td= index + 1 |
||||
|
%td= client.first_name |
||||
|
%td= client.last_name |
||||
|
%td= client.application_date |
||||
|
%td= client.agency.agency_name if client.agency |
||||
|
%td= link_to 'Show', client |
||||
|
%td= link_to 'Edit', edit_client_path(client) |
||||
|
%td= link_to 'Destroy', client, method: :delete, data: { confirm: 'Are you sure?' } |
||||
|
|
||||
|
%br |
||||
|
.row |
||||
|
%h1 All Clients |
||||
|
|
||||
|
%table.table.table-striped.table-bordered.table-hover |
||||
|
%thead |
||||
|
%tr |
||||
|
%th First Name |
||||
|
%th Last Name |
||||
|
%th Agency |
||||
|
%th |
||||
|
%th |
||||
|
%th |
||||
|
%tbody |
||||
|
- @clients.each do |client| |
||||
|
%tr |
||||
|
%td= client.first_name |
||||
|
%td= client.last_name |
||||
|
%td= client.agency.agency_name if client.agency |
||||
|
%td= link_to 'Show', client |
||||
|
%td= link_to 'Edit', edit_client_path(client) |
||||
|
%td= link_to 'Destroy', client, method: :delete, data: { confirm: 'Are you sure?' } |
||||
|
|
||||
|
%br |
||||
|
Loading…
Reference in new issue