Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PosController < ApplicationController
- # GET /pos
- # GET /pos.xml
- def index
- @pos = Po.find(:all)
- respond_to do |format|
- format.html # index.html.erb
- format.xml { render :xml => @pos }
- end
- end
- # GET /pos/1
- # GET /pos/1.xml
- def show
- @po = Po.find(params[:id])
- c_id = @po.account_name
- @customer = Customer.find(params[:c_id])
- ship_id = @po.shipping_id
- @shipping = Shipping.find(params[:ship_id])
- status_id = @po.status_id
- @status = Status.find(params[:status_id])
- priority_id = @po.priority_id
- @priority = Priority.find(params[:priority_id])
- respond_to do |format|
- format.html # show.html.erb
- format.xml { render :xml => @po }
- end
- end
- # GET /pos/new
- # GET /pos/new.xml
- def new
- @po = Po.new
- @po.items.build
- @shipping = Shipping.find(:all)
- @status = Status.find(:all)
- @priority = Priority.find(:all)
- @customers = Customer.find(:all)
- respond_to do |format|
- format.html # new.html.erb
- format.xml { render :xml => @po }
- end
- end
- # GET /pos/1/edit
- def edit
- @po = Po.find(params[:id])
- @shipping = Shipping.find(params[:id])
- @status = Status.find(params[:id])
- @priority = Priority.find(params[:id])
- end
- # POST /pos
- # POST /pos.xml
- def create
- @po = Po.new(params[:po])
- respond_to do |format|
- if @po.save
- flash[:notice] = 'Po was successfully created.'
- format.html { redirect_to(@po) }
- format.xml { render :xml => @po, :status => :created, :location => @po }
- else
- format.html { render :action => "new" }
- format.xml { render :xml => @po.errors, :status => :unprocessable_entity }
- end
- end
- end
- # PUT /pos/1
- # PUT /pos/1.xml
- def update
- params[:po][:existing_item_attributes] ||= {}
- @po = Po.find(params[:id])
- @shipping = Shipping.find(params[:id])
- @status = Status.find(params[:id])
- @priority = Priority.find(params[:id])
- respond_to do |format|
- if @po.update_attributes(params[:po])
- flash[:notice] = 'Po was successfully updated.'
- format.html { redirect_to(@po) }
- format.xml { head :ok }
- else
- format.html { render :action => "edit" }
- format.xml { render :xml => @po.errors, :status => :unprocessable_entity }
- end
- end
- end
- # DELETE /pos/1
- # DELETE /pos/1.xml
- def destroy
- @po = Po.find(params[:id])
- @po.destroy
- respond_to do |format|
- format.html { redirect_to(pos_url) }
- format.xml { head :ok }
- end
- end
- end
Add Comment
Please, Sign In to add comment