.qi_header
  .right
    =@s_project.state_to_text[@s_project.nav_project_status.to_i]
  %h1
    Projet
    
    - @s_project.ancestors.reverse.each do |s_project|
      %span=link_to s_project.name, [:admin, s_project]
    
    %span
      =@s_project.p_number
      =@s_project.name
      


-if @s_project.description?
  .qi_row
    .qi_pannel.qi_plain.padding
      =simple_format @s_project.description
    
  

  

:scss
  .qi_tab_content{
    border:1px solid #ddd;
    border-top:0;
    .qi_tab_header{
      padding:10px 20px;
      h3{
        padding:0;
        margin:0;
      }
      
    }
    min-height:1000px;
    margin-bottom:300px;
    background:white;
    
    
  }


    
.qi_row#tabs
  .qi_pannel
    %ul.nav.nav-tabs
      -if @s_project.children.count > 1
        -params[:tab] = params[:tab] || "projets"
      -else
        -params[:tab] = params[:tab] || "bills"
      
      %li{:class => ("active" if params[:tab] == "projets")}=link_to "Sous projets", "?tab=projets#tabs"

      -if current_admin.has_permission?("bills")
        %li{:class => ("active" if params[:tab] == "bills")}=link_to "Factures & Avoirs", "?tab=bills#tabs"
      
      
      -if current_admin.has_permission?("serials")
        %li{:class => ("active" if params[:tab] == "serials")}=link_to "Modules", "?tab=serials#tabs"
    
    .qi_tab_content
      -if params[:tab] == "projets"
        #offres
      
          .qi_tab_header
            .right= link_to 'Créer un sous projet ', new_admin_s_project_path(:parent_id => @s_project.id), :class => "btn btn-primary bgbd-ventes", :remote => false
   

     
     
     
          -params[:search][:per_page] = params[:search][:per_page] || 50
          -per_page = params[:search][:per_page]
          -page = (params[:page] and params[:page] != "") ? params[:page] : 1 
          -@s_projects =@s_project.children
          -@s_projects = sort_by_sorting(@s_projects, "created_at DESC")
          -@s_projects = @s_projects.page(page).per(per_page)

          =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @s_projects}
     
  
      
        
      -if params[:tab] == "bills"
        #bills
          -params[:search][:per_page] = params[:search][:per_page] || 50
          -per_page = params[:search][:per_page]
          -page = (params[:page] and params[:page] != "") ? params[:page] : 1 
          
          -@price_documents = @s_project.price_documents.where(:price_document_type_id => [1,2]).order("date DESC, created_at DESC")

          -@price_documents = sort_by_sorting(@price_documents, "created_at DESC")
          -@price_documents = @price_documents.page(page).per(per_page)
    
          =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents}
      



      -if params[:tab] == "serials"
        #serials
          .right= link_to 'Ajouter un module', admin_s_modules_path(:s_project_id => @s_project.id), :class => "btn btn-primary bgbd-ventes", :remote => false
          %table.table
            %tr
              %th Numéro de série
              %th cache_long_serial_number
              %th s_modules_state_id
              %th order_date
              %th.actions


            %tbody#s_modules_rows
              -@s_project.s_project_modules.each do |s_project_module|
                =render :object => s_project_module.s_module, :partial => "admin/s_modules/s_module", :locals => {:s_project_module => s_project_module}