%tr#p_commercial{:id => p_commercial.id}
  %td
    = p_commercial.p_commercial_cat.name if p_commercial.p_commercial_cat
  %td
    = p_commercial.code
  %td
    = p_commercial.firstname
    = p_commercial.name
  
  %td
    = p_commercial.email
  %td
    = p_commercial.phone
    
 
  

  %td.actions
    -year = 2020
    -if pco = p_commercial.p_commercial_objectives.where("start_at >= ? and start_at <= ?", Date.parse("#{year}/01/01"), Date.parse("#{year}/12/31")).first
      =link_to "Voir l'objectif #{year}", admin_p_commercial_objective_path(pco)
    -else
      =link_to "Saisir les objectifs pour #{year}", new_admin_p_commercial_objective_path(:start_at => year, :p_commercial_id => p_commercial.id), :class => "btn btn-default"
    
  
  
    -year = 2021
    -if pco = p_commercial.p_commercial_objectives.where("start_at >= ? and start_at <= ?", Date.parse("#{year}/01/01"), Date.parse("#{year}/12/31")).first
      =link_to "Voir l'objectif #{year}", admin_p_commercial_objective_path(pco)
    -else
      =link_to "Saisir les objectifs pour #{year}", new_admin_p_commercial_objective_path(:start_at => year, :p_commercial_id => p_commercial.id), :class => "btn btn-default"
    
  
    = link_to i(:"trash-o"), [:admin, p_commercial], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
    = link_to i(:pencil), edit_admin_p_commercial_path(p_commercial), :remote => true
    
    -if false
      = link_to i(:eye), admin_p_commercial_path(p_commercial)

