This commit is contained in:
Nicolas Bally 2019-01-28 23:48:41 +01:00
parent 03864e04d3
commit 78d48aa2dd
6 changed files with 59 additions and 37 deletions

View File

@ -1,54 +1,58 @@
-if true
#p_sheet_line.product_stock_form.field.p_sheet_line_field{:id => form.object.id}
%table{:style => "width:100%;"}
%tr
%td{:style => "width:70%;"}
-if form.object.lock != true
=link_to_remove_fields ic(:"trash-o"), form
-if form.object.lock != true
=link_to_remove_fields ic(:"trash-o"), form
%label Produit :
%input.p_product_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product.code} #{form.object.p_product.name}" if form.object.p_product), :readonly => ("true" if form.object.id)}
%label Produit :
%input.p_product_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product.code} #{form.object.p_product.name}" if form.object.p_product), :readonly => ("true" if form.object.id)}
= form.hidden_field :p_product_id, :class => "p_product_id"
= form.hidden_field :p_product_id, :class => "p_product_id"
:javascript
$( function() {
:javascript
$( function() {
$('.p_product_autocomplete_input').autocomplete({
source: function( request, response ) {
$.ajax( {
url: "/admin/p_products/autocomplete.json",
dataType: "json",
data: {
search: request.term
},
success: function(data){
$('.p_product_autocomplete_input').autocomplete({
source: function( request, response ) {
$.ajax( {
url: "/admin/p_products/autocomplete.json",
dataType: "json",
data: {
search: request.term
},
success: function(data){
arr = jQuery.map( data, function( item ) {
return {
label: item.code+" "+item.name,
value: item.code+" "+item.name,
id: item.id
}
});
arr = jQuery.map( data, function( item ) {
return {
label: item.code+" "+item.name,
value: item.code+" "+item.name,
id: item.id
}
});
response(arr)
response(arr)
}
}
} );
},
minLength: 2,
select: function( event, ui ) {
} );
},
minLength: 2,
select: function( event, ui ) {
$(this).next(".p_product_id").val(ui.item.id)
$(this).next(".p_product_id").val(ui.item.id)
//return false
}
});
//return false
}
});
} );
} );
%td{:style => "width:30%;"}
=form.input :cust_ref, :label => "Référence client :"

View File

@ -42,6 +42,11 @@
%tr
%th{:style => "text-align:left !important;"}
=sheet_line.product_name
-if sheet_line.cust_ref?
%strong{:style => "font-weight:normal;"}
="-"
Réf client :
=sheet_line.cust_ref
-sheet_line.p_product.p_sizes.order("p_sizes.position ASC, p_sizes.id ASC").all.each do |psize|

View File

@ -35,6 +35,11 @@
%tr
%th{:style => "text-align:left !important;"}
=sheet_line.product_name
-if sheet_line.cust_ref?
%strong{:style => "font-weight:normal;"}
="-"
Réf client :
=sheet_line.cust_ref
-p_sheet_line_lines.group(:p_size_id).joins(:p_size).order("p_sizes.position ASC, p_sizes.id ASC").uniq.each do |psize|

View File

@ -39,6 +39,8 @@
%th
=form.object.p_product.name
=link_to_remove_fields ic(:"trash-o"), form
%br
=form.input :cust_ref, :placeholder => "Votre référence", :label => false
-p_product.p_sizes.all.each do |p_size|
%th.size_th

View File

@ -0,0 +1,5 @@
class AddCustRefToPSheetLines < ActiveRecord::Migration
def change
add_column :p_sheet_lines, :cust_ref, :string
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20190120142139) do
ActiveRecord::Schema.define(version: 20190128223146) do
create_table "admin_admin_roles", force: :cascade do |t|
t.integer "admin_id", limit: 4
@ -1171,6 +1171,7 @@ ActiveRecord::Schema.define(version: 20190120142139) do
t.integer "archived_p_color_id", limit: 4
t.string "archived_code", limit: 255
t.integer "archived_p_product_id", limit: 4
t.string "cust_ref", limit: 255
end
add_index "p_sheet_lines", ["p_product_stock_id"], name: "index_p_sheet_lines_on_p_product_stock_id", using: :btree