Replace price_line form

This commit is contained in:
Barnabé 2021-09-08 16:20:58 +02:00
parent a334469ac0
commit 3bf1514bcc
2 changed files with 236 additions and 122 deletions

View File

@ -1,134 +1,115 @@
.qi_pannel.qi_plain.padding.price_line_form.col-3.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
%table{:style => "width:100%;"}
.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
= form.input :ct_title, :label => "Designation personnalisée : " if @avoir
%table
%tr
%td{:style => "width:30px;"}
.take
%td{:class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
.take.mx-1
=ic :arrows
%td
= form.input :ct_title, :label => "Designation personnalisée : " if @avoir
%div{:class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
%label Produit :
%input.p_product_ref_autocomplete_input.form-control{:type => "text", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref)}
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id"
:javascript
$('.p_product_ref_autocomplete_input').focus()
$( function() {
$('.p_product_ref_autocomplete_input').autocomplete({
source: function( request, response ) {
$.ajax( {
url: "/admin/p_product_refs/autocomplete.json",
dataType: "json",
data: {
search: request.term,
p_customer_id: $(".p_customer_id").val()
},
success: function(data){
arr = jQuery.map( data, function( item ) {
return {
label: item.member_label,
value: item.member_label,
id: item.id
}
});
response(arr)
}
} );
},
minLength: 2,
select: function( event, ui ) {
$(this).next(".p_product_ref_id").val(ui.item.id)
form = $(this).closest(".price_line_form")
$.ajax( {
url: "/admin/p_product_refs/"+ui.item.id+"/get_infos.json",
dataType: "json",
data: {
type: "price",
qte: form.find(".input_price_line_qte").val(),
p_customer_id: $(".p_customer_id").val()
},
success: function (data) {
form.find(".input_price_line_price_u_ht").val(data.price);
form.find(".input_price_line_tva_account_id").val(data.tva_account_id);
form.find(".input_price_line_tva_account_value").val(data.tva_account_value);
form.find(".input_price_line_weight_u").val(data.weight);
}
} );
//return false
}
});
} );
%table.top_td{:style => "width:100%;margin-top:5px;"}
%tr
%td{:style => "width:30px"}
%span.destroy=link_to_remove_fields ic(:"trash-o"), form
%label.mx-3 Produit :
%td
%input.p_product_ref_autocomplete_input.form-control{:type => "text", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref)}
-form.object.forced_price = true if form.object.ct_u_price_ht
-if form.object.forced_price and form.object.p_product_ref
=qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :", :value => form.object.th_price_u_ht)
%td
.mx-4
=qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :", :value => form.object.th_price_u_ht)
-else
=qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :")
%div{:style => ("display:none;" if !current_admin or !current_admin.has_permission?("customer-sheets-personalised-price"))}
%td
.mx-4
=qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :")
%td
.form-inline.mx-4{:style => ("display:none;" if !current_admin or !current_admin.has_permission?("customer-sheets-personalised-price"))}
= form.input :forced_price, :label => "Prix personnalisé ?", :as => :boolean, :input_html => {:class => "input_price_line_forced_price"}
.forced_price_wrapper{:style => ("display:none;" if !form.object.forced_price)}= form.input :ct_u_price_ht, :label => false, :input_html => {:class => "input_price_line_ct_u_price_ht"}
.forced_price_wrapper.mx-4{:style => ("display:none;" if !form.object.forced_price)}= form.input :ct_u_price_ht, :label => false, :input_html => {:class => "input_price_line_ct_u_price_ht"}
%td
.mx-4.form-inline
= form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte form-control mx-2", tabindex: 1}
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id"
%td
= form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte", tabindex: 1}
.form-inline
%label.mx-4 Taux de TVA :
=select_tag :tva_account_id, options_from_collection_for_select(TvaRate.where(:accounting_zone_id => (@p_customer ? @p_customer.accounting_zone_id : nil)).all, "id", "member_label", form.object.tva_account_id), :class => "input_price_line_tva_account_id form-control custom-select" #, :disabled => true
%td
=#qi_js_field(form, :price_line, :tva_account_id, :label => "Compte TVA :")
-if @avoir
-if !form.object.ct_tva_account_id
-form.object.ct_tva_account_id = form.object.tva_account_id
= form.input :ct_tva_account_id, :collection => TvaRate.where(:accounting_zone_id => (@p_customer ? @p_customer.accounting_zone_id : nil)).all, :as => :select, :member_label => :member_label, :include_blank => false, :label => "TVA personnalisée", :input_html => { :class => "input_price_line_tva_account_id"}
-else
%label Taux de TVA :
%br
=select_tag :tva_account_id, options_from_collection_for_select(TvaRate.where(:accounting_zone_id => (@p_customer ? @p_customer.accounting_zone_id : nil)).all, "id", "member_label", form.object.tva_account_id), :class => "input_price_line_tva_account_id custom-select" #, :disabled => true
.mx-4
%span.destroy=link_to_remove_fields ic(:"trash-o"), form
=qi_js_field(form, :price_line, :tva_account_value, :hidden => true)
=qi_js_field(form, :price_line, :tva_account_value, :hidden => true)
/ = form.input :comment, :label => "Commentaire"
= form.hidden_field :position, :class => "price_line_position_input"
:javascript
$('.p_product_ref_autocomplete_input').focus()
$( function() {
$('.p_product_ref_autocomplete_input').autocomplete({
source: function( request, response ) {
$.ajax( {
url: "/admin/p_product_refs/autocomplete.json",
dataType: "json",
data: {
search: request.term,
p_customer_id: $(".p_customer_id").val()
},
success: function(data){
arr = jQuery.map( data, function( item ) {
return {
label: item.member_label,
value: item.member_label,
id: item.id
}
});
response(arr)
}
} );
},
minLength: 2,
select: function( event, ui ) {
$(this).next(".p_product_ref_id").val(ui.item.id)
form = $(this).closest(".price_line_form")
$.ajax( {
url: "/admin/p_product_refs/"+ui.item.id+"/get_infos.json",
dataType: "json",
data: {
type: "price",
qte: form.find(".input_price_line_qte").val(),
p_customer_id: $(".p_customer_id").val()
},
success: function (data) {
form.find(".input_price_line_price_u_ht").val(data.price);
form.find(".input_price_line_tva_account_id").val(data.tva_account_id);
form.find(".input_price_line_tva_account_value").val(data.tva_account_value);
form.find(".input_price_line_weight_u").val(data.weight);
}
} );
= form.hidden_field :position, :class => "price_line_position_input"
//return false
}
});
} );

