=f.inputs do
  :javascript
    var p_product_refs_url = "#{admin_p_product_refs_path(:manager => true)}"

  -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande")

    = f.hidden_field :p_customer_id, :class => "p_customer_id"
    =content_for :particular do
      .row
        .p_customer_sheet_customer.col-12.mb-4


          -if f.object.p_customer and f.object.p_customer.particular
            =render :partial => "admin/p_customers/apercu", :locals => {:particular => f.object.p_customer.particular}
        .col-6
          .addresses.row
            .columns.span_6
              %h4 Adresse de facturation

              -if f.object.p_customer
                =f.inputs do
                  = f.input :particular_bill_id, :collection => f.object.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de facturation"
              -else
                =f.inputs do
                  = f.input :particular_bill_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation"
        .col-6
          .addresses.row
            .columns.span_6
              %h4 Adresse de livraison

              -if f.object.p_customer
                =f.inputs do
                  = f.input :particular_send_id, :collection => f.object.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de livraison"
              -else
                =f.inputs do
                  = f.input :particular_send_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation"

            .clear

    =content_for :shipping_date do
      = f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date
      = f.input :ct_creation_date, :label => "Date de commande (si différente de la date de création) :", :as => :date
      = f.input :validation_date, :label => "Date de validation :", :as => :date



    = f.input :customer_ref, :label => "Référence commande client :"
    -if current_admin.has_permission?("customer-sheets-bl")
      =# f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"}

    -if @p_customer_sheet and @p_customer_sheet.p_customer and @p_customer_sheet.p_customer.p_customer_sheet_note?
      %div
        %strong Notes pour les demandes de commandes pour ce client :
        =simple_format @p_customer_sheet.p_customer.p_customer_sheet_note
        %br



    =content_for :price_lines do
      %div{:style=>"padding:0 30px;"}
        .row.qi_field_wrapper
          %table{:style => "width:100%;border-collapse:separate;"}
            %thead
              %tr
                %th
                %th Produit
                %th{:style => "width:200px;"} Prix
                %th
                %th{:style => "width:100px;"} Qté
                %th TVA
                %th
            %tbody.price_lines_form
              =f.semantic_fields_for :price_lines do |f|
                =render :partial => "admin/price_lines/form", :locals => {:form => f}

          %p{:style=>"padding-top:10px;"}= link_to_add_fields ic("plus-circle") + " ligne", f, :price_lines, {:class => "btn btn-primary p-2", tabindex: 10, style: "position: sticky; top: 100px"}


  -if current_admin.has_permission?("payments")
    =content_for :discount do
      -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande")
        -if !@avoir
          = f.input :ct_tot_discount_percent, :label => "Réduction pied de page (%) :", :input_html => {:class => "input_price_line_block_ct_tot_discount_percent"}
        = f.input :ct_tot_fdp_ht, :label => "Frais de port personnalisés :"


  -if current_admin.has_permission?("payments")
    -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande")
      - if f.object.id
        .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"}
          %h4 Paiements

          = f.input :p_payment_type_id, :label => "Type de paiement :", :include_blank => false, :collection => PPaymentType.order(:name).all, :as => :select, :input_html => {:id => "payment_type_id_select"}


          = f.input :ct_payment_comptant, :label => "Paiement comptant nécessaire ?"

          -if false
            = f.input :ct_acompte, :label => "Acompte nécessaire ?"
            = f.input :ct_acompte_percent, :label => "Pourcentage d'acompte :"

          = f.input :ct_payment_delais, :label => "Délais jour de paiement :"

          -if false
            = f.input :ct_payment_month_end, :label => "Fin de mois ?"




