Skip to content
Browse files

adding all source files

  • Loading branch information...
1 parent b856f0b commit 03a6303de0fe07f34253b736a55b892990c74616 Mark Coates committed May 2, 2008
Showing with 10,685 additions and 0 deletions.
  1. BIN .DS_Store
  2. +10 −0 Rakefile
  3. +31 −0 app/controllers/application.rb
  4. +76 −0 app/controllers/attachment_controller.rb
  5. +85 −0 app/controllers/contents_controller.rb
  6. +156 −0 app/controllers/conversions_controller.rb
  7. +79 −0 app/controllers/credit_applications_controller.rb
  8. +157 −0 app/controllers/pages_controller.rb
  9. +100 −0 app/controllers/product_categories_controller.rb
  10. +119 −0 app/controllers/products_controller.rb
  11. +85 −0 app/controllers/sales_location_products_controller.rb
  12. +113 −0 app/controllers/sales_locations_controller.rb
  13. +85 −0 app/controllers/sales_region_locations_controller.rb
  14. +85 −0 app/controllers/sales_regions_controller.rb
  15. +105 −0 app/controllers/service_centers_controller.rb
  16. +31 −0 app/controllers/sessions_controller.rb
  17. +63 −0 app/controllers/superior_users_controller.rb
  18. +60 −0 app/helpers/application_helper.rb
  19. +2 −0 app/helpers/contents_helper.rb
  20. +2 −0 app/helpers/conversions_helper.rb
  21. +25 −0 app/helpers/pages_helper.rb
  22. +2 −0 app/helpers/product_categories_helper.rb
  23. +36 −0 app/helpers/products_helper.rb
  24. +2 −0 app/helpers/sales_location_products_helper.rb
  25. +63 −0 app/helpers/sales_locations_helper.rb
  26. +2 −0 app/helpers/sales_region_locations_helper.rb
  27. +2 −0 app/helpers/sales_regions_helper.rb
  28. +75 −0 app/helpers/service_centers_helper.rb
  29. +2 −0 app/helpers/sessions_helper.rb
  30. +2 −0 app/helpers/superior_users_helper.rb
  31. +6 −0 app/models/content.rb
  32. +180 −0 app/models/conversion.rb
  33. +64 −0 app/models/credit_application.rb
  34. +6 −0 app/models/page.rb
  35. +22 −0 app/models/product.rb
  36. +16 −0 app/models/product_category.rb
  37. +32 −0 app/models/sales_location.rb
  38. +4 −0 app/models/sales_location_product.rb
  39. +8 −0 app/models/sales_region.rb
  40. +4 −0 app/models/sales_region_sales_location.rb
  41. +23 −0 app/models/service_center.rb
  42. +119 −0 app/models/superior_user.rb
  43. +24 −0 app/models/superior_user_mailer.rb
  44. +11 −0 app/models/superior_user_observer.rb
  45. +12 −0 app/views/contents/edit.html.erb
  46. +18 −0 app/views/contents/index.html.erb
  47. +11 −0 app/views/contents/new.html.erb
  48. +3 −0 app/views/contents/show.html.erb
  49. +28 −0 app/views/conversions/_carbon_equivalency.html.erb
  50. +4 −0 app/views/conversions/_celsius_to_fahrenheit.html.erb
  51. +53 −0 app/views/conversions/_conversions.html.erb
  52. +4 −0 app/views/conversions/_fahrenheit_to_celsius.html.erb
  53. +4 −0 app/views/conversions/_ft_lbs_to_joules.html.erb
  54. +4 −0 app/views/conversions/_inches_to_millimeters.html.erb
  55. +4 −0 app/views/conversions/_joules_to_ft_lbs.html.erb
  56. +4 −0 app/views/conversions/_kilos_to_pounds.html.erb
  57. +4 −0 app/views/conversions/_ksi_to_mpa.html.erb
  58. +4 −0 app/views/conversions/_metric_tons_to_pounds.html.erb
  59. +4 −0 app/views/conversions/_metric_tons_to_tons.html.erb
  60. +4 −0 app/views/conversions/_millimeters_to_inches.html.erb
  61. +4 −0 app/views/conversions/_mpa_to_ksi.html.erb
  62. +4 −0 app/views/conversions/_mpa_to_psi.html.erb
  63. +36 −0 app/views/conversions/_pcm.html.erb
  64. +4 −0 app/views/conversions/_pounds_to_kilos.html.erb
  65. +4 −0 app/views/conversions/_psi_to_mpa.html.erb
  66. +12 −0 app/views/conversions/_steel_circles_weight.html.erb
  67. +12 −0 app/views/conversions/_steel_plate_weight.html.erb
  68. +1 −0 app/views/conversions/carbon_equivalency.html.erb
  69. +1 −0 app/views/conversions/celsius_to_fahrenheit.html.erb
  70. +1 −0 app/views/conversions/fahrenheit_to_celsius.html.erb
  71. +1 −0 app/views/conversions/ft_lbs_to_joules.html.erb
  72. +1 −0 app/views/conversions/inches_to_millimeters.html.erb
  73. +1 −0 app/views/conversions/joules_to_ft_lbs.html.erb
  74. +1 −0 app/views/conversions/kilos_to_pounds.html.erb
  75. +1 −0 app/views/conversions/ksi_to_mpa.html.erb
  76. +1 −0 app/views/conversions/metric_tons_to_pounds.html.erb
  77. +1 −0 app/views/conversions/metric_tons_to_tons.html.erb
  78. +1 −0 app/views/conversions/millimeters_to_inches.html.erb
  79. +1 −0 app/views/conversions/mpa_to_ksi.html.erb
  80. +1 −0 app/views/conversions/mpa_to_psi.html.erb
  81. +1 −0 app/views/conversions/pcm.html.erb
  82. +1 −0 app/views/conversions/pounds_to_kilos.html.erb
  83. +1 −0 app/views/conversions/psi_to_mpa.html.erb
  84. +1 −0 app/views/conversions/steel_circles_weight.html.erb
  85. +1 −0 app/views/conversions/steel_plate_weight.html.erb
  86. +53 −0 app/views/credit_applications/_us_states.html.erb
  87. +284 −0 app/views/credit_applications/new.html.erb
  88. +313 −0 app/views/credit_applications/printable.html.erb
  89. +95 −0 app/views/layouts/public.html.erb
  90. +10 −0 app/views/pages/accounts_payable.html.erb
  91. +10 −0 app/views/pages/accounts_receivable.html.erb
  92. +321 −0 app/views/pages/contact_us.html.erb
  93. +32 −0 app/views/pages/corporate.html.erb
  94. +10 −0 app/views/pages/credit_department.html.erb
  95. +12 −0 app/views/pages/edit.html.erb
  96. +15 −0 app/views/pages/home.html.erb
  97. +18 −0 app/views/pages/index.html.erb
  98. +11 −0 app/views/pages/new.html.erb
  99. +2 −0 app/views/pages/processing.html.erb
  100. 0 app/views/pages/resources_page.html.erb
  101. +3 −0 app/views/pages/show.html.erb
  102. +7 −0 app/views/pages/steel_plate_weight.html.erb
  103. +12 −0 app/views/product_categories/edit.html.erb
  104. +18 −0 app/views/product_categories/index.html.erb
  105. +11 −0 app/views/product_categories/new.html.erb
  106. +3 −0 app/views/product_categories/show.html.erb
  107. +5 −0 app/views/products/data_book.html.erb
  108. +12 −0 app/views/products/edit.html.erb
  109. +11 −0 app/views/products/new.html.erb
  110. +5 −0 app/views/products/product_detail.html.erb
  111. +40 −0 app/views/products/product_overview.html.erb
  112. +3 −0 app/views/products/show.html.erb
  113. +12 −0 app/views/sales_location_products/edit.html.erb
  114. +18 −0 app/views/sales_location_products/index.html.erb
  115. +11 −0 app/views/sales_location_products/new.html.erb
  116. +3 −0 app/views/sales_location_products/show.html.erb
  117. +3 −0 app/views/sales_locations/_sales_region.html.erb
  118. +12 −0 app/views/sales_locations/edit.html.erb
  119. +18 −0 app/views/sales_locations/index.html.erb
  120. +11 −0 app/views/sales_locations/new.html.erb
  121. +3 −0 app/views/sales_locations/show.html.erb
  122. +18 −0 app/views/sales_locations/view.html.erb
  123. +12 −0 app/views/sales_region_locations/edit.html.erb
  124. +18 −0 app/views/sales_region_locations/index.html.erb
  125. +11 −0 app/views/sales_region_locations/new.html.erb
  126. +3 −0 app/views/sales_region_locations/show.html.erb
  127. +12 −0 app/views/sales_regions/edit.html.erb
  128. +18 −0 app/views/sales_regions/index.html.erb
  129. +11 −0 app/views/sales_regions/new.html.erb
  130. +3 −0 app/views/sales_regions/show.html.erb
  131. +12 −0 app/views/service_centers/edit.html.erb
  132. +18 −0 app/views/service_centers/index.html.erb
  133. +11 −0 app/views/service_centers/new.html.erb
  134. +18 −0 app/views/service_centers/service_center_detail.html.erb
  135. +3 −0 app/views/service_centers/show.html.erb
  136. +14 −0 app/views/sessions/new.html.erb
  137. +3 −0 app/views/superior_user_mailer/activation.html.erb
  138. +8 −0 app/views/superior_user_mailer/signup_notification.html.erb
  139. +16 −0 app/views/superior_users/new.html.erb
  140. +109 −0 config/boot.rb
  141. +19 −0 config/database.yml
  142. +24 −0 config/environment.rb
  143. +18 −0 config/environments/development.rb
  144. +19 −0 config/environments/production.rb
  145. +22 −0 config/environments/test.rb
  146. +10 −0 config/initializers/inflections.rb
  147. +5 −0 config/initializers/mime_types.rb
  148. +98 −0 config/routes.rb
  149. +19 −0 db/migrate/001_create_pages.rb
  150. +27 −0 db/migrate/002_create_service_centers.rb
  151. +15 −0 db/migrate/003_create_superior_users.rb
  152. +21 −0 db/migrate/004_create_product_categories.rb
  153. +15 −0 db/migrate/005_create_products.rb
  154. +14 −0 db/migrate/007_create_sales_regions.rb
  155. +15 −0 db/migrate/008_create_contents.rb
  156. +19 −0 db/migrate/010_create_sales_locations.rb
  157. +11 −0 db/migrate/011_create_sales_region_sales_locations.rb
  158. +11 −0 db/migrate/012_create_sales_location_products.rb
  159. +171 −0 db/schema.rb
  160. +4,559 −0 db/superior_steel_dev.sql
  161. +2 −0 doc/README_FOR_APP
  162. +116 −0 lib/authenticated_system.rb
  163. +10 −0 lib/authenticated_test_helper.rb
  164. BIN log/.DS_Store
  165. +55 −0 log/development.log
  166. BIN public/.DS_Store
  167. +40 −0 public/.htaccess
  168. +30 −0 public/404.html
  169. +30 −0 public/422.html
  170. +30 −0 public/500.html
  171. +10 −0 public/dispatch.cgi
  172. +24 −0 public/dispatch.fcgi
  173. +10 −0 public/dispatch.rb
  174. 0 public/favicon.ico
  175. BIN public/flash/.DS_Store
  176. BIN public/flash/expressinstall.swf
  177. BIN public/flash/gs/.DS_Store
  178. +475 −0 public/flash/gs/TweenFilterLite.as
  179. +472 −0 public/flash/gs/TweenLite.as
  180. BIN public/flash/images/.DS_Store
  181. BIN public/flash/images/plate_regions/Q5L7962.jpg
  182. BIN public/flash/images/plate_regions/Q5L7989.jpg
  183. BIN public/flash/images/plate_regions/Q5L8001.jpg
  184. BIN public/flash/images/service_centers/anchor.jpg
  185. BIN public/flash/images/service_centers/bmt_001.jpg
  186. BIN public/flash/images/service_centers/bmt_004.jpg
  187. BIN public/flash/images/service_centers/bmt_007.jpg
  188. BIN public/flash/images/service_centers/carbon_fitting_1.jpg
  189. BIN public/flash/images/service_centers/carbon_fitting_3.jpg
  190. BIN public/flash/images/service_centers/houma_1.jpg
  191. BIN public/flash/images/service_centers/houma_2.jpg
  192. BIN public/flash/images/service_centers/houma_product_image.jpg
  193. BIN public/flash/images/service_centers/new_iberia_1.jpg
  194. BIN public/flash/images/service_centers/new_iberia_2.jpg
  195. BIN public/flash/images/service_centers/stainless _fitting_1.jpg
  196. BIN public/flash/images/service_centers/sulphur_3.jpg
  197. +1 −0 public/flash/loadXml.as
  198. BIN public/flash/pr_chicago.swf
  199. +21 −0 public/flash/pr_chicago_images.xml
  200. BIN public/flash/sc_beaumont.swf
  201. +21 −0 public/flash/sc_beaumont_images.xml
  202. BIN public/flash/sc_houma.swf
  203. +21 −0 public/flash/sc_houma_images.xml
  204. BIN public/flash/sc_lake_charles.fla
  205. BIN public/flash/sc_lake_charles.swf
  206. +24 −0 public/flash/sc_lake_charles_images.xml
  207. BIN public/flash/sc_new_iberia.swf
  208. +21 −0 public/flash/sc_new_iberia_images.xml
  209. +1 −0 public/flash/xslideshow.as
  210. +1 −0 public/flash/xslideshow_np.as
  211. BIN public/images/.DS_Store
  212. BIN public/images/Q5L7958.jpg
  213. BIN public/images/Q5L7962.jpg
  214. BIN public/images/Q5L7983.jpg
  215. BIN public/images/ajax_indicator_dark.gif
  216. BIN public/images/ajax_indicator_light.gif
  217. BIN public/images/body_bkgd.jpg
  218. BIN public/images/both_parks_from_air.jpg
  219. BIN public/images/conversion_tool_header.gif
  220. BIN public/images/corporate_headline.gif
  221. BIN public/images/get_adobe_reader.gif
  222. BIN public/images/global_nav_bkgd.jpg
  223. BIN public/images/gn_contact_icon.gif
  224. BIN public/images/gn_contact_icon.png
  225. BIN public/images/gn_home_icon.gif
  226. BIN public/images/gn_home_icon.png
  227. BIN public/images/gn_logo.gif
  228. BIN public/images/gn_logo.png
  229. BIN public/images/gn_phone.gif
  230. BIN public/images/gn_phone.png
  231. BIN public/images/hdr_accounts_payable.gif
  232. BIN public/images/hdr_accounts_receivable.gif
  233. BIN public/images/hdr_contact_us.gif
  234. BIN public/images/hdr_credit_app.gif
  235. BIN public/images/hdr_credit_department.gif
  236. BIN public/images/hdr_data_book.gif
  237. BIN public/images/hdr_facility_specs.gif
  238. BIN public/images/hdr_flat_roll_region_tulsa.gif
  239. BIN public/images/hdr_plate_region_chicago.gif
  240. BIN public/images/hdr_plate_region_houston.gif
  241. BIN public/images/hdr_plate_region_mexico.gif
  242. BIN public/images/hdr_plate_region_mobile.gif
  243. BIN public/images/hdr_plate_region_tulsa.gif
  244. BIN public/images/hdr_service_center_alexandria.gif
  245. BIN public/images/hdr_service_center_beaumont.gif
  246. BIN public/images/hdr_service_center_houma.gif
  247. BIN public/images/hdr_service_center_lake_charles.gif
  248. BIN public/images/hdr_service_center_morgan_city.gif
  249. BIN public/images/hdr_service_center_new_iberia.gif
  250. BIN public/images/hdr_superior_processing.gif
  251. BIN public/images/hdr_superior_products.gif
  252. BIN public/images/home_coverage_map.jpg
  253. BIN public/images/home_earth_image.jpg
  254. BIN public/images/home_headline.gif
  255. BIN public/images/ico_blue_arrows.gif
  256. BIN public/images/ico_diamond.gif
  257. BIN public/images/ico_diamond.png
  258. BIN public/images/main_nav_bkgd.jpg
  259. BIN public/images/map_beaumont_sc.jpg
  260. BIN public/images/map_chicago.jpg
  261. BIN public/images/map_houma_sc.jpg
  262. BIN public/images/map_houston_plate.jpg
  263. BIN public/images/map_lake_charles_sc.jpg
  264. BIN public/images/map_mexico_plate.jpg
  265. BIN public/images/map_mobile_plate.jpg
  266. BIN public/images/map_morgan_city_sc.jpg
  267. BIN public/images/map_new_iberia_sc.jpg
  268. BIN public/images/map_tulsa_flat_roll.jpg
  269. BIN public/images/map_tulsa_plate.jpg
  270. BIN public/images/menu_bkgd.jpg
  271. BIN public/images/menu_header_bkgd.jpg
  272. BIN public/images/menu_header_corner.jpg
  273. BIN public/images/mn_contact_f1.gif
  274. BIN public/images/mn_contact_f1.png
  275. BIN public/images/mn_contact_f2.png
  276. BIN public/images/mn_contact_f3.gif
  277. BIN public/images/mn_contact_f3.png
  278. BIN public/images/mn_corporate_f1.gif
  279. BIN public/images/mn_corporate_f1.png
  280. BIN public/images/mn_corporate_f2.png
  281. BIN public/images/mn_corporate_f3.gif
  282. BIN public/images/mn_corporate_f3.png
  283. BIN public/images/mn_home_f1.gif
  284. BIN public/images/mn_home_f1.png
  285. BIN public/images/mn_home_f3.gif
  286. BIN public/images/mn_home_f3.png
  287. BIN public/images/mn_processing_f1.gif
  288. BIN public/images/mn_processing_f1.png
  289. BIN public/images/mn_processing_f2.png
  290. BIN public/images/mn_processing_f3.gif
  291. BIN public/images/mn_processing_f3.png
  292. BIN public/images/mn_products_f1.gif
  293. BIN public/images/mn_products_f1.png
  294. BIN public/images/mn_products_f2.png
  295. BIN public/images/mn_products_f3.gif
  296. BIN public/images/mn_products_f3.png
  297. BIN public/images/mn_resources_f1.gif
  298. BIN public/images/mn_resources_f1.png
  299. BIN public/images/mn_resources_f2.png
  300. BIN public/images/mn_resources_f3.gif
