.qi_header

  %h1 

    Administrateurs
    
    %span
      Détail de
      =@admin.firstname
      =@admin.name
    
.qi_row
  .qi_pannel.qi_plain.padding
    %h2 Suivi temps
    
    =form_tag "", :method => "get", :remote => false, :onsubmit => "set_busy();" do
    
      .row.qi_cancel_margins
        .col-xs-4
          .input-group
            =text_field_tag :start, params[:start],:class => "form-control datepicker", :placeholder => "Début"
            %span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"}
              =ic(:times)
        
        .col-xs-4
          .input-group
            =text_field_tag :stop, params[:stop],:class => "form-control datepicker", :placeholder => "Fin"
            %span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"}
              =ic(:times)
    
      
        
        .col-xs-2
          
          =submit_tag "filtrer", :class => "btn btn-default", :style => "margin-bottom: 10px;"
      
      %p
        -if @start and @stop
          =link_to "< Jour précédent","?start=#{CGI.escape((@start - 1.day).strftime('%d/%m/%Y'))}&stop=#{CGI.escape((@stop - 1.day).strftime('%d/%m/%Y'))}", :class => "btn btn-default"
        -if @start and @stop
          =link_to "Jour suivant >","?start=#{CGI.escape((@start + 1.day).strftime('%d/%m/%Y'))}&stop=#{CGI.escape((@stop + 1.day).strftime('%d/%m/%Y'))}", :class => "btn btn-default"
      
    
    %table.table
      %thead
        %tr
          %th Client
          %th Temps passé
          %th
      -@timer_watchers.group(:p_customer_id).order("p_customer_id DESC").uniq.each do |twp|
        %tbody
          %tr
            %td
              -if twp.p_customer
                =link_to twp.p_customer.show_name, admin_p_customer_path(twp.p_customer)
              -else
                Non défini
            %td{:style => "text-align:right;"}
              =format_time( @timer_watchers.where(:p_customer_id => twp.p_customer_id).sum(:time_ok).to_i )
            %td  
              =link_to "Détail +", "#", :onclick => "$(this).closest('tbody').next('tbody').toggle();return false;"
            
        %tbody{:style => "display:none;color:rgba(0,0,0,0.5) !important;"}    
          -@timer_watchers.where(:p_customer_id => twp.p_customer_id).each do |tw|
          
            %tr
              %td=l tw.created_at
            
              %td{:style => "text-align:right;"}
                =format_time(tw.time_ok)
              %td
              
      %tbody
        %tr
          %td
          %td
        %tr
          %td
            %strong Total
        
          %td{:style => "text-align:right;"}
        
            =format_time(@timer_watchers.sum(:time_ok))
          
          
          
          
          
            