.qi_header
  %h1
    Documents
    %span
      Liste des documents


.qi_row
  .qi_pannel.qi_plain.padding
    
    -if params[:print]
      %p
        Date du document :
        =Time.now
    -else
      =form_tag "", :method => "get",  :onsubmit => "", :autocomplete => "off" do
    

    
        -if @p_customer
          .customer_label
            =link_to @p_customer.show_name, [:admin,@p_customer ]
        -if false and @p_customer
          .customer_label
            =@p_customer.show_name
            =link_to ic(:times),"#", :onclick => "$(this).closest('.customer_label').next('input').val('');$(this).closest('.customer_label').remove();return false;"
        =hidden_field_tag :p_customer_id, params[:p_customer_id],:class => "form-control", :placeholder => "Client" if params[:p_customer_id]
    
      
      
        %table.search_table
          %tr
            %td.search_label
              Début
            %td
              .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)
            
              %br
              -if @start and @stop
              
                =link_to "< Mois précédent",request.query_parameters.merge({start: ((@start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-default"
            
      
            %td.search_label
              Fin
            %td
              .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)
              %br
              -if @start and @stop
                =link_to "Mois suivant >",request.query_parameters.merge({start: ((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-default"
          
          
            -params[:p_document_type_ids] = params[:p_document_type_ids] || []
            %td.search_label
              Type de document :
            %td.search_case
            
              -PDocumentType.where(:enabled => true).order("position").each do |pdt|
                %p
                  = check_box_tag :"p_document_type_ids[]", pdt.id, (true if params[:p_document_type_ids].include?(pdt.id.to_s)), {:id => "p_document_type_ids_#{pdt.id}"}
                  = label_tag "p_document_type_ids_"+pdt.id.to_s, pdt.name
          
            %td.search_label
              Détail ?
            %td.search_case
              = check_box_tag :detail, "true", params[:detail]
          
    
        =submit_tag "Recherche", :class => "btn btn-default", :style => "margin-bottom: 10px;"
    :scss
      .search_case{
        label{
        float:left;
        padding-left:5px;
        
        
              }
              input{
                display:block;
                padding-right:5px;
                float:left;
                clear:both;
              }
      }
      .search_table{
        td{
          padding-left:5px;
          vertical-align:top;
        }
      }
    =render :partial => "index"
    
    
    =link_to "Version imprimable",request.query_parameters.merge({print: true}), :class => "btn btn-default" if !params[:print]