Signed-off-by: Ira W. Snyder <devel@irasnyder.com>
return
end
+ @maxoverduevideos = RentablePolicy.find_by_name("MaxOverdueVideos")
+ if @rentable.class == Video and @customer.overdue_videos >= @maxoverduevideos.value
+ flash[:error] = "#{@maxoverduevideos.description} LIMIT REACHED"
+ redirect_to :action => :rent_begin
+ return
+ end
+
+ @maxoverduegames = RentablePolicy.find_by_name("MaxOverdueGames")
+ if @rentable.class == Game and @customer.overdue_games >= @maxoverduegames.value
+ flash[:error] = "#{@maxoverduegames.description} LIMIT REACHED"
+ redirect_to :action => :rent_begin
+ return
+ end
+
# Check out the item
checkout = Coitem.new
checkout.customer = @customer
return game_count
end
+ def overdue_videos
+ coitems = Coitem.find_all_by_customer_id(id)
+ overdue_video_count = 0
+
+ for item in coitems
+ if item.rentable.class == Video and item.overdue?
+ overdue_video_count += 1
+ end
+ end
+
+ return overdue_video_count
+ end
+
+ def overdue_games
+ coitems = Coitem.find_all_by_customer_id(id)
+ overdue_game_count = 0
+
+ for item in coitems
+ if item.rentable.class == Game and item.overdue?
+ overdue_game_count += 1
+ end
+ end
+
+ return overdue_game_count
+ end
+
protected
def validate