Guest User

Untitled

a guest
May 24th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. class PosController < ApplicationController
  2. # GET /pos
  3. # GET /pos.xml
  4. def index
  5. @pos = Po.find(:all)
  6. respond_to do |format|
  7. format.html # index.html.erb
  8. format.xml { render :xml => @pos }
  9. end
  10. end
  11.  
  12. # GET /pos/1
  13. # GET /pos/1.xml
  14. def show
  15. @po = Po.find(params[:id])
  16. c_id = @po.account_name
  17. @customer = Customer.find(params[:c_id])
  18. ship_id = @po.shipping_id
  19. @shipping = Shipping.find(params[:ship_id])
  20. status_id = @po.status_id
  21. @status = Status.find(params[:status_id])
  22. priority_id = @po.priority_id
  23. @priority = Priority.find(params[:priority_id])
  24. respond_to do |format|
  25. format.html # show.html.erb
  26. format.xml { render :xml => @po }
  27. end
  28. end
  29.  
  30. # GET /pos/new
  31. # GET /pos/new.xml
  32. def new
  33. @po = Po.new
  34. @po.items.build
  35. @shipping = Shipping.find(:all)
  36. @status = Status.find(:all)
  37. @priority = Priority.find(:all)
  38. @customers = Customer.find(:all)
  39. respond_to do |format|
  40. format.html # new.html.erb
  41. format.xml { render :xml => @po }
  42. end
  43. end
  44.  
  45. # GET /pos/1/edit
  46. def edit
  47. @po = Po.find(params[:id])
  48. @shipping = Shipping.find(params[:id])
  49. @status = Status.find(params[:id])
  50. @priority = Priority.find(params[:id])
  51. end
  52.  
  53. # POST /pos
  54. # POST /pos.xml
  55. def create
  56. @po = Po.new(params[:po])
  57.  
  58. respond_to do |format|
  59. if @po.save
  60. flash[:notice] = 'Po was successfully created.'
  61. format.html { redirect_to(@po) }
  62. format.xml { render :xml => @po, :status => :created, :location => @po }
  63. else
  64. format.html { render :action => "new" }
  65. format.xml { render :xml => @po.errors, :status => :unprocessable_entity }
  66. end
  67. end
  68. end
  69.  
  70. # PUT /pos/1
  71. # PUT /pos/1.xml
  72. def update
  73. params[:po][:existing_item_attributes] ||= {}
  74. @po = Po.find(params[:id])
  75. @shipping = Shipping.find(params[:id])
  76. @status = Status.find(params[:id])
  77. @priority = Priority.find(params[:id])
  78. respond_to do |format|
  79. if @po.update_attributes(params[:po])
  80. flash[:notice] = 'Po was successfully updated.'
  81. format.html { redirect_to(@po) }
  82. format.xml { head :ok }
  83. else
  84. format.html { render :action => "edit" }
  85. format.xml { render :xml => @po.errors, :status => :unprocessable_entity }
  86. end
  87. end
  88. end
  89.  
  90. # DELETE /pos/1
  91. # DELETE /pos/1.xml
  92. def destroy
  93. @po = Po.find(params[:id])
  94. @po.destroy
  95.  
  96. respond_to do |format|
  97. format.html { redirect_to(pos_url) }
  98. format.xml { head :ok }
  99. end
  100. end
  101. end
Add Comment
Please, Sign In to add comment