View File

@ -0,0 +1,133 @@
.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
%table{:style => "width:100%;"}
%tr
%td{:style => "width:30px;"}
.take
=ic :arrows
%td
= form.input :ct_title, :label => "Designation personnalisée : " if @avoir
%div{:class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
%label Produit :
%td
%input.p_product_ref_autocomplete_input.form-control{:type => "text", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref)}
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id"
:javascript
$('.p_product_ref_autocomplete_input').focus()
$( function() {
$('.p_product_ref_autocomplete_input').autocomplete({
source: function( request, response ) {
$.ajax( {
url: "/admin/p_product_refs/autocomplete.json",
dataType: "json",
data: {
search: request.term,
p_customer_id: $(".p_customer_id").val()
},
success: function(data){
arr = jQuery.map( data, function( item ) {
return {
label: item.member_label,
value: item.member_label,
id: item.id
}
});
response(arr)
}
} );
},
minLength: 2,
select: function( event, ui ) {
$(this).next(".p_product_ref_id").val(ui.item.id)
form = $(this).closest(".price_line_form")
$.ajax( {
url: "/admin/p_product_refs/"+ui.item.id+"/get_infos.json",
dataType: "json",
data: {
type: "price",
qte: form.find(".input_price_line_qte").val(),
p_customer_id: $(".p_customer_id").val()
},
success: function (data) {
form.find(".input_price_line_price_u_ht").val(data.price);
form.find(".input_price_line_tva_account_id").val(data.tva_account_id);
form.find(".input_price_line_tva_account_value").val(data.tva_account_value);
form.find(".input_price_line_weight_u").val(data.weight);
}
} );
//return false
}
});
} );
%td{:style => "width:30px"}
%span.destroy=link_to_remove_fields ic(:"trash-o"), form
%td
-form.object.forced_price = true if form.object.ct_u_price_ht
-if form.object.forced_price and form.object.p_product_ref
=qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :", :value => form.object.th_price_u_ht)
-else
=qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :")
%div{:style => ("display:none;" if !current_admin or !current_admin.has_permission?("customer-sheets-personalised-price"))}
= form.input :forced_price, :label => "Prix personnalisé ?", :as => :boolean, :input_html => {:class => "input_price_line_forced_price"}
.forced_price_wrapper{:style => ("display:none;" if !form.object.forced_price)}= form.input :ct_u_price_ht, :label => false, :input_html => {:class => "input_price_line_ct_u_price_ht"}
%td
= form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte", tabindex: 1}
%td
=#qi_js_field(form, :price_line, :tva_account_id, :label => "Compte TVA :")
-if @avoir
-if !form.object.ct_tva_account_id
-form.object.ct_tva_account_id = form.object.tva_account_id
= form.input :ct_tva_account_id, :collection => TvaRate.where(:accounting_zone_id => (@p_customer ? @p_customer.accounting_zone_id : nil)).all, :as => :select, :member_label => :member_label, :include_blank => false, :label => "TVA personnalisée", :input_html => { :class => "input_price_line_tva_account_id"}
-else
%label Taux de TVA :
%br
=select_tag :tva_account_id, options_from_collection_for_select(TvaRate.where(:accounting_zone_id => (@p_customer ? @p_customer.accounting_zone_id : nil)).all, "id", "member_label", form.object.tva_account_id), :class => "input_price_line_tva_account_id custom-select" #, :disabled => true
=qi_js_field(form, :price_line, :tva_account_value, :hidden => true)
/ = form.input :comment, :label => "Commentaire"
= form.hidden_field :position, :class => "price_line_position_input"