From 78d48aa2dd9c1af632cfe03124a3839f12842a80 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Mon, 28 Jan 2019 23:48:41 +0100 Subject: [PATCH] suite --- app/views/admin/p_sheet_lines/_form.html.haml | 76 ++++++++++--------- .../p_sheet_lines/_p_sheet_lines.html.haml | 5 ++ .../_print_p_sheet_lines.html.haml | 5 ++ app/views/public/p_orders/cart.html.haml | 2 + ...128223146_add_cust_ref_to_p_sheet_lines.rb | 5 ++ db/schema.rb | 3 +- 6 files changed, 59 insertions(+), 37 deletions(-) create mode 100644 db/migrate/20190128223146_add_cust_ref_to_p_sheet_lines.rb diff --git a/app/views/admin/p_sheet_lines/_form.html.haml b/app/views/admin/p_sheet_lines/_form.html.haml index eac6d55..8b9e446 100755 --- a/app/views/admin/p_sheet_lines/_form.html.haml +++ b/app/views/admin/p_sheet_lines/_form.html.haml @@ -1,55 +1,59 @@ -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 :" + diff --git a/app/views/admin/p_sheet_lines/_p_sheet_lines.html.haml b/app/views/admin/p_sheet_lines/_p_sheet_lines.html.haml index 81c3bf6..3d6c79b 100644 --- a/app/views/admin/p_sheet_lines/_p_sheet_lines.html.haml +++ b/app/views/admin/p_sheet_lines/_p_sheet_lines.html.haml @@ -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| diff --git a/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml b/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml index 41f76dc..8c1b7ca 100644 --- a/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml +++ b/app/views/admin/p_sheet_lines/_print_p_sheet_lines.html.haml @@ -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| diff --git a/app/views/public/p_orders/cart.html.haml b/app/views/public/p_orders/cart.html.haml index 8113c44..61d5a0e 100644 --- a/app/views/public/p_orders/cart.html.haml +++ b/app/views/public/p_orders/cart.html.haml @@ -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 diff --git a/db/migrate/20190128223146_add_cust_ref_to_p_sheet_lines.rb b/db/migrate/20190128223146_add_cust_ref_to_p_sheet_lines.rb new file mode 100644 index 0000000..2d9f9d3 --- /dev/null +++ b/db/migrate/20190128223146_add_cust_ref_to_p_sheet_lines.rb @@ -0,0 +1,5 @@ +class AddCustRefToPSheetLines < ActiveRecord::Migration + def change + add_column :p_sheet_lines, :cust_ref, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index f792c9e..b387839 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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