render :action => 'overdue'
end
+ def filterbycustomerid
+ query = params[:id]
+ @coitem_pages, @coitems = paginate :coitems, :per_page => 20, :conditions => ["customer_id = ?", query]
+ render :action => 'list'
+ end
+
def return
if request.post?
rentable_id = params[:rentable_id]
class Game < Rentable
+ has_many :game_genres, :through => Gamegenre
+ has_many :gameplatforms, :through => Gameplatform
+
validates_presence_of :game_genre
validates_presence_of :platform
return Time.now.advance(:days => period).to_date
end
+ def genre_name
+ Gamegenre.find_by_id(game_genre).name
+ end
+
+ def platform_name
+ Gameplatform.find_by_id(platform).name
+ end
+
end
class Gamegenre < ActiveRecord::Base
+ belongs_to :game
end
class Gameplatform < ActiveRecord::Base
+ belongs_to :game
end
<table border="1">
<tr>
+ <th>Item ID</th>
<th>Customer</th>
+ <th>Type</th>
<th>Rentable</th>
<th>Overdue</th>
<th>Date Checked Out</th>
<% for coitem in @coitems %>
<tr>
+ <td><%=h coitem.rentable.id.to_s %></td>
<td><%=h coitem.customer.name %></td>
- <td><%=h coitem.rentable.title %></td>
+ <td><%=h coitem.rentable.class %></td>
+ <% if coitem.rentable.type == Game %>
+ <td><%=link_to coitem.rentable.title.to_s, :controller => 'game', :action => 'show', :id => coitem.rentable %></td>
+ <% else %>
+ <td><%=link_to coitem.rentable.title.to_s, :controller => 'video', :action => 'show', :id => coitem.rentable %></td>
+ <% end %>
<td><%=h tf_to_yesno(coitem.overdue?) %></td>
<td><%=h coitem.out_date %></td>
<td><%=h coitem.due_date %></td>
- <td><%= link_to 'View', :action => 'show', :id => coitem %></td>
</tr>
<% end %>
</table>
<table border="1">
<tr>
+ <th>Item ID</th>
<th>Customer</th>
<th>Customer Phone #</th>
<th>Customer Email</th>
<% for coitem in @coitems %>
<tr>
+ <td><%=h coitem.rentable.id.to_s %></td>
<td><%=link_to coitem.customer.name, :controller => 'customer', :action => 'show', :id => coitem.customer.id %></td>
<td><%=h coitem.customer.phone %></td>
<td><%=h coitem.customer.email %></td>
<table border="1">
<tr>
- <th>Customer ID</th>
- <% for column in Customer.content_columns %>
- <th><%= column.human_name %></th>
- <% end %>
+ <th>Customer ID</th>
+ <th>Name</th>
+ <th>Phone</th>
+ <th>Debt</th>
</tr>
<% for customer in @customers %>
<tr>
- <td><%=h customer.id %></td>
- <% for column in Customer.content_columns %>
- <td><%=h customer.send(column.name) %></td>
- <% end %>
- <td><%= link_to 'View', :action => 'show', :id => customer %></td>
+ <td><%=h customer.id %></td>
+ <td><%=link_to customer.name.to_s, :action => 'show', :id => customer %></td>
+ <td><%=h customer.phone %></td>
+ <td><%=h number_to_currency(customer.debt) %></td>
+ <td><%= link_to "Checked Out Items", :controller => :coitem, :action => 'filterbycustomerid', :id => customer %></td>
<td><%= link_to 'Edit', :action => 'edit', :id => customer %></td>
<td><%= link_to 'Remove', { :action => 'destroy', :id => customer }, :confirm => 'Are you sure?', :method => :post %></td>
</tr>
-<% for column in Game.content_columns %>
-<p>
- <b><%= column.human_name %>:</b> <%=h @game.send(column.name) %>
-</p>
-<% end %>
+<p><b>Game ID:</b> <%=h @game.id.to_s %></p>
+<p><b>Title:</b> <%=h @game.title %></p>
+<p><b>New Release:</b> <%=h tf_to_yesno(@game.newrelease) %></p>
+<p><b>Genre:</b> <%=h @game.genre_name %></p>
+<p><b>Platform:</b> <%=h @game.platform_name %></p>
+
<%= link_to 'Edit', :action => 'edit', :id => @game %> |
<%= link_to 'Back', :action => 'list' %>
-<h1>Game Rental Policies</h1>
+<h1>Game Rental Pricing and Policies</h1>
<table border="1">
<tr>
- <% for column in GamePolicy.content_columns %>
- <th><%= column.human_name %></th>
- <% end %>
+ <th>Description</th>
+ <th>Fee</th>
+ <th>Period</th>
</tr>
<% for game_policy in @game_policies %>
<tr>
- <% for column in GamePolicy.content_columns %>
- <td><%=h game_policy.send(column.name) %></td>
- <% end %>
+ <td><%=h game_policy.description %></td>
+ <td><%=h number_to_currency(game_policy.fee) %></td>
+ <td><%=h game_policy.period %> Days</td>
<td><%= link_to 'View', :action => 'show', :id => game_policy %></td>
<td><%= link_to 'Edit', :action => 'edit', :id => game_policy %></td>
</tr>
<%= link_to 'Previous page', { :page => @game_policy_pages.current.previous } if @game_policy_pages.current.previous %>
<%= link_to 'Next page', { :page => @game_policy_pages.current.next } if @game_policy_pages.current.next %>
-<br />
-
-<%= link_to 'New game_policy', :action => 'new' %>
<tr>
<td><%=link_to purchase.date, :action => 'filterbydate', :id => purchase.date %></td>
<td><%=h purchase.quantity %></td>
- <td><%=link_to purchase.type, :action => 'filterbytype', :id => purchase.type %></td>
+ <td><%=link_to purchase.class, :action => 'filterbytype', :id => purchase.type %></td>
<td><%=h purchase.title %></td>
<td><%=h purchase.price %></td>
<td><%=link_to purchase.customer.name, :action => 'filterbycust', :id => purchase.customer_id %></td>
-<% for column in Video.content_columns %>
-<p>
- <b><%= column.human_name %>:</b> <%=h @video.send(column.name) %>
-</p>
-<% end %>
+<p><b>Video ID:</b> <%=h @video.id.to_s %></p>
+<p><b>Title:</b> <%=h @video.title %></p>
+<p><b>New Release:</b> <%=h tf_to_yesno(@video.newrelease) %></p>
+<p><b>Genre:</b> <%=h @video.genre %></p>
+<p><b>Director:</b> <%=h @video.director %></p>
+<p><b>Media:</b> <%=h @video.media_name %></p>
<%= link_to 'Edit', :action => 'edit', :id => @video %> |
<%= link_to 'Back', :action => 'list' %>
-<h1>Video Rental Policies</h1>
+<h1>Video Rental Pricing and Policies</h1>
<table border="1">
<tr>
- <% for column in VideoPolicy.content_columns %>
- <th><%= column.human_name %></th>
- <% end %>
+ <th>Description</th>
+ <th>Fee</th>
+ <th>Period</th>
</tr>
<% for video_policy in @video_policies %>
<tr>
- <% for column in VideoPolicy.content_columns %>
- <td><%=h video_policy.send(column.name) %></td>
- <% end %>
+ <td><%=h video_policy.description %></td>
+ <td><%=h number_to_currency(video_policy.fee) %></td>
+ <td><%=h video_policy.period %>Days</td>
<td><%= link_to 'View', :action => 'show', :id => video_policy %></td>
<td><%= link_to 'Edit', :action => 'edit', :id => video_policy %></td>
</tr>
<%= link_to 'Previous page', { :page => @video_policy_pages.current.previous } if @video_policy_pages.current.previous %>
<%= link_to 'Next page', { :page => @video_policy_pages.current.next } if @video_policy_pages.current.next %>
-<br />
-
-<%= link_to 'New video_policy', :action => 'new' %>