Ergo + popup
This commit is contained in:
parent
57bac61ac9
commit
390fe5d98d
@ -56,6 +56,7 @@
|
|||||||
|
|
||||||
#= require freeze-table
|
#= require freeze-table
|
||||||
|
|
||||||
|
#= require admin/random_hexa
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -857,5 +858,3 @@ $(document).on 'click', '.datepicker', (e) ->
|
|||||||
return
|
return
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2
app/assets/javascripts/admin/random_hexa.js
Normal file
2
app/assets/javascripts/admin/random_hexa.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const genRanHex = size => [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join('');
|
||||||
|
|
@ -245,8 +245,8 @@ function select_product_from_manager(input_id){
|
|||||||
|
|
||||||
manager_prompt(p_product_refs_url,function(m_return){
|
manager_prompt(p_product_refs_url,function(m_return){
|
||||||
|
|
||||||
$('.p_product_ref_id_'+input_id).val(m_return.id);
|
$('#p_product_ref_id_'+input_id).val(m_return.id);
|
||||||
$('.p_product_ref_name_'+input_id).val(m_return.name);
|
$('#p_product_ref_name_'+input_id).val(m_return.name);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -10,8 +10,10 @@
|
|||||||
|
|
||||||
if $(link).closest("p").next("." + association + "_form").length > 0
|
if $(link).closest("p").next("." + association + "_form").length > 0
|
||||||
form_element = $(link).closest("p").next("." + association + "_form")
|
form_element = $(link).closest("p").next("." + association + "_form")
|
||||||
else
|
else if $(link).closest("p").prev("." + association + "_form").length > 0
|
||||||
form_element = $(link).closest("p").prev("." + association + "_form")
|
form_element = $(link).closest("p").prev("." + association + "_form")
|
||||||
|
else
|
||||||
|
form_element = $(link).closest(".qi_field_wrapper").find("." + association + "_form")
|
||||||
|
|
||||||
form_element.append content_final
|
form_element.append content_final
|
||||||
|
|
||||||
|
@ -56,12 +56,23 @@
|
|||||||
|
|
||||||
|
|
||||||
=content_for :price_lines do
|
=content_for :price_lines do
|
||||||
.row
|
%div{:style=>"padding:0 30px;"}
|
||||||
.price_lines_form.col-11.row
|
.row.qi_field_wrapper
|
||||||
=f.semantic_fields_for :price_lines do |f|
|
%table{:style => "width:100%;border-collapse:separate;"}
|
||||||
=render :partial => "admin/price_lines/form", :locals => {:form => f}
|
%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.col-1= link_to_add_fields ic("plus-circle") + " ligne", f, :price_lines, {:class => "btn btn-primary p-2", tabindex: 10, style: "position: sticky; top: 100px"}
|
%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")
|
-if current_admin.has_permission?("payments")
|
||||||
|
@ -1,54 +1,63 @@
|
|||||||
|
%tr.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"}
|
||||||
.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{:class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
|
|
||||||
.take.mr-1
|
|
||||||
=ic :arrows
|
|
||||||
%td
|
|
||||||
|
|
||||||
= form.input :ct_title, :label => "Designation personnalisée : " if @avoir
|
|
||||||
-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}"
|
%td{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
|
||||||
%td
|
.take.mr-1
|
||||||
=link_to ic(:search), "#", class: "ml-2",:onclick => "select_product_from_manager('#{key}');return false;"
|
=ic :arrows
|
||||||
|
%td{:style => "white-space: nowrap;"}
|
||||||
|
|
||||||
:javascript
|
|
||||||
var p_product_refs_url = "#{admin_p_product_refs_path(:manager => true)}"
|
|
||||||
|
|
||||||
-form.object.forced_price = true if form.object.ct_u_price_ht
|
|
||||||
|
|
||||||
-if form.object.forced_price and form.object.p_product_ref
|
.input-group
|
||||||
%td
|
%input.p_product_ref_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :value => ("#{form.object.p_product_ref.member_label}" if form.object.p_product_ref), :class => "p_product_ref_name"}
|
||||||
.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-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}
|
|
||||||
|
|
||||||
%td
|
|
||||||
|
|
||||||
|
|
||||||
|
.input-group-append
|
||||||
|
=link_to "#", class: "btn btn-dark",:onclick => "key=genRanHex(12);select_product_from_manager(key);$(this).closest('tr').find('.p_product_ref_id').attr('id', 'p_product_ref_id_'+key);$(this).closest('tr').find('.p_product_ref_name').attr('id', 'p_product_ref_name_'+key);return false;" do
|
||||||
|
=ic(:search)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
= form.hidden_field :p_product_ref_id, :class => "p_product_ref_id"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
var p_product_refs_url = "#{admin_p_product_refs_path(:manager => true)}"
|
||||||
|
|
||||||
|
-form.object.forced_price = true if form.object.ct_u_price_ht
|
||||||
|
|
||||||
|
-if form.object.forced_price and form.object.p_product_ref
|
||||||
|
%td
|
||||||
|
.mx-2
|
||||||
.form-inline
|
.form-inline
|
||||||
%label.mx-2 Taux de TVA :
|
=qi_js_field_price_line_form(form, :price_line, :price_u_ht, :label => false, label_class: "mr-1", :value => form.object.th_price_u_ht)
|
||||||
=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
|
-else
|
||||||
%td
|
%td
|
||||||
.ml-4
|
.mx-2
|
||||||
%span.destroy=link_to_remove_fields ic(:"trash-o"), form
|
.form-inline
|
||||||
|
=qi_js_field_price_line_form(form, :price_line, :price_u_ht, :label =>false, 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{:style => "width:100px;"}
|
||||||
|
|
||||||
|
= form.input :qte, :label => false, :input_html => {:class => "input_price_line_qte form-control", tabindex: 1}
|
||||||
|
|
||||||
|
%td
|
||||||
|
|
||||||
|
|
||||||
|
=form.input :ct_tva_account_id, :collection => 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), :as => :select ,:label => false, :include_blank => false , :input_html => {:class => "input_price_line_tva_account_id form-control custom-select"}
|
||||||
|
|
||||||
|
%td
|
||||||
|
|
||||||
|
%span.destroy=link_to_remove_fields ic(:"trash-o"), form
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -57,50 +66,58 @@
|
|||||||
= form.hidden_field :position, :class => "price_line_position_input"
|
= form.hidden_field :position, :class => "price_line_position_input"
|
||||||
|
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
$('.p_product_ref_autocomplete_input').focus()
|
$('.p_product_ref_autocomplete_input').focus()
|
||||||
$( function() {
|
$( function() {
|
||||||
$('.p_product_ref_autocomplete_input').autocomplete({
|
$('.p_product_ref_autocomplete_input').autocomplete({
|
||||||
source: function( request, response ) {
|
source: function( request, response ) {
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "/admin/p_product_refs/autocomplete.json",
|
url: "/admin/p_product_refs/autocomplete.json",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {
|
data: {
|
||||||
search: request.term,
|
search: request.term,
|
||||||
p_customer_id: $(".p_customer_id").val()
|
p_customer_id: $(".p_customer_id").val()
|
||||||
},
|
},
|
||||||
success: function(data){
|
success: function(data){
|
||||||
arr = jQuery.map( data, function( item ) {
|
arr = jQuery.map( data, function( item ) {
|
||||||
return {
|
return {
|
||||||
label: item.member_label,
|
label: item.member_label,
|
||||||
value: item.member_label,
|
value: item.member_label,
|
||||||
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_product_ref_id").val(ui.item.id)
|
$(this).next(".p_product_ref_id").val(ui.item.id)
|
||||||
form = $(this).closest(".price_line_form")
|
form = $(this).closest(".price_line_form")
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "/admin/p_product_refs/"+ui.item.id+"/get_infos.json",
|
url: "/admin/p_product_refs/"+ui.item.id+"/get_infos.json",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {
|
data: {
|
||||||
type: "price",
|
type: "price",
|
||||||
qte: form.find(".input_price_line_qte").val(),
|
qte: form.find(".input_price_line_qte").val(),
|
||||||
p_customer_id: $(".p_customer_id").val()
|
p_customer_id: $(".p_customer_id").val()
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
form.find(".input_price_line_price_u_ht").val(data.price);
|
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_id").val(data.tva_account_id);
|
||||||
form.find(".input_price_line_tva_account_value").val(data.tva_account_value);
|
form.find(".input_price_line_tva_account_value").val(data.tva_account_value);
|
||||||
form.find(".input_price_line_weight_u").val(data.weight);
|
form.find(".input_price_line_weight_u").val(data.weight);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//return false
|
//return false
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
:scss
|
||||||
|
.price_line_form{
|
||||||
|
.form-group{
|
||||||
|
margin-bottom:0;}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user