Rails.application.routes.draw do
  
  constraints :subdomain => /^(?!commander|negos)(\w+)/ do
    get "/" => 'public/reseauxes#find_sub_domain'
  end
  
  constraints subdomain: 'commander' do

    get "/" => "public/home#vouisstar"
  end
  
  constraints domain: ['negos.pro', 'negos.quartz.xyz', "localhost"] do
  
    get 'mail_assets/:token.png' => "admin/mail_trackings#update", :as => :image_tracking

    get "vouisstar" => "public/home#vouisstar"
  
  
    get "/ogoneipn" => "public/payments#ogone_ipn", :as => :ogone_ipn_public_payments
  
  

    get "affiliation/:mlm_token" => "public/home#affiliation"
    get "affiliation" => "public/home#affiliation"




    get 'p/:mlm_token' => "public/customers#parrainage", :as => :mlm_token

    namespace :public do
    
      resources :payments do
        member do 
          get :paid_by_ogone
          get :paid_by_ogone_confirm
          get :paid
        end
        collection do
          get :ogone_ipn
        end
      end
      resources :abonnements
    
      resources :conversations
      get 'documents/:download_token', to: 'documents#download', as: :download_document


      resources :customer_favs
      resources :customer_ribs do

      end
      resources :annonce_cats do
        collection do
          get :search
        end
      end
      resources :commissions
      resources :orders do
        collection do
          get :e_trans_cancel
          get :e_trans_ipn
          get :e_trans_refuse
          get :e_trans_effectue

          get :billing
          get :bills
        end

        member do
          get :bill_print
          get :paid
          get :paid_force

        end
      end
      resources :credit_products
      resources :cities do
        collection do
          get :search
        end
      end
      resources :credits
      resources :mlm_points

      resources :annonce_photos do
        member do
         get :rotate
        end
      end
      resources :annonces do
        collection do



          get :geocode
        end
        member do
          get :photos
          get :specific
          get :publish
          get :contact
          get :options
          get :buy_option
        end
      end
      get 'my_account/mes-reseaux' => "my_account#my_reseauxes", :as => "my_reseauxes"
      get 'my_account/favoris', :as => "favs"
      get 'my_account/filleuls', :as => "filleuls"
      get 'my_account/binary', :as => "binary"
      get 'my_account/index', :as => "my_account"
      get 'my_account/edit_infos', :as => "edit_infos"
      get 'my_account/my_annonces', :as => "my_annonces"
      get 'my_account/reconfirm', :as => "reconfirm_email"

      resources :accepted_offers do

        resources :documents do
          member do
            get :download
            get :download_returned
            post :upload_returned
            get :destroy_returned

          end
        end


      end
      resources :needs do
        get :download_devis
        resources :messages
        resources :wishes do
          member do
            get :download_devis
          end
        end
        resources :offers do
          member do
            get :accept
            post :accept_save
          end
        end
        member do
          get 'wish', as: 'wish'
        end
      end

      resources :contact_messages do

      end

    end



    get "evenements/:id.html" => "public/events#show", :as => "public_event"
    get "evenements.html" => "public/events#index", :as => "public_events"


    post "search.:f" => "public/annonces#search", :as => :search_public_annonces, :f => "html"
    get "search.:f" => "public/annonces#search", :f => "html"


    constraints subdomain: 'blog' do
        get "blog/archives/:year/:month.html"=> "public/articles#archives", :as => :archive_public_article
        get "blog/tags/:id.html"=> "public/articles#tags", :as => :public_tag
        get "blog/categorie/:slug.:f"=> "public/articles#category", :as => :category_public_article, :f => "html"
        get 'blog/:id.html' => "public/articles#show", :as => "public_article"
      	get 'blog/:slug.:f' => 'public/articles#show', :as => :article, :f => "html"
      	get 'blog.:f' => 'public/articles#index', :as => :articles, :f => "html"
        get '/' => 'public/articles#index'

    end





    get "/" => "public/ebooks#show",:id => "arreter-de-fumer" ,:constraints => {:domain => ["arreter-de-fumer-avec-eft.dev", "bally.me", "arreter-de-fumer-avec-eft.com"]}




    get "categorie/:id.:f" => "public/annonces#search", :as => :public_annonce_category, :f => "html"
    post "categorie/:id.:f" => "public/annonces#search", :as => :post_public_annonce_category, :f => "html"




    get "sitemap.:f" => "public/sitemap#sitemap"
    namespace :public do
      resources :product_order_documents
      get :my_cart, to: "product_orders#my_cart"
    
    
      resources :militer_cats
    
      resources :product_sizes

      resources :product_images

      resources :product_categories

      resources :products

      resources :product_orders do
        member do
          get :payment_instructions
        end
      
        collection do
          get :paid_by_ogone
          get :paid_by_ogone_confirm
                
          post :payplug_ipn
        
          post :vourcher
        
          get :particulars
          post :particulars_save
          get :select_payment
          get :select_fdp
          post :select_fdp_save
          get :select_fdp_save
          post :select_payment_save
        
        
          get :payment_instructions
        
        end
      
      end
      resources :product_order_products
    
    
      resources :product_customers do
        member do
          get :confirm
          get :mail
          get :mail_confirm
          get :show_details
        end

        collection do
          get :find_parrain
        end

      end

      resources :product_customers_auths do

        collection do

          get :logout

        end
      end
    
      resources :reseauxes do
        resources :products
        resources :product_orders
        resources :customers do


        end
      
      end
      resources :virements
      resources :comments
      resources :customer_messages do
        member do
          get :answer
          post :answer_save
        end
      end
    
    
      resources :customers do
        member do
          get :confirm
          get :mail
          get :mail_confirm
          get :show_details
        end

        collection do
          get :find_parrain
        end

      end

      resources :customers_auths do

        collection do

          get :logout

        end
      end

      resources :password_resets

    end

    namespace :portlet do
      resources :event_contents
      resources :break_contents
      resources :download_contents
      resources :dynamic_contents
      resources :gallery_contents
      resources :gallery_images do
        collection do
          get :reorder
        end
      end
      resources :html_contents
      resources :image_contents
      resources :link_contents
      resources :img_link_contents
      resources :text_contents
      resources :map_contents
      resources :title_contents
      resources :table_contents
      resources :block_contents
      resources :table_rows
      resources :table_cols
      resources :portlets do
        collection do
          post :reorder
        end
      end
    end

    namespace :admin do
      resources :fournisseurs
      resources :product_order_documents
      resources :product_order_document_types
      resources :product_order_payments
      resources :product_orders do
        collection do
          get :export
          get :export2
        end
        member do
          get :ship
          get :bill
          get :bl
          get :subs
        end
      end
      
      
        resources :product_sizes do
          collection do
            get :reorder
        end
      end
        resources :product_images do
          collection do
            get :reorder
        end
      end
        resources :product_categories do
          collection do
            post :reorder
        end
          resources :product_collections
      end
        resources :products do
          collection do
            post :reorder
        end
        
          member do
            get :stock
        end
      
      end
      
  
    
    
    
      resources :reseauxes
      resources :documents

      resources :domains
      resources :annonces do

      end

      resources :orders do
        member do
          get :cancel
          get :force_pref
          post :force
        end
      end

      resources :virements do
        member do

          get :valid
        end
      end
      resources :virement_remises do
        member do

          get :sended
        end
      end
      resources :annonces
      resources :annonce_photos
      resources :customer_ribs do
        member do

          get :valid
        end
      end
      resources :newsletters do
        member do
          get :history
          get :history_detail

          get "select_recipients"
          put "select_recipients"
          post "send_test"
          post "send_newsletter"
        end
      end



      resources :need_categories
      resources :needs do
        get :download_devis
        resources :messages
        resources :wishes do
          member do
            get :download_devis
          end
        end
        resources :offers do

        end
        member do
          get :validate
          get :refuse
          get :negociate
          get :accept
          get :reject
          get :back_to_verified
          get :back_to_negociating
        end
      end

      resources :conversations do

      end

      resources :contact_messages do

      end
      resources :offers do
        resources :accepted_offers do
          resources :documents do
            post :upload_document
            post :upload_returned_document
            get :download
            get :download_returned
            get :delete
            get :delete_returned
            get :verify_returned
            get :destroy
            get :force_verified
          end
          member do
            get :validate_all_documents
          end
        end

        member do
          get :download_zip
          get :upload_documents
          post :upload_documents
          get :accepted
        end
      end
      get :connected_customers, to: "customers#connected_customers"
      resources :customers do

        member do

          get :validate
        end
      end

  		resources :categories do
  			collection do
  				post :reorder
  			end
  		end
      resources :annonce_cats
      resources :comments
      resources :articles
      resources :events

      resources :tags
      resources :password_resets

      resources :admin_auths do
          collection do
            get :logout
          end
      end

      resources :admins



      resources :external_links do
        collection do
          get :cible
        end
      end


      resources :menus
      resources :menu_items do
        collection do
          get :cible
          post :reorder
          get :import
        end
        member do
          get :clone
        end
      end
      resources :image_files do
        member do
          get :rotate
        end
      end
      resources :file_folders
      resources :data_files
      resources :pages
      resources :menu_urls
      resources :menu_aliases
      resources :blocks
      resources :albums
      resources :cibles


    end

    resources :download_data_files

    get 'admin' => "admin/admin_auths#index"

    get '*url.html' => 'public/menu_items#show', :as => :menu_item, :f => "html"
    get '*url.:f' => 'public/menu_items#redirect',  :f => "html"
    
    
    get "/" => 'public/needs#index'
  end


  #root ""

  #root 'public/needs#index'

  


end
