From 15ecb2f306cff2808bdf635b0aba81f996dc80f6 Mon Sep 17 00:00:00 2001 From: "Ira W. Snyder" Date: Tue, 27 Nov 2007 01:02:31 -0800 Subject: [PATCH] Small Cleanups + Merchandise Search Signed-off-by: Ira W. Snyder --- app/controllers/merchandise_controller.rb | 10 +++++++++ app/views/customer/searchresults.rhtml | 20 ++++++++--------- app/views/game_policy/list.rhtml | 1 - app/views/merchandise/index.rhtml | 1 + app/views/merchandise/search.rhtml | 8 +++++++ app/views/merchandise/searchresults.rhtml | 25 ++++++++++++++++++++++ app/views/rentable_policy/list.rhtml | 11 ++++------ app/views/video_policy/list.rhtml | 1 - db/development.sqlite3 | Bin 37888 -> 37888 bytes 9 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 app/views/merchandise/search.rhtml create mode 100644 app/views/merchandise/searchresults.rhtml diff --git a/app/controllers/merchandise_controller.rb b/app/controllers/merchandise_controller.rb index 79a85dd..f819b30 100644 --- a/app/controllers/merchandise_controller.rb +++ b/app/controllers/merchandise_controller.rb @@ -52,4 +52,14 @@ class MerchandiseController < ApplicationController Merchandise.find(params[:id]).destroy redirect_to :action => 'list' end + + def search + if request.post? + @query = params[:q] + @merchandises = Merchandise.find(:all, :conditions => ["title like ?", "%#{@query[0]}%"]) + render :action => 'searchresults' + else + render :action => 'search' + end + end end diff --git a/app/views/customer/searchresults.rhtml b/app/views/customer/searchresults.rhtml index cc32efe..37d8b2e 100644 --- a/app/views/customer/searchresults.rhtml +++ b/app/views/customer/searchresults.rhtml @@ -5,21 +5,21 @@ <% else %> - - <% for column in Customer.content_columns %> - - <% end %> + + + + <% for customer in @customers %> - - <% for column in Customer.content_columns %> - - <% end %> - + + + + + - + <% end %>
Customer ID<%= column.human_name %>Customer IDNamePhoneBalance
<%=h customer.id %><%=h customer.send(column.name) %><%= link_to 'Show', :action => 'show', :id => customer %><%=h customer.id %><%=link_to customer.name.to_s, :action => 'show', :id => customer %><%=h customer.phone %><%=h number_to_currency(customer.debt) %><%= link_to "Checked Out Items", :controller => :coitem, :action => 'filterbycustomerid', :id => customer %> <%= link_to 'Edit', :action => 'edit', :id => customer %><%= link_to 'Destroy', { :action => 'destroy', :id => customer }, :confirm => 'Are you sure?', :post => true %><%= link_to 'Remove', { :action => 'destroy', :id => customer }, :confirm => 'Are you sure?', :method => :post %>
diff --git a/app/views/game_policy/list.rhtml b/app/views/game_policy/list.rhtml index 327c35d..fdcaa05 100644 --- a/app/views/game_policy/list.rhtml +++ b/app/views/game_policy/list.rhtml @@ -12,7 +12,6 @@ <%=h game_policy.description %> <%=h number_to_currency(game_policy.fee) %> <%=h game_policy.period %> Days - <%= link_to 'View', :action => 'show', :id => game_policy %> <%= link_to 'Edit', :action => 'edit', :id => game_policy %> <% end %> diff --git a/app/views/merchandise/index.rhtml b/app/views/merchandise/index.rhtml index 6950e28..1abaee6 100644 --- a/app/views/merchandise/index.rhtml +++ b/app/views/merchandise/index.rhtml @@ -3,5 +3,6 @@

Actions

diff --git a/app/views/merchandise/search.rhtml b/app/views/merchandise/search.rhtml new file mode 100644 index 0000000..142d401 --- /dev/null +++ b/app/views/merchandise/search.rhtml @@ -0,0 +1,8 @@ +

