Sources::Application.routes.draw do

  root :to => 'index#index'

  resources :index, :only => :index
  match '/search' => 'index#search', as: :index_search
  resources :about, :only => :index
  resources :history, :only => :index
  resources :contact, :only => :index
  resources :services, :only => :index
  resources :manufacture, :only => :index
  resources :news, :only => [:show, :index]
  resources :med, :only => [:show, :index]
  resources :partners, :only => [:show, :index]
  resources :projects, :only => [:show, :index]
  resources :certificates, :only => [:show, :index]
  resources :product, :only => :show
  resources :order, :only => :index

  get 'contact' => 'contact#index', :as => :contact
  get '/order' => 'order#show', :as => :order_show
  post '/order' => 'order#confirm', :as => :order_confirm # confirm order
  post '/order/add_product' => 'order#add_product' # add product to order
  post '/order/remove_product' => 'order#remove_product' # remove product from order

  match '/catalogue/c' => 'catalogue#index', :as => :catalog_categories_index
  match '/catalogue/c/:id' => 'catalogue#show', :as => :catalogue_category
  match '/catalogue/c/:id/info' => 'catalogue#info', :as => :catalogue_category_info

  match '/catalogue/m' => 'catalogue#index_by_manufacturer', :as => :catalogue_categories_index_by_manufacturer
  match '/catalogue/m/:id' => 'catalogue#show_by_manufacturer', :as => :catalogue_category_by_manufacturer
  match '/catalogue/m/:id/info' => 'catalogue#info_by_manufacturer', :as => :catalogue_category_info_by_manufacturer

  get 'int/en' => 'international#english', :as => :international_english
  #get '/med', to: 'med#index'

  match '*\.php' => redirect('/news/288') # redirect for old links

  namespace :admin do
    get '', to: 'admin#index', as: '/'
    resources :news_items, except: :show
    resources :banners, except: :show
    resources :certificates, except: :show
    get 'company_info', to: 'company_info#index'
    put 'company_info', to: 'company_info#update'
    resources :manufacturers, except: :show
    resources :med_items, except: :show
    resources :projects, except: :show
    resources :products, except: :show do
      collection do
        get 'typeahead_get_data'
      end
      get 'new_from_copy'
    end
    resources :admin_users, except: :show
    resources :orders, except: :show do
      collection do
        delete 'destroy_old'
      end
    end
    resources :catalogue_categories, except: :show do
      collection do
        get 'tree_get_data'
        post 'tree_move_node'
      end
    end

    resources :rich_text_image, only: :create
    resources :rich_text_document, only: :create
  end


  # The priority is based upon order of creation:
  # first created -> highest priority.

  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Sample resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', :on => :collection
  #     end
  #   end

  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => 'welcome#index'

  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id))(.:format)'
end
