.qi_header
  .right
    =link_to ic(:pencil), edit_admin_m_odr_file_path(@m_odr_file)
  %h1
    Primes
    %span
      Factures
    %span 
      Détail d'une
      =@m_odr_file.m_odr_file_type.name
      


=debug @m_odr_file.nbr_pneus

Historique des factures

-params[:search][:per_page] = params[:search][:per_page] || 50
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1 
-@m_odr_files = @m_odr_file.p_customer.m_odr_files.where("id != ?", @m_odr_file.id).where(:m_odr_file_type_id => @m_odr_file.m_odr_file_type_id )
-@m_odr_files = sort_by_sorting(@m_odr_files, "created_at DESC")
-@m_odr_files = @m_odr_files.page(page).per(per_page)

=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_files}

%hr

.left{:style => "float:left;width:30%;"}
  .qi_row
    .qi_pannel.qi_plain.padding
      %table.table
        %tr
          %td Utilisateur
          %td=@m_odr_file.p_customer.show_name if @m_odr_file.p_customer
        
        %tr
          %td Date de la facture
          %td=@m_odr_file.buy_at
        
        %tr
          %td Validé ?
          %td
            -if @m_odr_file.admin_ok
              Oui
            -else
              Non
          
        
        -if @m_odr_file.m_odr_file_type_id == 2
          %tr
            %td
              Revendeur
              
            %td=@m_odr_file.m_odr_place.name if @m_odr_file.m_odr_place
            
      -if @m_odr_file.m_odr_file_type_id == 2
        Produits :
        %table.table
          -@m_odr_file.m_odr_file_products.each do |m_odr_file_product|
            %tr
              %td
                =m_odr_file_product.m_odr_product_size.name if m_odr_file_product.m_odr_product_size
              %td
                =m_odr_file_product.qte
              %td
                =number_to_currency m_odr_file_product.price if m_odr_file_product.m_odr_product_size
          

      -else
        Roulages :
        %table.table
          -@m_odr_file.m_odr_file_roulages.each do |m_odr_file_roulage|
            %tr
              %td
                =m_odr_file_roulage.date
            
              %td
                =m_odr_file_roulage.m_event.title if m_odr_file_roulage.m_event
      -if @m_odr_file.admin_ok == true
        -if @m_odr_file.m_odr_file_type_id == 2
          =link_to ic(:envelope)+"Envoyer un mail demandant la facture de roulage", send_mail_admin_m_odr_file_path(@m_odr_file, :slug => "achat-manque-roulage"), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;"
      
        -else
          -slugs = MailType.where(:mail_type_cat_id => 4).map{|m| m.slug}
        
          -slugs.each do |slug|
            %br
            =link_to ic(:envelope)+" #{slug}", send_mail_admin_m_odr_file_path(@m_odr_file, :slug => slug), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;"
        
        
      -if @m_odr_file.admin_ok == false
        .red Facture refusée
        Envoyer un mail de notification :
        
        -if @m_odr_file.m_odr_file_type_id == 2
          -slugs = MailType.where(:mail_type_cat_id => 2).map{|m| m.slug}
        -else
          -slugs = MailType.where(:mail_type_cat_id => 3).map{|m| m.slug}
        
        -slugs.each do |slug|
          %br
          =link_to ic(:envelope)+" #{slug}", send_mail_admin_m_odr_file_path(@m_odr_file, :slug => slug), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;"
      
      
         
  

#show{:style => "margin-left:31%;"}
  =link_to ic(:download)+" Télécharger le document", download_admin_m_odr_file_path(@m_odr_file, :disposition => "attachment")


  -if File.extname(@m_odr_file.file.path) == ".pdf" || File.extname(@m_odr_file.file.path) == ".PDF"
    
    %iframe{:src => @m_odr_file.file.url, :style => "width:100%;height:800px;border:1px solid gray;"}

  -else
    &nbsp;&nbsp;
    =link_to ic(:"rotate-left"), rotate_admin_m_odr_file_path(:id => @m_odr_file.id, :direction => "right"), :remote => true
    &nbsp;&nbsp;
    =link_to ic(:"rotate-right"), rotate_admin_m_odr_file_path(@m_odr_file), :remote => true
    #image_previ{:style => "width:100%;height:800px;border:1px solid gray;overflow:auto;"}
      =render :partial => "admin/m_odr_files/image", :locals => {:file => @m_odr_file}

.clear
%hr
Historique des mails envoyés

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

=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @mail_hists}


.clear