Search for a Merchandise by Name

+ +<%= start_form_tag :action => 'search' %> +<%= text_field 'q', nil %> + <%= submit_tag 'Search' %> +<%= end_form_tag %> + +
diff --git a/app/views/merchandise/searchresults.rhtml b/app/views/merchandise/searchresults.rhtml new file mode 100644 index 0000000..4a0fb5c --- /dev/null +++ b/app/views/merchandise/searchresults.rhtml @@ -0,0 +1,25 @@ +

Search Results for '<%= @query[0].to_s %>'

+ +<% if @merchandises.empty? %> +

Sorry, there were no results

+<% else %> + + + + + + + + +<% for merchandise in @merchandises %> + + + + + + + + +<% end %> +
Merchandise IDTitleQuantity RemainingPrice Per Unit
<%=h merchandise.id %><%=link_to merchandise.title.to_s, :action => 'show', :id => merchandise %><%=h merchandise.quantity %><%=h number_to_currency(merchandise.price) %><%= link_to 'Edit', :action => 'edit', :id => merchandise %><%= link_to 'Remove', { :action => 'destroy', :id => merchandise }, :confirm => 'Are you sure?', :method => :post %>
+<% end %> diff --git a/app/views/rentable_policy/list.rhtml b/app/views/rentable_policy/list.rhtml index a5be4fb..5297424 100644 --- a/app/views/rentable_policy/list.rhtml +++ b/app/views/rentable_policy/list.rhtml @@ -2,17 +2,14 @@ - <% for column in RentablePolicy.content_columns %> - - <% end %> + + <% for rentable_policy in @rentable_policies %> - <% for column in RentablePolicy.content_columns %> - - <% end %> - + + <% end %> diff --git a/app/views/video_policy/list.rhtml b/app/views/video_policy/list.rhtml index 539ca06..54acd88 100644 --- a/app/views/video_policy/list.rhtml +++ b/app/views/video_policy/list.rhtml @@ -12,7 +12,6 @@ - <% end %> diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 9e6b13058140db388a39e30a6075bbd274398624..413ba0b00cd519af6a3e4c5cd66b203da734e1c4 100644 GIT binary patch delta 162 zcmZoz!PKyVX@WFw83P3H0V$4+8aLSaSb;1?=HDP;VdmeP1ufn)Gc&OBY~o?zS@Bt~<^^r&smR6pfH*dxo`vLj^wx+X}BznfwEAv+Fn(vd0J+aYIw?r-o z?a+WW=oww41iScxKAvG233TBVZlMk?F!Dn_$vwGvXfC2Sl&$mmRDl9NkhwdDQRMp} zV8Hh@pwtrbv^^{Rb1T&CM&q>DQL78E9U342-%1QN6N8P2vBY{J5^H_rg-9if)dcaC z*h174C6HGmr!;pHr{(_sQXf^c_gS;ej*Hdk2F>3Ilik?e()DQ*Pnw^n1dl|#ih2`Tx zkx#^^AaYt_XKJpyUa3|qH7ykOf8_Wu$q>ZYFsXaZYIo+b2`=qBC*`R>W5t2C$b=g> x2-G&|VN%(M5lzakw)%Q~HC1Wc@U+~Bpk`A8mi1Xq<2X~`U=A8G?e%zk^ap*jiOT>0 -- 2.25.1
<%= column.human_name %>DescriptionQuantity
<%=h rentable_policy.send(column.name) %><%= link_to 'View', :action => 'show', :id => rentable_policy %><%=h rentable_policy.description %><%=h rentable_policy.value %> <%= link_to 'Edit', :action => 'edit', :id => rentable_policy %>
<%=h video_policy.description %> <%=h number_to_currency(video_policy.fee) %> <%=h video_policy.period %> Days<%= link_to 'View', :action => 'show', :id => video_policy %> <%= link_to 'Edit', :action => 'edit', :id => video_policy %>