Skip to content

Commit

Permalink
Work Orders
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Byron committed Nov 28, 2009
1 parent 9856c49 commit 8610d7a
Show file tree
Hide file tree
Showing 22 changed files with 449 additions and 292 deletions.
6 changes: 5 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class UsersController < ApplicationController
# render new.rhtml

def index
@users = User.all
end

def new
@user = User.new
end
Expand Down
68 changes: 68 additions & 0 deletions app/controllers/work_orders_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
class WorkOrdersController < ApplicationController
# GET /work_orders
# GET /work_orders.xml
def index
@work_orders = WorkOrder.all
end

# GET /work_orders/1
# GET /work_orders/1.xml
def show
@work_order = WorkOrder.find(params[:id])
end

# GET /work_orders/new
# GET /work_orders/new.xml
def new
@work_order = WorkOrder.new
end

# GET /work_orders/1/edit
def edit
@work_order = WorkOrder.find(params[:id])
end

# POST /work_orders
# POST /work_orders.xml
def create
@work_order = WorkOrder.new(params[:work_order])

# @work_order.status =

respond_to do |format|
if @work_order.save
format.html { redirect_to thank_you_path }
else
format.html { render :action => "new" }
end
end
end

# PUT /work_orders/1
# PUT /work_orders/1.xml
def update
@work_order = WorkOrder.find(params[:id])

respond_to do |format|
if @work_order.update_attributes(params[:work_order])
flash[:notice] = 'WorkOrder was successfully updated.'
format.html { redirect_to(@work_order) }
else
format.html { render :action => "edit" }
end
end
end

def thank_you
render :layout => 'entry'
end

# DELETE /work_orders/1
# DELETE /work_orders/1.xml
def destroy
@work_order = WorkOrder.find(params[:id])
@work_order.destroy

redirect_to work_orders_url
end
end
2 changes: 2 additions & 0 deletions app/helpers/work_orders_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module WorkOrdersHelper
end
3 changes: 3 additions & 0 deletions app/models/note.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Note < ActiveRecord::Base
belongs_to :work_order
end
3 changes: 3 additions & 0 deletions app/models/status.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Status < ActiveRecord::Base
has_many :work_orders
end
4 changes: 4 additions & 0 deletions app/models/work_order.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class WorkOrder < ActiveRecord::Base
has_many :notes
belongs_to :status
end
8 changes: 4 additions & 4 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
<div id='header'>
<%= image_tag 'prabums_icon.png' %><h1>prabums</h1>
</div>
<div id="top_navigation"><%= render :partial => 'users/user_bar' %></div><%= navigation [:users, :buildings] %>
<div id="top_navigation"><%= render :partial => 'users/user_bar' %></div><%= navigation [:work_orders, :users, :buildings] %>
<div id='contents'>
<%= yield %>
<div id="footer">
<%= version %><%= link_to image_tag('DSS.png'), "http://www.ducksoupsoftware.com", :popup => true %>
</div>
</div>
</div>
<div id="footer">
<%= version %><%= image_tag 'DSS.png' %>
</div>
</div>
</body>
</html>
29 changes: 29 additions & 0 deletions app/views/layouts/entry.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title><%= yield(:title) %></title>

<!-- Defaults -->
<%= javascript_include_tag :defaults %>
<%= stylesheet_link_tag 'default' %>
</head>
<body>
<div id='outer_container'>
<div id='container'>
<div id='header'>
<%= image_tag 'prabums_icon.png' %><h1>prabums</h1>
</div>
<div id='contents'>
<%= yield %>
<div id="footer">
<%= version %><%= link_to image_tag('DSS.png'), "http://www.ducksoupsoftware.com", :popup => true %>
</div>
</div>
</div>
</div>
</body>
</html>
5 changes: 5 additions & 0 deletions app/views/users/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% title 'Users' %>
<% header do %>
<h1>Users</h1>
<% end %>
48 changes: 48 additions & 0 deletions app/views/work_orders/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<h1>Editing work_order</h1>

<% form_for(@work_order) do |f| %>
<%= f.error_messages %>

<p>
<%= f.label :first_name %><br />
<%= f.text_field :first_name %>
</p>
<p>
<%= f.label :last_name %><br />
<%= f.text_field :last_name %>
</p>
<p>
<%= f.label :phone_number %><br />
<%= f.text_field :phone_number %>
</p>
<p>
<%= f.label :building_id %><br />
<%= f.text_field :building_id %>
</p>
<p>
<%= f.label :room_number %><br />
<%= f.text_field :room_number %>
</p>
<p>
<%= f.label :email %><br />
<%= f.text_field :email %>
</p>
<p>
<%= f.label :location_of_problem %><br />
<%= f.text_field :location_of_problem %>
</p>
<p>
<%= f.label :problem %><br />
<%= f.text_area :problem %>
</p>
<p>
<%= f.label :status_id %><br />
<%= f.text_field :status_id %>
</p>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>
<%= link_to 'Show', @work_order %> |
<%= link_to 'Back', work_orders_path %>
40 changes: 40 additions & 0 deletions app/views/work_orders/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<% title 'Work Orders' %>
<% header do %>
<h1>Work Orders</h1>
<% end %>