Sorry, we could not display the entire diff because too many files (3,150) changed.
View
BIN .DS_Store
Binary file not shown.
View
10 Rakefile
@@ -0,0 +1,10 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
View
31 app/controllers/application.rb
@@ -0,0 +1,31 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+
+ # See ActionController::RequestForgeryProtection for details
+ # Uncomment the :secret if you're not using the cookie session store
+ protect_from_forgery # :secret => '6a95979ff8f1baa11cb434b240ae7df5'
+
+ def init_public_page(page_name = nil)
+
+ if page_name.nil?
+ @current_controller = self.class.controller_name.underscore.sub('_controller','')
+ page_name = ApplicationHelper.controller_name_to_page_name(@current_controller)
+ end
+
+ @body_class = page_name.downcase.underscore
+ @page ||= Page.find_by_name(page_name, :include => :contents, :select => 'pages.title, pages.keywords, pages.description, pages.topic, contents.id, contents.live_content')
+ @title = @page.title.blank? ? 'Superior Supply &amp; Steel' : 'Superior Supply &amp; Steel : ' << @page.title
+ @contents = @page.contents
+ end
+
+ def hyphenate(string)
+ string.gsub(/[^a-z1-9]+/i, '-')
+ end
+
+ def parse_id(string)
+ string.gsub(/[\D]/, '').to_i
+ end
+end
View
76 app/controllers/attachment_controller.rb
@@ -0,0 +1,76 @@
+require 'fileutils'
+
+class AttachmentController < ApplicationController
+ UPLOADED = '/images' #uploaded
+ UPLOADED_ROOT = RAILS_ROOT + '/public' + UPLOADED
+ MIME_TYPES = [ 'image/jpeg', 'image/gif', 'image/png', 'application/x-shockwave-flash' ]
+
+ def command
+ self.send params[:Command]
+ end
+
+ def GetFolders
+ self.GetFoldersAndFiles(false)
+ end
+
+ def GetFoldersAndFiles(include_files = true)
+ @url = UPLOADED + params[:CurrentFolder]
+ @folders = Array.new
+ @files = {}
+ @current_folder = UPLOADED_ROOT + params[:CurrentFolder]
+ Dir.entries(@current_folder).each do |entry|
+ next if entry =~ /^\./
+ path = @current_folder + entry
+ @folders.push entry if FileTest.directory?(path)
+ @files[entry] = (File.size(path) / 1024) if (include_files and FileTest.file?(path))
+ end
+ end
+
+ def CreateFolder
+
+ @url = UPLOADED_ROOT + params[:CurrentFolder]
+ path = @url + params[:NewFolderName]
+ if !(File.stat(@url).writable?)
+ @errorNumber = 103
+ elsif params[:CurrentFolder] !~ /[\w\d\s]+/
+ @errorNumber = 102
+ elsif FileTest.exists?(path)
+ @errorNumber = 101
+ else
+ Dir.mkdir(path,0775)
+ @errorNumber = 0
+ end
+ rescue => e
+ @errorNumber = 110 if @errorNumber.nil?
+ end
+
+
+ def FileUpload
+ begin
+ ftype = params[:NewFile].content_type.strip
+ if ! MIME_TYPES.include?(ftype)
+ @errorNumber = 202
+ raise "#{ftype} is invalid MIME type"
+ else
+ dir = UPLOADED_ROOT + (params[:CurrentFolder] ? params[:CurrentFolder] : '/')
+ path = dir + params[:NewFile].original_filename
+ File.open(path,'wb',0664) do |fp|
+ FileUtils.copy_stream(params[:NewFile], fp)
+ end
+ @errorNumber = 0
+ end
+ rescue => e
+ @errorNumber = 110 if @errorNumber.nil?
+ end
+ render :text => <<-EOL
+ <script type="text/javascript">
+ window.parent.frames['frmUpload'].OnUploadCompleted(#{@errorNumber});
+ </script>
+ EOL
+ end
+
+ def upload
+ self.FileUpload
+ end
+
+end
View
85 app/controllers/contents_controller.rb
@@ -0,0 +1,85 @@
+class ContentsController < ApplicationController
+ # GET /contents
+ # GET /contents.xml
+ def index
+ @contents = Content.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @contents }
+ end
+ end
+
+ # GET /contents/1
+ # GET /contents/1.xml
+ def show
+ @content = Content.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @content }
+ end
+ end
+
+ # GET /contents/new
+ # GET /contents/new.xml
+ def new
+ @content = Content.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @content }
+ end
+ end
+
+ # GET /contents/1/edit
+ def edit
+ @content = Content.find(params[:id])
+ end
+
+ # POST /contents
+ # POST /contents.xml
+ def create
+ @content = Content.new(params[:content])
+
+ respond_to do |format|
+ if @content.save
+ flash[:notice] = 'Content was successfully created.'
+ format.html { redirect_to(@content) }
+ format.xml { render :xml => @content, :status => :created, :location => @content }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @content.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /contents/1
+ # PUT /contents/1.xml
+ def update
+ @content = Content.find(params[:id])
+
+ respond_to do |format|
+ if @content.update_attributes(params[:content])
+ flash[:notice] = 'Content was successfully updated.'
+ format.html { redirect_to(@content) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @content.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /contents/1
+ # DELETE /contents/1.xml
+ def destroy
+ @content = Content.find(params[:id])
+ @content.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(contents_url) }
+ format.xml { head :ok }
+ end
+ end
+end
View
156 app/controllers/conversions_controller.rb
@@ -0,0 +1,156 @@
+class ConversionsController < ApplicationController
+ require 'bigdecimal'
+
+ layout 'public'
+ before_filter :init
+
+ def convert
+ conversion = params[:conversion]
+ type = conversion[:type]
+ length = conversion[:length]
+ width = conversion[:width]
+ thickness = conversion[:thickness]
+ outer_diameter = conversion[:outer_diameter]
+ inner_diameter = conversion[:inner_diameter]
+ inches = conversion[:inches]
+ millimeters = conversion[:millimeters]
+ pounds = conversion[:pounds]
+ kilograms = conversion[:kilograms]
+ metric_tons = conversion[:metric_tons]
+ fahrenheit = conversion[:fahrenheit]
+ celsius = conversion[:celsius]
+ ft_lbs = conversion[:ft_lbs]
+ mpa = conversion[:mpa]
+ psi = conversion[:psi]
+ ksi = conversion[:ksi]
+ c = conversion[:c]
+ si = conversion[:si]
+ mn = conversion[:mn]
+ cr = conversion[:cr]
+ mo = conversion[:mo]
+ v = conversion[:v]
+ ni = conversion[:ni]
+ cu = conversion[:cu]
+ b = conversion[:b]
+
+ case type
+ when 'steel_plate_weight'
+ @conversion = Conversion.new(:length => length, :width => width, :thickness => thickness)
+ @conversion.converting_steel_plate_weight = true
+ result = (BigDecimal(length) * BigDecimal(width) * BigDecimal(thickness) * 0.2836)
+
+ when 'steel_circles_weight'
+ @conversion = Conversion.new(:outer_diameter => outer_diameter, :inner_diameter => inner_diameter, :thickness => thickness)
+ @conversion.converting_steel_circles_weight = true
+ t = BigDecimal(thickness)
+ f = 0.22274
+ result = (((BigDecimal(outer_diameter)**2) * t * f) - ((BigDecimal(inner_diameter)**2) * t * f))
+
+ when 'inches_to_millimeters'
+ @conversion = Conversion.new(:inches => inches)
+ @conversion.converting_inches_to_millimeters = true
+ result = (BigDecimal(inches) / 0.03937)
+
+ when 'millimeters_to_inches'
+ @conversion = Conversion.new(:millimeters => millimeters)
+ @conversion.converting_millimeters_to_inches = true
+ result = (BigDecimal(millimeters) * 0.03937)
+
+ when 'pounds_to_kilos'
+ @conversion = Conversion.new(:pounds => pounds)
+ @conversion.converting_pounds_to_kilos = true
+ result = (BigDecimal(pounds) * 0.45359237)
+
+ when 'kilos_to_pounds'
+ @conversion = Conversion.new(:kilograms => kilograms)
+ @conversion.converting_kilos_to_pounds = true
+ result = (BigDecimal(kilograms) * 2.2046)
+
+ when 'metric_tons_to_pounds'
+ @conversion = Conversion.new(:metric_tons => metric_tons)
+ @conversion.converting_metric_tons_to_pounds_or_tons = true
+ result = (BigDecimal(metric_tons) * 2204.62262)
+
+ when 'metric_tons_to_tons'
+ @conversion = Conversion.new(:metric_tons => metric_tons)
+ @conversion.converting_metric_tons_to_pounds_or_tons = true
+ result = (BigDecimal(metric_tons) * 1.1023)
+
+ when 'fahrenheit_to_celsius'
+ @conversion = Conversion.new(:fahrenheit => fahrenheit)
+ @conversion.converting_fahrenheit_to_celsius = true
+ result = (((BigDecimal(fahrenheit) - 32) * 5) / 9)
+
+ when 'celsius_to_fahrenheit'
+ @Conversion = Conversion.new(:celsius => celsius)
+ @conversion.converting_celsius_to_fahrenheit = true
+ result = (((BigDecimal(celsius) * 9) / 5) + 32)
+
+ when 'ft_lbs_to_joules'
+ @conversion = Conversion.new(:ft_lbs => ft_lbs)
+ @conversion.converting_ft_lbs_to_joules = true
+ result = (BigDecimal(ft_lbs) * 1.35582)
+
+ when 'joules_to_ft_lbs'
+ @conversion = Conversion.new(:joules => joules)
+ @conversion.converting_joules_to_ft_lbs = true
+ result = (BigDecimal(joules) / 1.3558)
+
+ when 'mpa_to_psi'
+ @conversion = Conversion.new(:mpa => mpa)
+ @conversion.converting_mpa_to_psi_or_mpa_to_ksi = true
+ result = (BigDecimal(mpa) * 145.03774)
+
+ when 'psi_to_mpa'
+ @conversion = Conversion.new(:psi => psi)
+ @conversion.converting_psi_to_mpa = true
+ result = (BigDecimal(psi) / 145.03774)
+
+ when 'mpa_to_ksi'
+ @conversion = Conversion.new(:mpa => mpa)
+ @conversion.converting_mpa_to_psi_or_mpa_to_ksi = true
+ result = (BigDecimal(mpa) * 0.14503774)
+
+ when 'ksi_to_mpa'
+ @conversion = Conversion.new(:ksi => ksi)
+ @conversion.converting_ksi_to_mpa = true
+ result = (BigDecimal(ksi) / 0.14503774)
+
+ when 'carbon_equivalency'
+ @conversion = Conversion.new(:c => c, :mn => mn, :cr => cr, :mo => mo, :v => v, :ni => ni, :cu => cu)
+ @conversion.converting_carbon_equivalency = true
+ result = ((BigDecimal(c) + (BigDecimal(mn) / 6)) + ((BigDecimal(cr) + BigDecimal(mo) + BigDecimal(v)) / 5) + ((BigDecimal(ni) + BigDecimal(cu)) / 15))
+
+ when 'pcm'
+ @conversion = Conversion.new(:c => c, :si => si, :mn => mn, :cu => cu, :cr => cr, :ni => ni, :mo => mo, :v => v, :b => b)
+ @conversion.converting_pcm = true
+ result = (BigDecimal(c) + (BigDecimal(si) / 30) + ((BigDecimal(mn) + BigDecimal(cu) + BigDecimal(cr)) / 20) + (BigDecimal(ni) / 60) + (BigDecimal(mo) / 15) + (BigDecimal(v) / 10) + (5 * BigDecimal(b)))
+ end
+
+
+ render :update do |page|
+ page[:errors].hide
+ page[:result].value = ''
+
+ if @conversion.save
+ page[:result].value = result.to_s
+ page[:ajax_indicator].toggle
+ else
+ page[:ajax_indicator].toggle
+ page[:errors].replace_html(error_messages_for(:conversion)).show
+ end
+
+ end
+
+ end
+
+ private
+
+ def init
+ init_public_page('Conversion Tool')
+ @body_class = 'resources conversions'
+ @css_imports = ['conversions']
+ @js_imports = ['conversions']
+ @conversion = Conversion.new
+ end
+end
View
79 app/controllers/credit_applications_controller.rb
@@ -0,0 +1,79 @@
+class CreditApplicationsController < ApplicationController
+ before_filter :init, :only => [:new, :create]
+ layout :determine_layout
+
+ # GET /credit_applications/new
+ # GET /credit_applications/new.xml
+ def new
+ session[:credit_application] = nil
+ @credit_application = CreditApplication.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @credit_application }
+ end
+ end
+
+ # GET /credit_applications/1/edit
+ def create
+ @css_imports = ['credit_application']
+ @credit_application = CreditApplication.create(params[:credit_application])
+
+ respond_to do |format|
+ if @credit_application.save
+ session[:credit_application] = @credit_application
+ format.html { redirect_to printable_credit_application_path }
+ format.xml { render :xml => @credit_application, :status => :created, :location => @credit_application }
+ else
+ format.html { render :action => 'new' }
+ format.xml { render :xml => @credit_application.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ def printable
+ unless (session[:credit_application].nil?)
+ @css_imports = ['credit_application_print']
+ @credit_application = session[:credit_application]
+ np = 'Not Provided'
+
+ #check for blank values on optional fields and replace blank with 'Not Provided'
+ @credit_application.applicant_ssn.blank? ? np : @credit_application.applicant_ssn
+ @credit_application.applicant_email.blank? ? np : @credit_application.applicant_email
+ @credit_application.firm_years_at_this_address.blank? ? np : @credit_application.firm_years_at_this_address
+ @credit_application.firm_federal_tax_id_number.blank? ? np : @credit_application.firm_federal_tax_id_number
+ @credit_application.receive_statement_email_address.blank? ? np : @credit_application.receive_statement_email_address
+ @credit_application.firm_accounts_payable_contact.blank? ? np : @credit_application.firm_accounts_payable_contact
+ @credit_application.firm_accounts_payable_contact_email.blank? ? np : @credit_application.firm_accounts_payable_contact_email
+ @credit_application.firm_officer2_name.blank? ? np : @credit_application.firm_officer2_name
+ @credit_application.firm_officer2_title.blank? ? np : @credit_application.firm_officer2_title
+ @credit_application.firm_officer2_phone.blank? ? np : @credit_application.firm_officer2_phone
+ @credit_application.firm_officer2_address.blank? ? np : @credit_application.firm_officer2_address
+ @credit_application.trade_reference1_fax.blank? ? np : @credit_application.trade_reference1_fax
+ @credit_application.trade_reference2_fax.blank? ? np : @credit_application.trade_reference2_fax
+ @credit_application.trade_reference3_fax.blank? ? np : @credit_application.trade_reference3_fax
+ @credit_application.trade_reference4_fax.blank? ? np : @credit_application.trade_reference4_fax
+
+ dt = DateTime.now
+ @year = dt.year
+ @month = dt.strftime('%B')
+ @day = dt.strftime('%d')
+ else
+ redirect_to new_credit_application_path
+ end
+ end
+
+
+ private
+
+ def init
+ @title = 'Superior Steel &amp; Supply : Credit Application'
+ @body_class = 'resources credit_application'
+ @css_imports = ['credit_application']
+ end
+
+ def determine_layout
+ ['new','create'].include?(action_name) ? 'public' : nil
+ end
+
+end
View
157 app/controllers/pages_controller.rb
@@ -0,0 +1,157 @@
+class PagesController < ApplicationController
+ caches_page(:home, :corporate, :credit_department, :accounts_receivable, :accounts_payable, :processing, :resources_page, :contact_ud)
+ layout :determine_layout
+
+ def home
+ init_public_page('Home')
+ @css_imports = ['home']
+
+ #This is very brittle. If the plate product category is not 6, the select will fail
+ @plate_sales_regions = SalesRegion.find(:all, :conditions => ['sales_regions.active = ? AND products.product_category_id = ? AND products.active = ?', 1, 6, 1],
+ :include => [:sales_locations => [:products => [:product_category]]], :order => 'sales_locations.country desc, sales_locations.position asc')
+
+ #we're grabbing this from the collection for consistency in the data, instead of hard-coding 'plate' into the view
+ @plate_region_category = @plate_sales_regions[0].sales_locations[0].products[0].product_category.category
+
+ #If the flat roll product category is not 11, the select will fail and the same restrictions as above apply
+ @flat_roll_sales_regions = SalesRegion.find(:all, :conditions => ['sales_regions.active = ? AND products.product_category_id = ? AND products.active = ?', 1, 11, 1],
+ :include => [:sales_locations => [:products => [:product_category]]], :order => 'sales_locations.position asc')
+
+ @flat_roll_region_category = @flat_roll_sales_regions[0].sales_locations[0].products[0].product_category.category
+
+ @service_centers = @flat_roll_sales_regions.nil? ? 0 : ServiceCenter.find(:all, :order => 'position asc')
+ end
+
+ def corporate
+ init_public_page('Corporate')
+ @body_class = 'corporate'
+ @css_imports = ['corporate']
+ end
+
+ def credit_department
+ init_public_page('Credit Department')
+ @body_class = 'corporate credit_department'
+ @css_imports = ['credit_department']
+ end
+
+ def accounts_receivable
+ init_public_page('Accounts Receivable')
+ @body_class = 'corporate accounts_receivable'
+ @css_imports = ['accounts_receivable']
+ end
+
+ def accounts_payable
+ init_public_page('Accounts Payable')
+ @body_class = 'corporate accounts_payable'
+ @css_imports = ['accounts_payable']
+ end
+
+ def processing
+ init_public_page('Processing')
+ @body_class = 'processing'
+ @css_imports = ['processing']
+ end
+
+ def resources_page
+ init_public_page('Resources')
+ @body_class = 'resources'
+ end
+
+ def contact_us
+ init_public_page('Contact Us')
+ @body_class = 'contact_us'
+ @css_imports = ['contact_us']
+ end
+
+ # GET /pages
+ # GET /pages.xml
+ def index
+ @pages = Page.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @pages }
+ end
+ end
+
+ # GET /pages/1
+ # GET /pages/1.xml
+ def show
+ @page = Page.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @page }
+ end
+ end
+
+ # GET /pages/new
+ # GET /pages/new.xml
+ def new
+ @page = Page.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @page }
+ end
+ end
+
+ # GET /pages/1/edit
+ def edit
+ @page = Page.find(params[:id])
+ end
+
+ # POST /pages
+ # POST /pages.xml
+ def create
+ @page = Page.new(params[:page])
+
+ respond_to do |format|
+ if @page.save
+ flash[:notice] = 'Page was successfully created.'
+ format.html { redirect_to(@page) }
+ format.xml { render :xml => @page, :status => :created, :location => @page }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /pages/1
+ # PUT /pages/1.xml
+ def update
+ @page = Page.find(params[:id])
+
+ respond_to do |format|
+ if @page.update_attributes(params[:page])
+ flash[:notice] = 'Page was successfully updated.'
+ format.html { redirect_to(@page) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /pages/1
+ # DELETE /pages/1.xml
+ def destroy
+ @page = Page.find(params[:id])
+ @page.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(pages_url) }
+ format.xml { head :ok }
+ end
+ end
+
+
+ private
+
+ def determine_layout
+ ['home','corporate','credit_department','accounts_receivable','accounts_payable','processing','resources_page','contact_us','current_promotions','product_overview'].include?(action_name) ? 'public' : 'admin'
+ end
+
+end
View
100 app/controllers/product_categories_controller.rb
@@ -0,0 +1,100 @@
+class ProductCategoriesController < ApplicationController
+ layout :determine_layout
+
+ # GET /product_categories
+ # GET /product_categories.xml
+ def index
+ @product_categories = ProductCategory.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @product_categories }
+ end
+ end
+
+ # GET /product_categories/1
+ # GET /product_categories/1.xml
+ def show
+ @product_category = ProductCategory.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @product_category }
+ end
+ end
+
+ # GET /product_categories/new
+ # GET /product_categories/new.xml
+ def new
+ @product_category = ProductCategory.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @product_category }
+ end
+ end
+
+ # GET /product_categories/1/edit
+ def edit
+ @product_category = ProductCategory.find(params[:id])
+ end
+
+ # POST /product_categories
+ # POST /product_categories.xml
+ def create
+ @product_category = ProductCategory.new(params[:product_category])
+
+ respond_to do |format|
+ if @product_category.save
+ flash[:notice] = 'ProductCategory was successfully created.'
+ format.html { redirect_to(@product_category) }
+ format.xml { render :xml => @product_category, :status => :created, :location => @product_category }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @product_category.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /product_categories/1
+ # PUT /product_categories/1.xml
+ def update
+ @product_category = ProductCategory.find(params[:id])
+
+ respond_to do |format|
+ if @product_category.update_attributes(params[:product_category])
+ flash[:notice] = 'ProductCategory was successfully updated.'
+ format.html { redirect_to(@product_category) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @product_category.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /product_categories/1
+ # DELETE /product_categories/1.xml
+ def destroy
+ @product_category = ProductCategory.find(params[:id])
+ @product_category.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(product_categories_url) }
+ format.xml { head :ok }
+ end
+ end
+
+
+ private
+
+ def init
+ @title = 'Superior Steel &amp; Supply : Product Matrix'
+ @title += params[:product_category_permalink] + ' : ' + params[:product_permalink] unless params[:product_category_permalink].nil?
+ end
+
+ def determine_layout
+ [''].include?(action_name) ? 'public' : 'admin'
+ end
+
+end
View
119 app/controllers/products_controller.rb
@@ -0,0 +1,119 @@
+class ProductsController < ApplicationController
+ before_filter :init, :only => [:data_book, :product_detail]
+ layout :determine_layout
+ caches_page(:product_overview, :data_book, :product_detail)
+
+ def product_overview
+ init_public_page('Product Overview')
+ @body_class = 'products'
+ @css_imports = ['product_overview']
+ end
+
+ def data_book
+ @body_class = 'products'
+ @css_imports = ['data_book']
+ @product_categories = ProductCategory.find(:all, :conditions => ['product_categories.active = ? AND products.active = ? AND product_categories.show_in_data_book = ? AND products.show_in_data_book = ?', true, true, true, true], :order => 'product_categories.position, products.position ASC', :include => [:products])
+ end
+
+ def product_detail
+ @product = Product.find(params[:id], :include => [:contents])
+ end
+
+ # GET /products
+ # GET /products.xml
+ def index
+ @products = Product.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @products }
+ end
+ end
+
+ # GET /products/1
+ # GET /products/1.xml
+ def show
+ @product = Product.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @product }
+ end
+ end
+
+ # GET /products/new
+ # GET /products/new.xml
+ def new
+ @product = Product.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @product }
+ end
+ end
+
+ # GET /products/1/edit
+ def edit
+ @product = Product.find(params[:id])
+ end
+
+ # POST /products
+ # POST /products.xml
+ def create
+ @product = Product.new(params[:product])
+
+ respond_to do |format|
+ if @product.save
+ flash[:notice] = 'Product was successfully created.'
+ format.html { redirect_to(@product) }
+ format.xml { render :xml => @product, :status => :created, :location => @product }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /products/1
+ # PUT /products/1.xml
+ def update
+ @product = Product.find(params[:id])
+
+ respond_to do |format|
+ if @product.update_attributes(params[:product])
+ flash[:notice] = 'Product was successfully updated.'
+ format.html { redirect_to(@product) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /products/1
+ # DELETE /products/1.xml
+ def destroy
+ @product = Product.find(params[:id])
+ @product.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(products_url) }
+ format.xml { head :ok }
+ end
+ end
+
+
+ private
+
+ def init
+ @title = 'Superior Steel &amp; Supply : Product Data Book'
+ @title += ' : ' + params[:product_category].titleize + ' : ' + params[:permalink].titleize unless params[:permalink].nil?
+ @css_imports = ['data_book']
+ @body_class = 'products'
+ end
+
+ def determine_layout
+ ['product_overview','data_book','product_detail','tables'].include?(action_name) ? 'public' : 'admin'
+ end
+end
View
85 app/controllers/sales_location_products_controller.rb
@@ -0,0 +1,85 @@
+class SalesLocationProductsController < ApplicationController
+ # GET /sales_location_products
+ # GET /sales_location_products.xml
+ def index
+ @sales_location_products = SalesLocationProduct.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @sales_location_products }
+ end
+ end
+
+ # GET /sales_location_products/1
+ # GET /sales_location_products/1.xml
+ def show
+ @sales_location_product = SalesLocationProduct.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @sales_location_product }
+ end
+ end
+
+ # GET /sales_location_products/new
+ # GET /sales_location_products/new.xml
+ def new
+ @sales_location_product = SalesLocationProduct.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @sales_location_product }
+ end
+ end
+
+ # GET /sales_location_products/1/edit
+ def edit
+ @sales_location_product = SalesLocationProduct.find(params[:id])
+ end
+
+ # POST /sales_location_products
+ # POST /sales_location_products.xml
+ def create
+ @sales_location_product = SalesLocationProduct.new(params[:sales_location_product])
+
+ respond_to do |format|
+ if @sales_location_product.save
+ flash[:notice] = 'SalesLocationProduct was successfully created.'
+ format.html { redirect_to(@sales_location_product) }
+ format.xml { render :xml => @sales_location_product, :status => :created, :location => @sales_location_product }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @sales_location_product.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /sales_location_products/1
+ # PUT /sales_location_products/1.xml
+ def update
+ @sales_location_product = SalesLocationProduct.find(params[:id])
+
+ respond_to do |format|
+ if @sales_location_product.update_attributes(params[:sales_location_product])
+ flash[:notice] = 'SalesLocationProduct was successfully updated.'
+ format.html { redirect_to(@sales_location_product) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @sales_location_product.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /sales_location_products/1
+ # DELETE /sales_location_products/1.xml
+ def destroy
+ @sales_location_product = SalesLocationProduct.find(params[:id])
+ @sales_location_product.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(sales_location_products_url) }
+ format.xml { head :ok }
+ end
+ end
+end
View
113 app/controllers/sales_locations_controller.rb
@@ -0,0 +1,113 @@
+class SalesLocationsController < ApplicationController
+ caches_page :view
+ layout :determine_layout
+
+ def view
+ @js_imports = ['swfobject']
+
+ @selected_sales_location_id = parse_id(params[:sales_location_id])
+ product_category_id = parse_id(params[:product_category_id])
+
+ @sales_locations = SalesLocation.find(:all, :include => [:contents, [:products => [:product_category]]], :conditions => ['products.product_category_id = ? AND contents.product_category_id = ?', product_category_id, product_category_id])
+ @sales_location = @sales_locations.select { |sl| sl.id == @selected_sales_location_id }[0]
+
+ title_class = @sales_location.united_states? ? @sales_location.display_city : @sales_location.country
+
+ @product_category = @sales_location.products[0].product_category.category
+
+ @title = 'Superior Steel &amp; Supply : ' + @product_category + ' : ' + title_class
+ @body_class = 'corporate sales_locations ' + hyphenate(title_class).underscore + ' ' + hyphenate(@product_category).underscore
+ @css_imports = ['sales_locations']
+ end
+
+ # GET /sales_locations
+ # GET /sales_locations.xml
+ def index
+ @sales_locations = SalesLocation.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @sales_locations }
+ end
+ end
+
+ # GET /sales_locations/1
+ # GET /sales_locations/1.xml
+ def show
+ @sales_location = SalesLocation.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @sales_location }
+ end
+ end
+
+ # GET /sales_locations/new
+ # GET /sales_locations/new.xml
+ def new
+ @sales_location = SalesLocation.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @sales_location }
+ end
+ end
+
+ # GET /sales_locations/1/edit
+ def edit
+ @sales_location = SalesLocation.find(params[:id])
+ end
+
+ # POST /sales_locations
+ # POST /sales_locations.xml
+ def create
+ @sales_location = SalesLocation.new(params[:sales_location])
+
+ respond_to do |format|
+ if @sales_location.save
+ flash[:notice] = 'SalesLocation was successfully created.'
+ format.html { redirect_to(@sales_location) }
+ format.xml { render :xml => @sales_location, :status => :created, :location => @sales_location }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @sales_location.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /sales_locations/1
+ # PUT /sales_locations/1.xml
+ def update
+ @sales_location = SalesLocation.find(params[:id])
+
+ respond_to do |format|
+ if @sales_location.update_attributes(params[:sales_location])
+ flash[:notice] = 'SalesLocation was successfully updated.'
+ format.html { redirect_to(@sales_location) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @sales_location.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /sales_locations/1
+ # DELETE /sales_locations/1.xml
+ def destroy
+ @sales_location = SalesLocation.find(params[:id])
+ @sales_location.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(sales_locations_url) }
+ format.xml { head :ok }
+ end
+ end
+
+
+ private
+
+ def determine_layout
+ ['view'].include?(action_name) ? 'public' : 'admin'
+ end
+end
View
85 app/controllers/sales_region_locations_controller.rb
@@ -0,0 +1,85 @@
+class SalesRegionLocationsController < ApplicationController
+ # GET /sales_region_locations
+ # GET /sales_region_locations.xml
+ def index
+ @sales_region_locations = SalesRegionLocation.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @sales_region_locations }
+ end
+ end
+
+ # GET /sales_region_locations/1
+ # GET /sales_region_locations/1.xml
+ def show
+ @sales_region_location = SalesRegionLocation.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @sales_region_location }
+ end
+ end
+
+ # GET /sales_region_locations/new
+ # GET /sales_region_locations/new.xml
+ def new
+ @sales_region_location = SalesRegionLocation.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @sales_region_location }
+ end
+ end
+
+ # GET /sales_region_locations/1/edit
+ def edit
+ @sales_region_location = SalesRegionLocation.find(params[:id])
+ end
+
+ # POST /sales_region_locations
+ # POST /sales_region_locations.xml
+ def create
+ @sales_region_location = SalesRegionLocation.new(params[:sales_region_location])
+
+ respond_to do |format|
+ if @sales_region_location.save
+ flash[:notice] = 'SalesRegionLocation was successfully created.'
+ format.html { redirect_to(@sales_region_location) }
+ format.xml { render :xml => @sales_region_location, :status => :created, :location => @sales_region_location }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @sales_region_location.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /sales_region_locations/1
+ # PUT /sales_region_locations/1.xml
+ def update
+ @sales_region_location = SalesRegionLocation.find(params[:id])
+
+ respond_to do |format|
+ if @sales_region_location.update_attributes(params[:sales_region_location])
+ flash[:notice] = 'SalesRegionLocation was successfully updated.'
+ format.html { redirect_to(@sales_region_location) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @sales_region_location.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /sales_region_locations/1
+ # DELETE /sales_region_locations/1.xml
+ def destroy
+ @sales_region_location = SalesRegionLocation.find(params[:id])
+ @sales_region_location.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(sales_region_locations_url) }
+ format.xml { head :ok }
+ end
+ end
+end
View
85 app/controllers/sales_regions_controller.rb
@@ -0,0 +1,85 @@
+class SalesRegionsController < ApplicationController
+ # GET /sales_regions
+ # GET /sales_regions.xml
+ def index
+ @sales_regions = SalesRegion.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @sales_regions }
+ end
+ end
+
+ # GET /sales_regions/1
+ # GET /sales_regions/1.xml
+ def show
+ @sales_region = SalesRegion.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @sales_region }
+ end
+ end
+
+ # GET /sales_regions/new
+ # GET /sales_regions/new.xml
+ def new
+ @sales_region = SalesRegion.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @sales_region }
+ end
+ end
+
+ # GET /sales_regions/1/edit
+ def edit
+ @sales_region = SalesRegion.find(params[:id])
+ end
+
+ # POST /sales_regions
+ # POST /sales_regions.xml
+ def create
+ @sales_region = SalesRegion.new(params[:sales_region])
+
+ respond_to do |format|
+ if @sales_region.save
+ flash[:notice] = 'SalesRegion was successfully created.'
+ format.html { redirect_to(@sales_region) }
+ format.xml { render :xml => @sales_region, :status => :created, :location => @sales_region }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @sales_region.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /sales_regions/1
+ # PUT /sales_regions/1.xml
+ def update
+ @sales_region = SalesRegion.find(params[:id])
+
+ respond_to do |format|
+ if @sales_region.update_attributes(params[:sales_region])
+ flash[:notice] = 'SalesRegion was successfully updated.'
+ format.html { redirect_to(@sales_region) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @sales_region.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /sales_regions/1
+ # DELETE /sales_regions/1.xml
+ def destroy
+ @sales_region = SalesRegion.find(params[:id])
+ @sales_region.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(sales_regions_url) }
+ format.xml { head :ok }
+ end
+ end
+end
View
105 app/controllers/service_centers_controller.rb
@@ -0,0 +1,105 @@
+class ServiceCentersController < ApplicationController
+ caches_page :service_center_detail
+ layout :determine_layout
+
+ def service_center_detail
+ @service_centers = ServiceCenter.find(:all, :include => :contents, :conditions => ['service_centers.active = ?', true], :order => 'service_centers.position asc')
+ @selected_service_center_id = parse_id(params[:id])
+ @service_center = @service_centers.select { |sc| sc.id == @selected_service_center_id }[0]
+ @title = 'Superior Steel &amp; Supply : Service Center : ' + @service_center.display_city
+ @body_class = 'corporate service_centers ' + hyphenate(@service_center.display_city).underscore
+ @css_imports = ['service_centers']
+ @js_imports = ['swfobject']
+ end
+
+ # GET /service_centers
+ # GET /service_centers.xml
+ def index
+ @service_centers = ServiceCenter.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @service_centers }
+ end
+ end
+
+ # GET /service_centers/1
+ # GET /service_centers/1.xml
+ def show
+ @service_center = ServiceCenter.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @service_center }
+ end
+ end
+
+ # GET /service_centers/new
+ # GET /service_centers/new.xml
+ def new
+ @service_center = ServiceCenter.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @service_center }
+ end
+ end
+
+ # GET /service_centers/1/edit
+ def edit
+ @service_center = ServiceCenter.find(params[:id])
+ end
+
+ # POST /service_centers
+ # POST /service_centers.xml
+ def create
+ @service_center = ServiceCenter.new(params[:service_center])
+
+ respond_to do |format|
+ if @service_center.save
+ flash[:notice] = 'ServiceCenter was successfully created.'
+ format.html { redirect_to(@service_center) }
+ format.xml { render :xml => @service_center, :status => :created, :location => @service_center }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @service_center.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /service_centers/1
+ # PUT /service_centers/1.xml
+ def update
+ @service_center = ServiceCenter.find(params[:id])
+
+ respond_to do |format|
+ if @service_center.update_attributes(params[:service_center])
+ flash[:notice] = 'ServiceCenter was successfully updated.'
+ format.html { redirect_to(@service_center) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @service_center.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /service_centers/1
+ # DELETE /service_centers/1.xml
+ def destroy
+ @service_center = ServiceCenter.find(params[:id])
+ @service_center.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(service_centers_url) }
+ format.xml { head :ok }
+ end
+ end
+
+
+ private
+
+ def determine_layout
+ ['service_center_detail'].include?(action_name) ? 'public' : 'admin'
+ end
+end
View
31 app/controllers/sessions_controller.rb
@@ -0,0 +1,31 @@
+# This controller handles the login/logout function of the site.
+class SessionsController < ApplicationController
+ # Be sure to include AuthenticationSystem in Application Controller instead
+ include AuthenticatedSystem
+
+ # render new.rhtml
+ def new
+ end
+
+ def create
+ self.current_superior_user = SuperiorUser.authenticate(params[:login], params[:password])
+ if logged_in?
+ if params[:remember_me] == "1"
+ self.current_superior_user.remember_me
+ cookies[:auth_token] = { :value => self.current_superior_user.remember_token , :expires => self.current_superior_user.remember_token_expires_at }
+ end
+ redirect_back_or_default('/')
+ flash[:notice] = "Logged in successfully"
+ else
+ render :action => 'new'
+ end
+ end
+
+ def destroy
+ self.current_superior_user.forget_me if logged_in?
+ cookies.delete :auth_token
+ reset_session
+ flash[:notice] = "You have been logged out."
+ redirect_back_or_default('/')
+ end
+end
View
63 app/controllers/superior_users_controller.rb
@@ -0,0 +1,63 @@
+class SuperiorUsersController < ApplicationController
+ # Be sure to include AuthenticationSystem in Application Controller instead
+ include AuthenticatedSystem
+
+ # Protect these actions behind an admin login
+ # before_filter :admin_required, :only => [:suspend, :unsuspend, :destroy, :purge]
+ before_filter :find_superior_user, :only => [:suspend, :unsuspend, :destroy, :purge]
+
+
+ # render new.rhtml
+ def new
+ end
+
+ def create
+ cookies.delete :auth_token
+ # protects against session fixation attacks, wreaks havoc with
+ # request forgery protection.
+ # uncomment at your own risk
+ # reset_session
+ @superior_user = SuperiorUser.new(params[:superior_user])
+ @superior_user.save!
+ self.current_superior_user = @superior_user
+ redirect_back_or_default('/')
+ flash[:notice] = "Thanks for signing up!"
+ rescue ActiveRecord::RecordInvalid
+ render :action => 'new'
+ end
+
+ def activate
+ self.current_superior_user = params[:activation_code].blank? ? :false : SuperiorUser.find_by_activation_code(params[:activation_code])
+ if logged_in? && !current_superior_user.active?
+ current_superior_user.activate!
+ flash[:notice] = "Signup complete!"
+ end
+ redirect_back_or_default('/')
+ end
+
+ def suspend
+ @superior_user.suspend!
+ redirect_to superior_users_path
+ end
+
+ def unsuspend
+ @superior_user.unsuspend!
+ redirect_to superior_users_path
+ end
+
+ def destroy
+ @superior_user.delete!
+ redirect_to superior_users_path
+ end
+
+ def purge
+ @superior_user.destroy
+ redirect_to superior_users_path
+ end
+
+protected
+ def find_superior_user
+ @superior_user = SuperiorUser.find(params[:id])
+ end
+
+end
View
60 app/helpers/application_helper.rb
@@ -0,0 +1,60 @@
+# Methods added to this helper will be available to all templates in the application.
+module ApplicationHelper
+
+ def user_logged_in?
+ session[:user_id]
+ end
+
+ def image_rep(string)
+ string << content_tag(:span, '', :class => 'imgrep')
+ end
+
+ def include(type,array)
+ html = ''
+
+ array.each do |item|
+ if type == 'javascript'
+ html << javascript_include_tag(item)
+ else
+ html << stylesheet_link_tag(item, :media => 'screen,projection')
+ end
+ end
+
+ html
+ end
+
+ def self.controller_name_to_page_name(current_controller)
+ titleize_string(current_controller)
+ end
+
+ def self.get_right_until(string, token)
+ token_pos = string.rindex(token)
+
+ if token_pos > 0
+ path.slice((token_pos + 1), (path.length - (token_pos + 1)))
+ else
+ string
+ end
+ end
+
+ def fckeditor_text_field(object, method, options = {})
+ text_area(object, method, options ) + javascript_tag("var oFCKeditor = new FCKeditor('" + object + "[" + method + "]');oFCKeditor.Config['CustomConfigurationsPath']='/javascripts/railsfck.js';oFCKeditor.ReplaceTextarea()")
+ end
+
+ def flash_msg
+ content_tag('p', flash[:notice], {:class => 'flash'}) unless flash[:notice].nil?
+ end
+
+ def activate_link(record)
+ record.active == 1 ? 'Deactivate' : content_tag(:span, 'Activate', {:class => 'inactive'})
+ end
+
+ def short_date(date)
+ date.strftime('%m/%d/%Y')
+ end
+
+ def pluralize_word(count, word, custom_plural = nil)
+ count > 0 ? (word.blank? ? custom_plural : word) + 's' : word
+ end
+
+end
View
2 app/helpers/contents_helper.rb
@@ -0,0 +1,2 @@
+module ContentsHelper
+end
View
2 app/helpers/conversions_helper.rb
@@ -0,0 +1,2 @@
+module ConversionsHelper
+end
View
25 app/helpers/pages_helper.rb
@@ -0,0 +1,25 @@
+module PagesHelper
+
+ def render_sales_regions_menu(product_category, collection)
+ unless collection.nil?
+ html = ''
+ line_items = content_tag(:li, product_category + ' ' + pluralize_word(collection.size,'Region') + image_tag('menu_header_corner.jpg', :size => '13x13', :alt => ''), :class => 'header')
+ line_items += render :partial => 'sales_locations/sales_region', :collection => collection
+ line_items += content_tag(:li, image_tag('spacer.gif', :size => '6x6', :alt => ''), :class => 'last')
+ html += content_tag(:ul, line_items, :class => 'menu')
+ end
+ end
+
+ def render_service_centers_menu(service_centers)
+ unless service_centers.nil?
+ html = ''
+ line_items = content_tag(:li, 'Service ' + pluralize_word(service_centers.size, 'Center') + image_tag('menu_header_corner.jpg', :size => '13x13', :alt => ''), :class => 'header')
+ service_centers.each do |sc|
+ line_items += content_tag(:li, link_to(h(sc.display_city_state), service_center_detail_path(sc), {:title => 'View the ' + h(sc.display_city) + ' service center'}))
+ end
+ line_items += content_tag(:li, image_tag('spacer.gif', :size => '6x6', :alt => ''), :class => 'last')
+ html += content_tag(:ul, line_items, :class => 'menu')
+ end
+ end
+
+end
View
2 app/helpers/product_categories_helper.rb
@@ -0,0 +1,2 @@
+module ProductCategoriesHelper
+end
View
36 app/helpers/products_helper.rb
@@ -0,0 +1,36 @@
+module ProductsHelper
+
+ def render_product_data_book(product_categories)
+ unless product_categories.nil?
+ line_items = ''
+
+ product_categories.each do |product_category|
+
+ products_list = product_line_items = ''
+
+ product_category.products.each do |product|
+
+ if product_category.products.any?
+ child_products_list = child_line_items = ''
+
+ product.children.each do |child_product|
+ child_line_items += content_tag(:li, link_to(h(child_product.name), product_detail_path(product_category.permalink, child_product)))
+ end
+
+ child_products_list += content_tag(:ul, child_line_items, {:class => 'product_children'})
+ end
+
+ product_line_items += content_tag(:li, link_to(h(product.name), product_detail_path(product_category.permalink, product)) + child_products_list)
+
+ end
+
+ line_items += content_tag(:li, h(product_category.category) + content_tag(:ul, product_line_items, :class => 'products'))
+ end
+
+ content_tag(:ul, line_items, :class => 'product_categories')
+ else
+ content_tag(:p, 'There are currently no products. Please check back soon.')
+ end
+ end
+
+end
View
2 app/helpers/sales_location_products_helper.rb
@@ -0,0 +1,2 @@
+module SalesLocationProductsHelper
+end
View
63 app/helpers/sales_locations_helper.rb
@@ -0,0 +1,63 @@
+module SalesLocationsHelper
+
+ def format_contact_info(sales_location, product_category)
+ html = content_tag(:p, content_tag(:strong, 'Contacting the ' + city_or_country(sales_location) + ' ' + product_category + ' Region:'))
+ line_items = ''
+
+ unless sales_location.address.blank?
+ a = content_tag(:strong, 'Physical Address:<br />')
+ a += sales_location.address
+ a += ' | ' + sales_location.address2 unless sales_location.address2.blank?
+ a += '<br />' + sales_location.city + ', '
+ a += state_or_country(sales_location) + ' ' + sales_location.zip
+
+ line_items += content_tag(:li, a)
+ end
+
+ unless sales_location.toll_free.blank?
+ line_items += content_tag(:li, content_tag(:strong, 'Toll Free: ' + sales_location.toll_free))
+ end
+
+ unless sales_location.phone.blank?
+ line_items += content_tag(:li, content_tag(:strong, 'Phone: ' + sales_location.phone))
+ end
+
+ unless sales_location.fax.blank?
+ line_items += content_tag(:li, content_tag(:strong, 'Fax: ' + sales_location.fax))
+ end
+
+ html += content_tag(:ul, line_items, :class => 'hasDiamonds')
+ end
+
+ def city_or_country(sales_location)
+ sales_location.united_states? ? sales_location.display_city : sales_location.country
+ end
+
+ def state_or_country(sales_location)
+ if sales_location.country == 'United States' || sales_location.country == 'Mexico'
+ sales_location.state_province_abbr
+ else
+ sales_location.country
+ end
+ end
+
+ def render_content(object, index)
+ object.contents[index].live_content unless object.contents[index].nil?
+ end
+
+ def other_sales_locations(sales_locations, selected_sales_location_id, product_category)
+ if sales_locations.size > 1 && !sales_locations.nil?
+
+ sales_locations = sales_locations.reject { |sl| sl.id == selected_sales_location_id }
+
+ html = content_tag(:h3, 'Other ' + product_category + ' Sales ' + pluralize_word(sales_locations.size, 'Region'), :class => 'secondary_subnav_header')
+ line_items = ''
+ sales_locations.each_with_index do |sl,i|
+ spacer = ((i + 1) < sales_locations.size)? ' | ' : ''
+ line_items += content_tag(:li, link_to(city_or_country(sl), view_sales_location_path(sl, sl.products[0].product_category)) + spacer)
+ end
+ html += content_tag(:ul, line_items, :class => 'secondary_subnav')
+ end
+ end
+
+end
View
2 app/helpers/sales_region_locations_helper.rb
@@ -0,0 +1,2 @@
+module SalesRegionLocationsHelper
+end
View
2 app/helpers/sales_regions_helper.rb
@@ -0,0 +1,2 @@
+module SalesRegionsHelper
+end
View
75 app/helpers/service_centers_helper.rb
@@ -0,0 +1,75 @@
+module ServiceCentersHelper
+
+ def format_contact_information(service_center)
+ html = content_tag(:p, content_tag(:strong, 'Contacting the ' + service_center.display_city + ' Service Center:'))
+
+ line_items = ''
+ unless service_center.phys_address.blank?
+ pa = service_center.phys_address
+ pa += ' | ' + service_center.phys_address2 unless service_center.phys_address2.blank?
+ pa += '<br />' + service_center.phys_city + ', '
+
+ if service_center.phys_country == 'United States'
+ pa += service_center.phys_state_province_abbr + ' ' unless service_center.phys_state_province_abbr.blank?
+ else
+ pa += service_center.phys_country + ' '
+ end
+
+ pa += service_center.phys_zip
+
+ line_items += content_tag(:li, content_tag(:strong, 'Physical Address:') + '<br />' + pa)
+ end
+
+ unless service_center.mail_address.blank?
+ pa = service_center.mail_address
+ pa += ' | ' + service_center.mail_address2 unless service_center.mail_address2.blank?
+ pa += '<br />' + service_center.mail_city + ', '
+
+ if service_center.mail_country == 'United States'
+ pa += service_center.mail_state_province_abbr + ' ' unless service_center.mail_state_province_abbr.blank?
+ else
+ pa += service_center.mail_country + ' '
+ end
+
+ pa += service_center.mail_zip
+
+ line_items += content_tag(:li, content_tag(:strong, 'Mailing Address:') + '<br />' + pa)
+ end
+
+ unless service_center.toll_free.blank?
+ line_items += content_tag(:li, content_tag(:strong, 'Toll Free: ' + service_center.toll_free))
+ end
+
+ unless service_center.phone.blank?
+ line_items += content_tag(:li, content_tag(:strong, 'Phone: ' + service_center.phone))
+ end
+
+ unless service_center.fax.blank?
+ line_items += content_tag(:li, content_tag(:strong, 'Fax: ' + service_center.fax))
+ end
+
+ html += content_tag(:ul, line_items, :class => 'hasDiamonds')
+
+ html
+ end
+
+ def render_content(object,index)
+ object.contents[index].live_content unless object.contents[index].nil?
+ end
+
+ def other_service_centers(service_centers, id)
+ if service_centers.size > 1 && !service_centers.nil?
+ html = content_tag(:h3, 'Other Service ' + pluralize_word(service_centers.size, 'Center'), :class => 'secondary_subnav_header')
+ line_items = ''
+
+ service_centers = service_centers.reject! { |service_center| service_center.id == id }