coton_app/app/views/admin/p_payments/_form.old.html.haml
2019-06-19 13:23:48 +02:00

199 lines
6.0 KiB
Plaintext
Executable File

=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"