suite
This commit is contained in:
parent
79b1e46daa
commit
05ed715d34
@ -17,3 +17,15 @@
|
|||||||
|
|
||||||
$(".new_field").removeClass "new_field"
|
$(".new_field").removeClass "new_field"
|
||||||
false
|
false
|
||||||
|
|
||||||
|
@qi_add_fields = (link, association, content) ->
|
||||||
|
new_id = new Date().getTime()
|
||||||
|
regexp = new RegExp("new_" + association, "g")
|
||||||
|
content_final = content.replace(regexp, new_id).replace(association + "_class", "new_field")
|
||||||
|
|
||||||
|
form_element = $("." + association + "_form")
|
||||||
|
|
||||||
|
form_element.append content_final
|
||||||
|
|
||||||
|
$(".new_field").removeClass "new_field"
|
||||||
|
false
|
@ -11,6 +11,10 @@ class Admin::PDocumentsController < ApplicationController
|
|||||||
@admin_space = "documents"
|
@admin_space = "documents"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def search_to_affect
|
||||||
|
@p_customer = PCustomer.where(:id => params[:p_customer_id]).first
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@p_documents = PDocument.order("created_at DESC")
|
@p_documents = PDocument.order("created_at DESC")
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ class PCustomer < ActiveRecord::Base
|
|||||||
validates :siren, :presence => true, :if => :valid_siren?
|
validates :siren, :presence => true, :if => :valid_siren?
|
||||||
validates :ape, :presence => true, :if => :valid_siren?
|
validates :ape, :presence => true, :if => :valid_siren?
|
||||||
|
|
||||||
|
has_many :p_documents
|
||||||
|
|
||||||
|
|
||||||
belongs_to :p_price_cat
|
belongs_to :p_price_cat
|
||||||
|
@ -15,6 +15,7 @@ class PDocument < ActiveRecord::Base
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
has_many :p_payment_documents, :dependent => :destroy
|
has_many :p_payment_documents, :dependent => :destroy
|
||||||
|
|
||||||
belongs_to :element, :polymorphic => true
|
belongs_to :element, :polymorphic => true
|
||||||
@ -239,8 +240,12 @@ class PDocument < ActiveRecord::Base
|
|||||||
PSheetLine.totals(self.p_sheet_lines)
|
PSheetLine.totals(self.p_sheet_lines)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def total_ttc
|
||||||
|
self.totals[:total_ttc]
|
||||||
|
end
|
||||||
|
|
||||||
def total_paid
|
def total_paid
|
||||||
self.p_payment_documents.joins(:p_payment).where(:p_payments => {:paid => true, :canceled => false}).sum(:amount)
|
self.p_payment_documents.joins(:p_payment).where(:p_payments => {:canceled => false}).sum(:amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_paid_at
|
def total_paid_at
|
||||||
@ -248,7 +253,7 @@ class PDocument < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def total_paid_th
|
def total_paid_th
|
||||||
self.p_payment_documents.joins(:p_payment).where(:p_payments => {:paid => false, :canceled => false}).sum(:amount)
|
self.p_payment_documents.joins(:p_payment).where(:p_payments => { :canceled => false}).sum(:amount)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ class PPayment < ActiveRecord::Base
|
|||||||
belongs_to :p_customer
|
belongs_to :p_customer
|
||||||
validates :p_customer_id, :presence => true
|
validates :p_customer_id, :presence => true
|
||||||
validates :amount, :presence => true
|
validates :amount, :presence => true
|
||||||
validates :paid_at, :presence => true, :if => :paid_date_needed?
|
validates :paid_at, :presence => true #, :if => :paid_date_needed?
|
||||||
validates :theo_date, :presence => true, :if => :theo_date_needed?
|
#validates :theo_date, :presence => true, :if => :theo_date_needed?
|
||||||
|
|
||||||
has_many :p_payment_documents
|
has_many :p_payment_documents
|
||||||
accepts_nested_attributes_for :p_payment_documents, allow_destroy: true
|
accepts_nested_attributes_for :p_payment_documents, allow_destroy: true
|
||||||
@ -19,10 +19,11 @@ class PPayment < ActiveRecord::Base
|
|||||||
self.affected = true
|
self.affected = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.total_affected > self.amount.to_f
|
if self.amount and ((self.amount.to_f < 0.0 and self.total_affected.to_f < self.amount.to_f) or (self.amount.to_f > 0 and self.total_affected.to_f > self.amount.to_f))# and !self.imported
|
||||||
errors.add(:amount, "Ne doit pas être inférieur aux affectations (manque #{(self.total_affected - self.amount.to_f)}€)")
|
errors.add(:amount, "Ne doit pas être inférieur aux affectations (manque #{(self.total_affected - self.amount.to_f)}€)")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
true
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
272
app/views/admin/p_documents/_search_to_affect.html.haml
Normal file
272
app/views/admin/p_documents/_search_to_affect.html.haml
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
-params[:solde] = params[:solde] || "0"
|
||||||
|
-p_customer = @p_customer
|
||||||
|
-if p_customer
|
||||||
|
|
||||||
|
|
||||||
|
-@p_documents = p_customer.p_documents
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-date_regex = /^(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/](19|20)\d\d$/i
|
||||||
|
-if params[:start] and params[:start] =~ date_regex
|
||||||
|
-@start = Date.parse(params[:start]).beginning_of_day
|
||||||
|
-params[:start]= @start.strftime('%d/%m/%Y')
|
||||||
|
-else
|
||||||
|
-@start = nil
|
||||||
|
|
||||||
|
|
||||||
|
-if params[:stop].to_s != "" and params[:stop] =~ date_regex
|
||||||
|
-@stop = Date.parse(params[:stop]).end_of_day
|
||||||
|
-params[:stop]= @stop.strftime('%d/%m/%Y')
|
||||||
|
|
||||||
|
-else
|
||||||
|
-@stop = nil
|
||||||
|
|
||||||
|
-@p_documents = @p_documents.where("created_at >= ?", @start) if @start
|
||||||
|
-@p_documents = @p_documents.where("created_at <= ?", @stop.end_of_day) if @stop
|
||||||
|
|
||||||
|
-if params[:solde].to_s != ""
|
||||||
|
|
||||||
|
-if params[:solde].to_s == "0"
|
||||||
|
-#@p_documents = @p_documents.where("cache_to_paid != 0.0 and (i_archive = 0 or i_archive is null)")
|
||||||
|
-else
|
||||||
|
-#@p_documents = @p_documents.where("cache_to_paid = 0.0 or i_archive = 1")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-@p_documents = @p_documents.where("d_number is not null")
|
||||||
|
-@p_documents = @p_documents.order("created_at DESC")
|
||||||
|
|
||||||
|
-per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 20
|
||||||
|
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
|
||||||
|
-@p_documents = @p_documents.page(page).per(per_page)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#search_to_affect{:style => ("display:none" if false)}
|
||||||
|
.header_table
|
||||||
|
-if true
|
||||||
|
#search_to_affect_form
|
||||||
|
=form_tag search_to_affect_admin_p_documents_path(), :method => "get", :onsubmit => "", :autocomplete => "off", :remote => true do
|
||||||
|
=hidden_field_tag :p_customer_id, (@p_customer.id if @p_customer)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%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)
|
||||||
|
|
||||||
|
|
||||||
|
-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_op
|
||||||
|
|
||||||
|
|
||||||
|
%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)
|
||||||
|
|
||||||
|
-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"
|
||||||
|
%td.search_op
|
||||||
|
%td.search_label
|
||||||
|
Soldé ?
|
||||||
|
%td=select_tag :solde, options_for_select([["Non","0"], ["Oui","1"]], params[:solde]), :include_blank => true
|
||||||
|
%td.search_op
|
||||||
|
%td
|
||||||
|
=submit_tag "Rechercher", :class => "btn btn-primary"
|
||||||
|
|
||||||
|
%table.table.table-stripped.table-hover
|
||||||
|
%tr
|
||||||
|
%th{:style => "width:30px"}
|
||||||
|
%th{:style => "width:100px"} Date
|
||||||
|
%th{:style => "width:90px"} Offre
|
||||||
|
%th Numéro de doc.
|
||||||
|
%th.numeraire{:style => "width:90px"} Montant TTC
|
||||||
|
%th.numeraire{:style => "width:90px"} Solde TTC
|
||||||
|
%th.numeraire{:style => "width:30px"}
|
||||||
|
%th{:style => "width:10px"}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.inner_panel
|
||||||
|
|
||||||
|
%table.table.table-stripped.table-hover
|
||||||
|
|
||||||
|
-@p_documents.where(:label => "Facture").each do |p_document|
|
||||||
|
%tr.p_document_search#p_document_search{:data => {:id => p_document.id}}
|
||||||
|
%td{:style => "width:30px;text-align:center;"}=ic :check if p_document.paid
|
||||||
|
%td{:style => "width:100px"}=l p_document.created_at, :format => "%y/%m/%Y"
|
||||||
|
%td{:style => "width:90px"}
|
||||||
|
=link_to p_document.element.id, [:admin,p_document.element], :target => "_blank" if p_document.element
|
||||||
|
%td
|
||||||
|
-if p_document.d_number?
|
||||||
|
=link_to p_document.d_number, admin_p_document_path(:id => p_document.token), :target => "_blank"
|
||||||
|
-else
|
||||||
|
=link_to "brouillon", admin_p_document_path(:id => p_document.token), :target => "_blank"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%td.numeraire{:style => "width:90px"}=number_to_currency p_document.total_ttc
|
||||||
|
|
||||||
|
%td.numeraire{:style => "width:90px"}
|
||||||
|
=number_to_currency p_document.total_ttc.to_f - p_document.total_paid.to_f
|
||||||
|
%td{:style => "width:30px;text-align:center;"}
|
||||||
|
-if true
|
||||||
|
-@fields = nil
|
||||||
|
-new_object = PPaymentDocument.new(:p_document_id => p_document.id)
|
||||||
|
-semantic_form_for([:admin, PPayment.new]) do |form|
|
||||||
|
-@fields = form.semantic_fields_for(:p_payment_documents, new_object, :child_index => "new_p_payment_documents") do |builder|
|
||||||
|
-render("admin/p_payment_documents/form", :form => builder)
|
||||||
|
|
||||||
|
|
||||||
|
=link_to ic(:plus) ,"#", :onclick => "qi_add_fields(this, 'p_payment_documents', \"#{escape_javascript(@fields)}\");return false;", :class => "add_to_affects"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%td{:style => "width:10px;text-align:center;"}
|
||||||
|
|
||||||
|
|
||||||
|
.qi_pagination
|
||||||
|
= paginate @p_documents, :remote => true
|
||||||
|
-else
|
||||||
|
#search_to_affect
|
||||||
|
|
||||||
|
:scss
|
||||||
|
|
||||||
|
#search_to_affect{
|
||||||
|
|
||||||
|
width:600px;
|
||||||
|
height:400px;
|
||||||
|
margin:auto;
|
||||||
|
overflow:hidden;
|
||||||
|
position:relative;
|
||||||
|
background:white;
|
||||||
|
box-shadow:0 0 5px rgba(0,0,0,0.5);
|
||||||
|
|
||||||
|
|
||||||
|
.add_to_affects{
|
||||||
|
cursor:pointer;
|
||||||
|
|
||||||
|
&:hover{
|
||||||
|
color:white;
|
||||||
|
background:#428bca;
|
||||||
|
padding:1px 3px;
|
||||||
|
margin:2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.header_table{
|
||||||
|
position:absolute;
|
||||||
|
top:0px;
|
||||||
|
height:50px;
|
||||||
|
right:0;
|
||||||
|
left:0;
|
||||||
|
background:white;
|
||||||
|
box-shadow:0 0 5px rgba(0,0,0,0.5);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.qi_pagination{
|
||||||
|
box-shadow:0 0 5px rgba(0,0,0,0.5);
|
||||||
|
margin:0;
|
||||||
|
position:absolute;
|
||||||
|
background:white;
|
||||||
|
right:0;
|
||||||
|
left:0;
|
||||||
|
bottom:0px;
|
||||||
|
height:30px;
|
||||||
|
padding:2px;
|
||||||
|
font-size:11px;
|
||||||
|
.gap, .current, a{
|
||||||
|
padding:4px 8px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.inner_panel{
|
||||||
|
position:absolute;
|
||||||
|
top:50px;
|
||||||
|
right:0;
|
||||||
|
left:0;
|
||||||
|
bottom:30px;
|
||||||
|
overflow:auto;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.table{
|
||||||
|
font-size:11px;
|
||||||
|
td,th{
|
||||||
|
padding:2px 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//dddd
|
||||||
|
#search_to_affect_form{
|
||||||
|
font-size:0.9em;
|
||||||
|
width:600px;
|
||||||
|
margin:auto;
|
||||||
|
background:white;
|
||||||
|
margin-bottom:4px;
|
||||||
|
.btn{
|
||||||
|
padding:3px 4px !important;
|
||||||
|
font-size:0.9em !important;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
.input-group{
|
||||||
|
.form-control, .btn{
|
||||||
|
padding:3px 4px !important;
|
||||||
|
font-size:0.9em !important;
|
||||||
|
height:20px !important;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control{
|
||||||
|
width:100px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.search_table{
|
||||||
|
td{
|
||||||
|
vertical-align:middle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.search_label{
|
||||||
|
text-align:right;
|
||||||
|
padding-right:5px;
|
||||||
|
|
||||||
|
}
|
||||||
|
.search_op{
|
||||||
|
width:25px;
|
||||||
|
text-align:center;
|
||||||
|
color:rgba(0,0,0,0.5);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
app/views/admin/p_documents/search_to_affect.js.erb
Normal file
2
app/views/admin/p_documents/search_to_affect.js.erb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$('#search_to_affect').replaceWith("<%= escape_javascript(render(:partial => "admin/p_documents/search_to_affect"))%>");
|
||||||
|
|
@ -1,14 +1,18 @@
|
|||||||
.p_payment_document_form.field
|
-p_document = form.object.p_document
|
||||||
%hr
|
%tr.p_payment_document_form.field
|
||||||
%table{:style => "width:100%;"}
|
%td{:style => "width:30px;text-align:center;"}=ic :check if p_document.paid
|
||||||
%tr
|
%td{:style => "width:100px"}=l p_document.created_at, :format => "%y/%m/%Y"
|
||||||
%td
|
%td{:style => "width:90px"}
|
||||||
-p_documents = PDocument.where(:p_document_type_id => 4)
|
=link_to p_document.element.id, [:admin,p_document.element], :target => "_blank" if p_document.element
|
||||||
-if @p_customer
|
%td
|
||||||
-p_documents = p_documents.where(:p_customer_id => @p_customer.id)
|
=link_to p_document.d_number, admin_p_document_path(:id => p_document.token), :target => "_blank"
|
||||||
= form.input :p_document_id, :label => "Document :", :collection => p_documents.all, :as => :select, :include_blank => false, :member_label => :name_for_payment
|
= form.hidden_field :p_document_id
|
||||||
%td
|
%td.numeraire{:style => "width:120px"}=number_to_currency p_document.cache_total_ttc
|
||||||
= form.input :amount, :label => "Montant"
|
|
||||||
|
%td.numeraire{:style => "width:120px"}
|
||||||
|
=number_to_currency(p_document.total_ttc.to_f - p_document.total_paid.to_f)
|
||||||
|
%td.numeraire{:style => "width:120px"}
|
||||||
|
= form.input :amount, :label => false, :placeholder => "Montant"
|
||||||
|
%td{:style => "width:30px;text-align:center;"}
|
||||||
|
=link_to_remove_fields ic(:"trash-o"), form
|
||||||
|
|
||||||
%td{:style => "padding:10px"}
|
|
||||||
=link_to_remove_fields ic(:"trash-o"), form
|
|
14
app/views/admin/p_payment_documents/_form.old.html.haml
Executable file
14
app/views/admin/p_payment_documents/_form.old.html.haml
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
.p_payment_document_form.field
|
||||||
|
%hr
|
||||||
|
%table{:style => "width:100%;"}
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
-p_documents = PDocument.where(:p_document_type_id => 4)
|
||||||
|
-if @p_customer
|
||||||
|
-p_documents = p_documents.where(:p_customer_id => @p_customer.id)
|
||||||
|
= form.input :p_document_id, :label => "Document :", :collection => p_documents.all, :as => :select, :include_blank => false, :member_label => :name_for_payment
|
||||||
|
%td
|
||||||
|
= form.input :amount, :label => "Montant"
|
||||||
|
|
||||||
|
%td{:style => "padding:10px"}
|
||||||
|
=link_to_remove_fields ic(:"trash-o"), form
|
32
app/views/admin/p_payments/_essentials_form.html.haml
Normal file
32
app/views/admin/p_payments/_essentials_form.html.haml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
-field_form = field_form || false
|
||||||
|
.p_payment_form.field
|
||||||
|
|
||||||
|
|
||||||
|
=form.inputs do
|
||||||
|
|
||||||
|
%table{:style => "width:100%;"}
|
||||||
|
%tr
|
||||||
|
%td{:style => "width:200px;"}
|
||||||
|
= form.input :p_payment_type_id, :label => "Type de paiement :", :include_blank => false, :collection => PPaymentType.order(:name).all, :as => :select, :input_html => {:class => "payment_type_id_select"}
|
||||||
|
|
||||||
|
%td{:style => "width:160px;"}
|
||||||
|
= form.input :paid_at, :label => "Date de paiement :" , :as => :date
|
||||||
|
%td{:style => "width:160px;"}
|
||||||
|
.not_comptant{:style => ("display:none" if !PPaymentType.where(:comptant => false).ids.include?(form.object.p_payment_type_id))}
|
||||||
|
= form.input :theo_date, :label => "Date paiement th. :" , :as => :date
|
||||||
|
|
||||||
|
-if false
|
||||||
|
%td{:style => "width:100px;"}
|
||||||
|
%br
|
||||||
|
= form.input :paid, :label => "Encaissé ?"
|
||||||
|
|
||||||
|
%td{:style => "width:100px;"}
|
||||||
|
= form.input :amount, :label => "Montant :", :input_html => {:class => "payment_amount"}
|
||||||
|
%td
|
||||||
|
= form.input :number, :label => "N° / réf. :"
|
||||||
|
|
||||||
|
|
||||||
|
-if !@p_payment
|
||||||
|
%td{:style => "width:40px;padding-top:28px;text-align:center;"}
|
||||||
|
|
||||||
|
=link_to_remove_fields ic(:"trash-o"), form
|
@ -1,199 +1,140 @@
|
|||||||
=semantic_form_for [:admin, @p_payment], :remote => true do |f|
|
#p_payment_form_wrapper
|
||||||
-@p_customer = @p_payment.p_customer if @p_payment.p_customer
|
|
||||||
|
|
||||||
.content
|
.content
|
||||||
=debug @p_payment.errors.messages
|
=debug @p_payment.errors.messages
|
||||||
=f.inputs do
|
=semantic_form_for [:admin, @p_payment], :remote => true, :html => {:id => "p_payment_general_form",:onsubmit => "$this = $(this); if ($this.data().isSubmitted) { alert('La sauvegarde est en cours, merci de patienter.');return false; } $this.data().isSubmitted = true; return true;"} do |f|
|
||||||
|
-@p_customer = @p_payment.p_customer if @p_payment.p_customer
|
||||||
|
|
||||||
|
|
||||||
=hidden_field_tag :last_p_customer_id, @p_payment.p_customer_id
|
=f.inputs do
|
||||||
|
|
||||||
|
|
||||||
%label Client :
|
=hidden_field_tag :last_p_customer_id, @p_payment.p_customer_id
|
||||||
%input.p_customer_autocomplete_input.form-control{:type => "text", :value => ("#{f.object.p_customer.show_name}" if f.object.p_customer)}
|
|
||||||
|
|
||||||
|
|
||||||
= f.hidden_field :p_customer_id, :class => "p_customer_id"
|
%label Client :
|
||||||
|
%input.p_customer_autocomplete_input.form-control{:type => "text", :value => ("#{f.object.p_customer.show_name}" if f.object.p_customer)}
|
||||||
|
|
||||||
:javascript
|
|
||||||
$( function() {
|
= f.hidden_field :p_customer_id, :class => "p_customer_id"
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$( function() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('.p_customer_autocomplete_input').autocomplete({
|
$('.p_customer_autocomplete_input').autocomplete({
|
||||||
source: function( request, response ) {
|
source: function( request, response ) {
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
|
|
||||||
|
|
||||||
url: "/admin/p_customers/autocomplete.json",
|
url: "/admin/p_customers/autocomplete.json",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {
|
data: {
|
||||||
search: request.term,
|
search: request.term,
|
||||||
|
|
||||||
},
|
},
|
||||||
success: function(data){
|
success: function(data){
|
||||||
|
|
||||||
arr = jQuery.map( data, function( item ) {
|
arr = jQuery.map( data, function( item ) {
|
||||||
return {
|
return {
|
||||||
label: item.show_name,
|
label: item.show_name,
|
||||||
value: item.show_name,
|
value: item.show_name,
|
||||||
id: item.id
|
id: item.id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
response(arr)
|
response(arr)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
minLength: 2,
|
minLength: 2,
|
||||||
select: function( event, ui ) {
|
select: function( event, ui ) {
|
||||||
|
|
||||||
$(this).next(".p_customer_id").val(ui.item.id)
|
$(this).next(".p_customer_id").val(ui.item.id)
|
||||||
|
|
||||||
var change_address = false;
|
var change_address = false;
|
||||||
|
|
||||||
if (parseInt($("#last_p_customer_id").val()) != parseInt(ui.item.id)){
|
if (parseInt($("#last_p_customer_id").val()) != parseInt(ui.item.id)){
|
||||||
change_address = true;
|
change_address = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url:"/admin/p_customers/"+ui.item.id+"/autocomplete_apercu.js",
|
||||||
|
type : "GET",
|
||||||
|
data : { change_address : change_address}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url:"/admin/p_documents/search_to_affect?p_customer_id="+ui.item.id+".js",
|
||||||
|
type : "GET"
|
||||||
|
//data : { change_address : change_address}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#last_p_customer_id").val(ui.item.id);
|
||||||
|
|
||||||
|
|
||||||
|
//return false
|
||||||
}
|
}
|
||||||
|
});
|
||||||
$.ajax({
|
|
||||||
url:"/admin/p_customers/"+ui.item.id+"/autocomplete_apercu.js",
|
|
||||||
type : "GET",
|
|
||||||
data : { change_address : change_address}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#last_p_customer_id").val(ui.item.id);
|
|
||||||
|
|
||||||
|
|
||||||
//return false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-if false
|
|
||||||
.qi_autocomplete
|
|
||||||
%input.qi_autocomplete_input.form-control{:type => "text"}
|
|
||||||
|
|
||||||
.qi_list
|
|
||||||
|
|
||||||
= f.hidden_field :p_customer_id, :id => "p_customer_id"
|
|
||||||
|
|
||||||
:coffeescript
|
|
||||||
$(document).on "click", ".autocomplete_line", ->
|
|
||||||
|
|
||||||
id = $(this).data('value')
|
|
||||||
|
|
||||||
$(this).closest(".qi_autocomplete").next("input").val(id)
|
|
||||||
|
|
||||||
$(this).closest(".qi_list").hide()
|
|
||||||
$(this).closest(".qi_autocomplete").find(".qi_autocomplete_input").val("")
|
|
||||||
|
|
||||||
change_address = false
|
|
||||||
|
|
||||||
if (parseInt($("#last_p_customer_id").val()) != parseInt(id))
|
|
||||||
change_address = true
|
|
||||||
|
|
||||||
|
|
||||||
$.ajax
|
|
||||||
url:"/admin/p_customers/"+id+"/autocomplete_apercu.js",
|
|
||||||
type : "GET",
|
|
||||||
data : {search : $(this).val(), change_address : change_address}
|
|
||||||
|
|
||||||
$("#last_p_customer_id").val(id)
|
|
||||||
|
|
||||||
return false
|
|
||||||
|
|
||||||
$(".qi_autocomplete_input").keyup ->
|
|
||||||
input = $(this)
|
|
||||||
$.ajax
|
|
||||||
url:"/admin/p_customers/autocomplete.js",
|
|
||||||
type : "GET",
|
|
||||||
data : {search : $(this).val()}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:scss
|
%br
|
||||||
.qi_autocomplete{
|
|
||||||
position:relative;
|
|
||||||
|
|
||||||
.qi_autocomplete_input{
|
=render :partial => "admin/p_payments/essentials_form", :locals => {:form => f}
|
||||||
width:100%;
|
|
||||||
box-sizing:border-box;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
#lettrage_panel
|
||||||
|
=f.inputs do
|
||||||
|
|
||||||
.qi_list{
|
%hr
|
||||||
position:absolute;
|
|
||||||
left:1px;
|
|
||||||
right:1px;
|
|
||||||
background:rgba(255,255,255,0.9);
|
|
||||||
box-shadow:0 0 5px rgba(0,0,0,0.3);
|
|
||||||
|
|
||||||
a{
|
Lettrage :
|
||||||
display:block;
|
#lettrage_table
|
||||||
padding:5px 7px;
|
%table.table
|
||||||
box-sizing:border-box;
|
%thead
|
||||||
border-bottom:1px solid rgba(0,0,0,0.2);
|
%tr
|
||||||
|
%th{:style => "width:30px"}
|
||||||
|
%th{:style => "width:100px"} Date
|
||||||
|
%th{:style => "width:90px"} Offre
|
||||||
|
%th Numéro de doc.
|
||||||
|
%th.numeraire{:style => "width:90px"} Montant TTC
|
||||||
|
%th.numeraire{:style => "width:90px"} Solde TTC
|
||||||
|
%th.numeraire{:style => "width:30px"} Montant à lettrer
|
||||||
|
%th{:style => "width:10px"}
|
||||||
|
|
||||||
&:hover{
|
%tbody.p_payment_documents_form
|
||||||
text-decoration:none;
|
|
||||||
|
=f.semantic_fields_for :p_payment_documents do |form|
|
||||||
|
=render :partial => "admin/p_payment_documents/form", :locals => {:form => form}
|
||||||
|
|
||||||
|
:scss
|
||||||
|
#lettrage_table{
|
||||||
|
font-size:14px;
|
||||||
|
td,th{
|
||||||
|
padding:2px 4px;
|
||||||
|
vertical-align:middle;
|
||||||
|
.form-group{
|
||||||
|
margin:0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
%p Pour sélectionner un document avec lequel lettrer ce paiement, cliquer sur le + dans la liste des paiements ci-dessous :
|
||||||
|
=render :partial => "admin/p_documents/search_to_affect"
|
||||||
.p_customer_sheet_customer
|
|
||||||
|
|
||||||
|
|
||||||
-if @p_payment.p_customer and @p_payment.p_customer.particular
|
|
||||||
=render :partial => "admin/p_customers/apercu", :locals => {:particular => @p_payment.p_customer.particular}
|
|
||||||
|
|
||||||
%br
|
|
||||||
|
|
||||||
= 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 :paid, :label => "Encaissé ?"
|
|
||||||
= f.input :paid_at, :label => "Date de paiement :"
|
|
||||||
.not_comptant{:style => ("display:none" if ![3].include?(@p_payment.p_payment_type_id))}
|
|
||||||
= f.input :theo_date, :label => "Date de paiement théorique :"
|
|
||||||
= f.input :amount, :label => "Montant :"
|
|
||||||
= f.input :number, :label => "Numéro / référence :"
|
|
||||||
|
|
||||||
|
|
||||||
%hr
|
|
||||||
|
|
||||||
.p_payment_documents_form
|
|
||||||
=f.semantic_fields_for :p_payment_documents do |form|
|
|
||||||
=render :partial => "admin/p_payment_documents/form", :locals => {:form => form}
|
|
||||||
|
|
||||||
%p= link_to_add_fields "Ajouter une ligne", f, :p_payment_documents
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
:coffeescript
|
|
||||||
not_comptant_ids = [3]
|
|
||||||
|
|
||||||
$('#payment_type_id_select').change ->
|
|
||||||
val = $(this).val()
|
|
||||||
if $.inArray(parseInt(val), not_comptant_ids) isnt -1
|
|
||||||
$(".not_comptant").show()
|
|
||||||
else
|
|
||||||
$(".not_comptant").hide()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.actions=submit_tag "sauvegarder", :class => "btn btn-primary", :onclick => "$(this).val('Sauvegarde en cours...');$(this).closest('#p_payment_form_wrapper').find('#p_payment_general_form').submit();"
|
||||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
|
||||||
|
|
199
app/views/admin/p_payments/_form.old.html.haml
Executable file
199
app/views/admin/p_payments/_form.old.html.haml
Executable file
@ -0,0 +1,199 @@
|
|||||||
|
=semantic_form_for [:admin, @p_payment], :remote => true do |f|
|
||||||
|
-@p_customer = @p_payment.p_customer if @p_payment.p_customer
|
||||||
|
|
||||||
|
.content
|
||||||
|
=debug @p_payment.errors.messages
|
||||||
|
=f.inputs do
|
||||||
|
|
||||||
|
|
||||||
|
=hidden_field_tag :last_p_customer_id, @p_payment.p_customer_id
|
||||||
|
|
||||||
|
|
||||||
|
%label Client :
|
||||||
|
%input.p_customer_autocomplete_input.form-control{:type => "text", :value => ("#{f.object.p_customer.show_name}" if f.object.p_customer)}
|
||||||
|
|
||||||
|
|
||||||
|
= f.hidden_field :p_customer_id, :class => "p_customer_id"
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$( function() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('.p_customer_autocomplete_input').autocomplete({
|
||||||
|
source: function( request, response ) {
|
||||||
|
$.ajax( {
|
||||||
|
|
||||||
|
|
||||||
|
url: "/admin/p_customers/autocomplete.json",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
search: request.term,
|
||||||
|
|
||||||
|
},
|
||||||
|
success: function(data){
|
||||||
|
|
||||||
|
arr = jQuery.map( data, function( item ) {
|
||||||
|
return {
|
||||||
|
label: item.show_name,
|
||||||
|
value: item.show_name,
|
||||||
|
id: item.id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
response(arr)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
minLength: 2,
|
||||||
|
select: function( event, ui ) {
|
||||||
|
|
||||||
|
$(this).next(".p_customer_id").val(ui.item.id)
|
||||||
|
|
||||||
|
var change_address = false;
|
||||||
|
|
||||||
|
if (parseInt($("#last_p_customer_id").val()) != parseInt(ui.item.id)){
|
||||||
|
change_address = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url:"/admin/p_customers/"+ui.item.id+"/autocomplete_apercu.js",
|
||||||
|
type : "GET",
|
||||||
|
data : { change_address : change_address}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#last_p_customer_id").val(ui.item.id);
|
||||||
|
|
||||||
|
|
||||||
|
//return false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-if false
|
||||||
|
.qi_autocomplete
|
||||||
|
%input.qi_autocomplete_input.form-control{:type => "text"}
|
||||||
|
|
||||||
|
.qi_list
|
||||||
|
|
||||||
|
= f.hidden_field :p_customer_id, :id => "p_customer_id"
|
||||||
|
|
||||||
|
:coffeescript
|
||||||
|
$(document).on "click", ".autocomplete_line", ->
|
||||||
|
|
||||||
|
id = $(this).data('value')
|
||||||
|
|
||||||
|
$(this).closest(".qi_autocomplete").next("input").val(id)
|
||||||
|
|
||||||
|
$(this).closest(".qi_list").hide()
|
||||||
|
$(this).closest(".qi_autocomplete").find(".qi_autocomplete_input").val("")
|
||||||
|
|
||||||
|
change_address = false
|
||||||
|
|
||||||
|
if (parseInt($("#last_p_customer_id").val()) != parseInt(id))
|
||||||
|
change_address = true
|
||||||
|
|
||||||
|
|
||||||
|
$.ajax
|
||||||
|
url:"/admin/p_customers/"+id+"/autocomplete_apercu.js",
|
||||||
|
type : "GET",
|
||||||
|
data : {search : $(this).val(), change_address : change_address}
|
||||||
|
|
||||||
|
$("#last_p_customer_id").val(id)
|
||||||
|
|
||||||
|
return false
|
||||||
|
|
||||||
|
$(".qi_autocomplete_input").keyup ->
|
||||||
|
input = $(this)
|
||||||
|
$.ajax
|
||||||
|
url:"/admin/p_customers/autocomplete.js",
|
||||||
|
type : "GET",
|
||||||
|
data : {search : $(this).val()}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:scss
|
||||||
|
.qi_autocomplete{
|
||||||
|
position:relative;
|
||||||
|
|
||||||
|
.qi_autocomplete_input{
|
||||||
|
width:100%;
|
||||||
|
box-sizing:border-box;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.qi_list{
|
||||||
|
position:absolute;
|
||||||
|
left:1px;
|
||||||
|
right:1px;
|
||||||
|
background:rgba(255,255,255,0.9);
|
||||||
|
box-shadow:0 0 5px rgba(0,0,0,0.3);
|
||||||
|
|
||||||
|
a{
|
||||||
|
display:block;
|
||||||
|
padding:5px 7px;
|
||||||
|
box-sizing:border-box;
|
||||||
|
border-bottom:1px solid rgba(0,0,0,0.2);
|
||||||
|
|
||||||
|
&:hover{
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.p_customer_sheet_customer
|
||||||
|
|
||||||
|
|
||||||
|
-if @p_payment.p_customer and @p_payment.p_customer.particular
|
||||||
|
=render :partial => "admin/p_customers/apercu", :locals => {:particular => @p_payment.p_customer.particular}
|
||||||
|
|
||||||
|
%br
|
||||||
|
|
||||||
|
= 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 :paid, :label => "Encaissé ?"
|
||||||
|
= f.input :paid_at, :label => "Date de paiement :"
|
||||||
|
.not_comptant{:style => ("display:none" if ![3].include?(@p_payment.p_payment_type_id))}
|
||||||
|
= f.input :theo_date, :label => "Date de paiement théorique :"
|
||||||
|
= f.input :amount, :label => "Montant :"
|
||||||
|
= f.input :number, :label => "Numéro / référence :"
|
||||||
|
|
||||||
|
|
||||||
|
%hr
|
||||||
|
|
||||||
|
.p_payment_documents_form
|
||||||
|
=f.semantic_fields_for :p_payment_documents do |form|
|
||||||
|
=render :partial => "admin/p_payment_documents/form", :locals => {:form => form}
|
||||||
|
|
||||||
|
%p= link_to_add_fields "Ajouter une ligne", f, :p_payment_documents
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:coffeescript
|
||||||
|
not_comptant_ids = [3]
|
||||||
|
|
||||||
|
$('#payment_type_id_select').change ->
|
||||||
|
val = $(this).val()
|
||||||
|
if $.inArray(parseInt(val), not_comptant_ids) isnt -1
|
||||||
|
$(".not_comptant").show()
|
||||||
|
else
|
||||||
|
$(".not_comptant").hide()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||||
|
|
@ -153,6 +153,7 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get :multiple
|
get :multiple
|
||||||
|
get :search_to_affect
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :p_trucks
|
resources :p_trucks
|
||||||
|
Loading…
x
Reference in New Issue
Block a user