class CustomerMailer < ApplicationMailer
  layout "mail"
  # Subject can be set in your I18n file at config/locales/en.yml
  # with the following lookup:
  #
  #   en.customer.confirm.subject
  #
  def confirm(customer)
    @customer = customer

    mail to: customer.email, :subject => "Important : Activation de votre compte Négos"
  end

  def validate_account(customer)
    @customer = customer

    mail to: customer.email, :subject => "Important : Validation de votre compte Négos"
  end

  def confirm_ins(customer)
    @customer = customer

    mail to: customer.email, :subject => "Confirmation d’inscription"
  end

  def validate_ins(customer)
    @customer = customer

    mail to: customer.email, :subject => "Bienvenue chez NEGOS"
  end

  def notify_ins(customer)
    @customer = customer

    mail to: "daniel@videlier.fr", bcc: "info@nicolasbally.com", :subject => "Nouveau compte client sur Negos"
  end

  def validate_need(need)
    @need = need
    @customer = need.author
    mail to: @customer.email, :subject => "Proposition de besoin validée"
  end

  def refuse_need(need)
    @need = need
    @customer = need.author
    mail to: @customer.email, :subject => "Proposition de besoin refusée"
  end

  def negociate_need(need, customer)
    @need = need
    @customer = customer
    mail to: @customer.email, :subject => "Négociation en cours pour le besoin #{@need.title}"
  end


  def need_negociated(customer ,need)
    @need = need
    @customer = customer
    mail to: @customer.email, :subject => "Besoin #{@need.title} négocié !"
  end


  def need_negociation_failed(customer, need)
    @need = need
    @customer = customer
    mail to: @customer.email, :subject => "Négociation échouée pour le besoin #{@need.title}"
  end

  def need_commented(customer, need, comment)
    @need = need
    @customer = customer
    @comment = comment
    mail to: @customer.email, :subject => "Nouveau commentaire pour le besoin #{@need.title}"
  end


  def offer_accepted(customer, accepted_offer)
    @accepted_offer = accepted_offer
    @customer = customer
    mail to: @customer.email, :subject => "Vous avez accepté une offre"
  end


  def document_available(customer, document)
    @document = document
    @customer = customer
    mail to: @customer.email, :subject => "Document disponible pour l'offre #{@document.accepted_offer.offer.need.title}"
  end


  def document_verified(customer, document)
    @document = document
    @customer = customer
    mail to: @customer.email, :subject => "Document vérifié pour l'offre #{@document.accepted_offer.offer.need.title}"
  end


  def contact_message_received(customer, contact_message)
    @contact_message = contact_message
    @customer = customer
    mail to: @customer.email, :subject => "Message reçu"
  end


  def new_user(customer)
    @customer = customer
    @parent = @customer.parent
    if @parent
      #mail from: "no-reply@negos.pro", to: @parent.email, :subject => "Vous avez un nouvel affilié sur Negos.pro !" do |format|
       # format.html { render layout: false }
      #end
    end
  end

  # Subject can be set in your I18n file at config/locales/en.yml
  # with the following lookup:
  #
  #   en.customer.reset_password.subject
  #

  def new_message(customer)
    @customer = customer

    mail from: "Négos.com <contact@negos.pro>", to: customer.email, :subject => "Vous avez un nouveau message privé"
  end

  def password_reset(customer)
    @customer = customer
    mail :to => @customer.email, :subject => "Reinitialisation du mot de passe.", :from => "Négos.com <contact@negos.pro>"
  end

  def new_commission(commission)
    @commission = commission

    if @commission.commission_type_id == 1 or @commission.commission_type_id == 2 or @commission.commission_type_id == 3
      mail from: "contact@negos.pro", to: @commission.customer.email, :subject => "Vous avez reçu une commission sur Négos.com !" do |format|
        format.html { render layout: false }


      end

    end
  end

end