<table>
<tr>
<th>First name</th>
<th>Last name</th>
<th>Phone number</th>
<th>Building</th>
<th>Room number</th>
<th>Email</th>
<th>Location of problem</th>
<th>Problem</th>
<th>Status</th>
</tr>

<% @work_orders.each do |work_order| %>
<tr>
<td><%=h work_order.first_name %></td>
<td><%=h work_order.last_name %></td>
<td><%=h work_order.phone_number %></td>
<td><%=h work_order.building_id %></td>
<td><%=h work_order.room_number %></td>
<td><%=h work_order.email %></td>
<td><%=h work_order.location_of_problem %></td>
<td><%=h work_order.problem %></td>
<td><%=h work_order.status_id %></td>
<td><%= link_to 'Show', work_order %></td>
<td><%= link_to 'Edit', edit_work_order_path(work_order) %></td>
<td><%= link_to 'Destroy', work_order, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'New work_order', new_work_order_path %>
52 changes: 52 additions & 0 deletions app/views/work_orders/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<% title 'New Work Order'%>
<% header do %>
<h1>New Work Order</h1>
<% end %>
<% form_for(@work_order) do |f| %>
<%= f.error_messages %>
<div class="column_1">
<p>
<%= f.label :first_name %><br />
<%= f.text_field :first_name %>
</p>
<p>
<%= f.label :building_id %><br />
<%= f.select :building_id, Building.all.collect {|b| [b.name, b.id] } %>
</p>
</div>
<div class="column_2">
<p>
<%= f.label :last_name %><br />
<%= f.text_field :last_name %>
</p>
<p>
<%= f.label :room_number %><br />
<%= f.text_field :room_number %>
</p>
</div>
<div class="column_3">
<p>
<%= f.label :phone_number %><br />
<%= f.text_field :phone_number %>
</p>
<p>
<%= f.label :email %><br />
<%= f.text_field :email %>
</p>
</div>
<div style="clear:both;">
<p>
<%= f.label :location_of_problem %><br />
<%= f.text_field :location_of_problem %>
</p>
<p>
<%= f.label :problem %><br />
<%= f.text_area :problem %>
</p>
</div>
<div class="footer">
<%= f.submit 'Submit Work Order' %> <%= link_to_function 'Reset', "$('new_work_order').reset();" %>
</div>
<% end %>
48 changes: 48 additions & 0 deletions app/views/work_orders/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<p>
<b>First name:</b>
<%=h @work_order.first_name %>
</p>

<p>
<b>Last name:</b>
<%=h @work_order.last_name %>
</p>

<p>
<b>Phone number:</b>
<%=h @work_order.phone_number %>
</p>

<p>
<b>Building:</b>
<%=h @work_order.building_id %>
</p>

<p>
<b>Room number:</b>
<%=h @work_order.room_number %>
</p>

<p>
<b>Email:</b>
<%=h @work_order.email %>
</p>

<p>
<b>Location of problem:</b>
<%=h @work_order.location_of_problem %>
</p>

<p>
<b>Problem:</b>
<%=h @work_order.problem %>
</p>

<p>
<b>Status:</b>
<%=h @work_order.status_id %>
</p>


<%= link_to 'Edit', edit_work_order_path(@work_order) %> |
<%= link_to 'Back', work_orders_path %>
11 changes: 11 additions & 0 deletions app/views/work_orders/thank_you.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% title 'Work Order Submitted' %>
<% header do %>
<h1>Work Order Submitted</h1>
<% end %>

<h1>Your work order request has been submitted.</h1>
<h2>Someone will contact you shortly ...</h2>
<p>
<%= link_to "Submit another work order", home_path %>
</p>
9 changes: 9 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
ActionController::Routing::Routes.draw do |map|
map.resources :notes

map.resources :statuses

map.home '/', :controller => :work_orders, :action => :new
map.thank_you '/thank_you', :controller => :work_orders, :action => :thank_you

map.resources :work_orders

map.resources :buildings


Expand Down
21 changes: 21 additions & 0 deletions db/migrate/20091128185531_create_work_orders.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class CreateWorkOrders < ActiveRecord::Migration
def self.up
create_table :work_orders do |t|
t.string :first_name
t.string :last_name
t.string :phone_number
t.integer :building_id
t.string :room_number
t.string :email
t.string :location_of_problem
t.text :problem
t.integer :status_id

t.timestamps
end
end

def self.down
drop_table :work_orders
end
end
Loading

0 comments on commit 8610d7a

Please sign in to comment.