Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def new
- @store = current_account.accountable
- @ordercard = Ordercard.find_all_by_company_id(4, :include => :item)
- return unless request.post?
- @order = Order.new
- @order.company_id = @store.id
- @order.submitted_by = params[:order][:submitted_by]
- @order.save!
- orderitems = params[:orderitem].reject {|item, qty| qty.nil? || qty.empty? || qty == 0 }
- orderitems.each do |item, qtyz|
- @orderitemnew = @order.orderitem.new(:item_id => item, :qty => qtyz)
- @orderitemnew.save!
- end
- flash[:notice] = "Order number #{@order.id} submitted successfully."
- redirect_to(:action => 'open')
- rescue ActiveRecord::RecordInvalid
- @order.destroy
- render :action => 'new'
- end
Add Comment
Please, Sign In to add comment