class Public::MyAccountController < ApplicationController
  
  layout "public"
  
  before_filter :auth_product_customer
  
  def index
    
  end

  def edit_infos
    @no_search = true
  end

  def my_annonces
    @no_search = true
  end
  
  def binary
    @no_search = true
    if params[:parrain_id] and current_product_customer.binary_child_ids.include?(params[:parrain_id].to_i)
      @parrain = ProductCustomer.find(params[:parrain_id])
      
      
      
    else
      @parrain = current_product_customer 
    end
  end
  
  def filleuls
    @no_search = true
    @filleuls = current_product_customer.children
    
    session[:mail_prev] = public_filleuls_path
    
  end
  
  def reconfirm
    @no_search = true
    ProductCustomerMailer.confirm(current_product_customer).deliver
    
    redirect_to public_my_account_path, :notice => "Le mail vous a été renvoyé"
  end
  
  
  def favoris
    
    per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 10
    
    page = (params[:page] and params[:page] != "") ? params[:page] : 1 
    
    @annonces = current_product_customer.annonce_favs.valid_to_show
    @annonces = @annonces.page(page).per(per_page).all
  end
  
  
end
