Wip show consult
This commit is contained in:
parent
00e390f50b
commit
1e5316a3bf
@ -13,7 +13,20 @@ module ApplicationHelper
|
||||
end
|
||||
return raw(r)
|
||||
end
|
||||
|
||||
|
||||
def qi_js_field_price_line_form(form, model, method, options = {})
|
||||
r = ""
|
||||
if options[:hidden]
|
||||
r += hidden_field_tag(method, eval("form.object.#{method}"), :class => "input_#{model}_#{method} form-control",:disabled => true)
|
||||
else
|
||||
if options[:label]
|
||||
r += label_tag(:input, options[:label], class: options[:label_class])
|
||||
end
|
||||
r += text_field_tag(method, (options[:value] ? options[:value] : eval("form.object.#{method}")), :class => "input_#{model}_#{method} form-control",:disabled => true)
|
||||
end
|
||||
return raw(r)
|
||||
end
|
||||
|
||||
|
||||
def edit_watcher(element_type, element_id, key='' )
|
||||
raw ('<script type="text/javascript">')+("edit_watcher('"+element_type+"', '"+element_id.to_s+"','"+key+"');")+("setInterval(function(){ edit_watcher('"+element_type+"', '"+element_id.to_s+"','"+key+"');}, 1000);")+('</script><div id="edit_watcher_result"></div>')
|
||||
|
@ -367,9 +367,28 @@
|
||||
Vous devez d'abord Selectionner les prix sur le page d'analyse :
|
||||
=link_to ic("bar-chart")+" analyse des réponses", analyse_reponses_admin_price_document_path(@price_document), class: "btn btn-primary"
|
||||
puis Generer les consultations
|
||||
|
||||
-@price_documents.each do |price_document_consult|
|
||||
|
||||
=link_to ic(:clipboard) + " test clipboard TODO", "#", class: "right btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)'
|
||||
%h4= price_document_consult.p_fournisseur.name
|
||||
=semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form|
|
||||
=form.semantic_fields_for :price_line_block do |f|
|
||||
=f.semantic_fields_for :price_lines do |form|
|
||||
=render partial: "admin/price_lines/form", locals: {form: form}
|
||||
= semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form|
|
||||
= form.button ic(:clipboard) + "Valider modifications (TODO +copier la consultation)", type: :submit, class: "btn btn-primary m-2"
|
||||
.price-lines{"data-document" => price_document_consult.id}
|
||||
=form.semantic_fields_for :price_line_block do |f|
|
||||
=f.semantic_fields_for :price_lines do |form|
|
||||
=render partial: "admin/price_lines/form_consult", locals: {form: form}
|
||||
|
||||
:javascript
|
||||
const copyPriceLines = (event) => {
|
||||
event.preventDefault()
|
||||
console.log(event.target.dataset.document)
|
||||
let result = $('div[data-document=38]')
|
||||
copy(result)
|
||||
}
|
||||
const copy = (element) => {
|
||||
element.select()
|
||||
document.execCommand("copy")
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,121 +4,45 @@
|
||||
%table
|
||||
%tr
|
||||
%td{:class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
|
||||
.take.mx-1
|
||||
.take.mr-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 )}
|
||||
|
||||
-key = SecureRandom.hex(6)
|
||||
|
||||
%label Produit :
|
||||
%input.p_product_ref_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref), :class => "p_product_ref_name_#{key}"}
|
||||
-key = SecureRandom.hex(6)
|
||||
%label.ml-3.mr-2 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), :class => "p_product_ref_name_#{key}"}
|
||||
|
||||
|
||||
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id p_product_ref_id_#{key}"
|
||||
=link_to "selectionner un produit", "#", :onclick => "select_product_from_manager('#{key}');return false;"
|
||||
:javascript
|
||||
$( 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
|
||||
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id p_product_ref_id_#{key}"
|
||||
%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
|
||||
=link_to ic(:search), "#", class: "ml-2",:onclick => "select_product_from_manager('#{key}');return false;"
|
||||
|
||||
-if form.object.forced_price and form.object.p_product_ref
|
||||
%td
|
||||
.mx-4
|
||||
.form-inline
|
||||
=qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :", :value => form.object.th_price_u_ht)
|
||||
-else
|
||||
%td
|
||||
.mx-3
|
||||
.form-inline
|
||||
=qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :")
|
||||
-form.object.forced_price = true if form.object.ct_u_price_ht
|
||||
|
||||
-if form.object.forced_price and form.object.p_product_ref
|
||||
%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.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"}
|
||||
.mx-2
|
||||
.form-inline
|
||||
=qi_js_field_price_line_form(form, :price_line, :price_u_ht, :label => "Prix U HT :", label_class: "mr-1", :value => form.object.th_price_u_ht)
|
||||
-else
|
||||
%td
|
||||
.mx-4.form-inline
|
||||
= form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte form-control mx-2", tabindex: 1}
|
||||
.mx-2
|
||||
.form-inline
|
||||
=qi_js_field_price_line_form(form, :price_line, :price_u_ht, :label => "Prix U HT :", label_class: "mr-1")
|
||||
%td
|
||||
.form-inline.mr-2{: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 => "form-inline input_price_line_forced_price"}
|
||||
.forced_price_wrapper.mx-2{: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-2.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-inline
|
||||
%label.mx-4 Taux de TVA :
|
||||
%label.mx-2 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
|
||||
.ml-4
|
||||
@ -131,72 +55,50 @@
|
||||
= 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);
|
||||
|
||||
|
||||
|
||||
: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
|
||||
}
|
||||
|
||||
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
//return false
|
||||
}
|
||||
});
|
||||
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
|
||||
}
|
||||
});
|
||||
});
|
||||
|
27
app/views/admin/price_lines/_form_consult.html.haml
Normal file
27
app/views/admin/price_lines/_form_consult.html.haml
Normal file
@ -0,0 +1,27 @@
|
||||
- price_line = form.object
|
||||
.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
|
||||
.row
|
||||
.col-1
|
||||
.take.mr-1
|
||||
=ic :arrows
|
||||
.col-6
|
||||
Produit :
|
||||
=price_line.p_product_ref.cc_name
|
||||
|
||||
.col-2
|
||||
Base de prix U HT :
|
||||
= price_line.price_u_ht
|
||||
€
|
||||
.col-3
|
||||
.form-inline
|
||||
= form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte form-control mx-2", tabindex: 1}
|
||||
%span.destroy=link_to_remove_fields ic(:"trash-o"), form
|
||||
|
||||
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id"
|
||||
|
||||
|
||||
|
||||
=qi_js_field(form, :price_line, :tva_account_value, :hidden => true)
|
||||
|
||||
= form.hidden_field :position, :class => "price_line_position_input"
|
||||
|
Reference in New Issue
Block a user