From 95b78299270f8cd0713dbf24931cf41e040910e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 23 Aug 2021 16:42:42 +0200 Subject: [PATCH 001/121] Remove status input --- app/models/p_customer_sheet.rb | 2 +- app/views/admin/p_customer_sheets/_form.html.haml | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb index 70d1426..c38ed4c 100644 --- a/app/models/p_customer_sheet.rb +++ b/app/models/p_customer_sheet.rb @@ -256,7 +256,7 @@ class PCustomerSheet < ApplicationRecord after_create do - #self.state = "brouillon" if self.state != "Panier web" + self.state = "brouillon" if self.state != "Panier web" self.save end diff --git a/app/views/admin/p_customer_sheets/_form.html.haml b/app/views/admin/p_customer_sheets/_form.html.haml index c8c82b9..16361e8 100755 --- a/app/views/admin/p_customer_sheets/_form.html.haml +++ b/app/views/admin/p_customer_sheets/_form.html.haml @@ -1,14 +1,7 @@ =semantic_form_for [:admin, @p_customer_sheet], :html => {:class => "qi_price_form"}, :remote => false do |form| .content - .qi_row - .qi_pannel.qi_plain.padding - -if @p_customer_sheet and @p_customer_sheet.state != "commande" - =#form.input :demande_type, :collection => ["Brouillon", "Demande de bon de commande","Demande de devis"], :as => :select, :include_blank => false, :label => "Type de demande :" - - =form.input :state, :collection => ["AV BPA", "PAS BPA","BPA", "Traitée"], :as => :select, :include_blank => false, :label => "Statut :" - - =form.input :past_id, :label => "N° système actuel" + .price_line_block_form =form.semantic_fields_for :price_line_block do |f| From 399cc1deaa57330d2a03d7fc0f767b483d1929e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 24 Aug 2021 10:24:56 +0200 Subject: [PATCH 002/121] replace state --- app/controllers/admin/buy_lists_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/buy_lists_controller.rb b/app/controllers/admin/buy_lists_controller.rb index cd1b7b6..d68d6b3 100644 --- a/app/controllers/admin/buy_lists_controller.rb +++ b/app/controllers/admin/buy_lists_controller.rb @@ -8,7 +8,7 @@ class Admin::BuyListsController < ApplicationController @p_customer_sheets = PCustomerSheet.all - @p_customer_sheets = @p_customer_sheets.where(:state => ["AV BPA", "PAS BPA", "BPA"]) + @p_customer_sheets = @p_customer_sheets.where(:state => ["brouillon", "offre", "commande"]) @price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids) From c687353802ea301f6fda4a24a0e0e35659f8d306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 26 Aug 2021 15:58:34 +0200 Subject: [PATCH 003/121] Generate qis PArticle --- .../admin/p_articles_controller.rb | 76 +++++++++++++++++++ app/models/p_article.rb | 3 + app/views/admin/p_articles/_form.html.haml | 12 +++ .../admin/p_articles/_p_article.html.haml | 16 ++++ app/views/admin/p_articles/create.js.erb | 2 + app/views/admin/p_articles/destroy.js.erb | 1 + app/views/admin/p_articles/edit.js.erb | 1 + app/views/admin/p_articles/index.html.haml | 16 ++++ app/views/admin/p_articles/new.js.erb | 1 + app/views/admin/p_articles/show.html.haml | 10 +++ app/views/admin/p_articles/update.js.erb | 2 + config/routes.rb | 11 +++ .../20210826135742_create_p_articles.rb | 9 +++ test/fixtures/p_articles.yml | 7 ++ test/models/p_article_test.rb | 7 ++ 15 files changed, 174 insertions(+) create mode 100644 app/controllers/admin/p_articles_controller.rb create mode 100644 app/models/p_article.rb create mode 100644 app/views/admin/p_articles/_form.html.haml create mode 100644 app/views/admin/p_articles/_p_article.html.haml create mode 100644 app/views/admin/p_articles/create.js.erb create mode 100644 app/views/admin/p_articles/destroy.js.erb create mode 100644 app/views/admin/p_articles/edit.js.erb create mode 100644 app/views/admin/p_articles/index.html.haml create mode 100644 app/views/admin/p_articles/new.js.erb create mode 100644 app/views/admin/p_articles/show.html.haml create mode 100644 app/views/admin/p_articles/update.js.erb create mode 100644 db/migrate/20210826135742_create_p_articles.rb create mode 100644 test/fixtures/p_articles.yml create mode 100644 test/models/p_article_test.rb diff --git a/app/controllers/admin/p_articles_controller.rb b/app/controllers/admin/p_articles_controller.rb new file mode 100644 index 0000000..62a2b86 --- /dev/null +++ b/app/controllers/admin/p_articles_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PArticlesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_articles = PArticle.all + + @p_articles = sort_by_sorting(@p_articles, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_articles = @p_articles.page(page).per(per_page) + + } + end + end + + def show + @p_article = PArticle.find(params[:id]) + + end + + def new + @p_article = PArticle.new + + end + + def edit + @p_article = PArticle.find(params[:id]) + + end + + def create + @p_article = PArticle.new(params.require(:p_article).permit!) + + if @p_article.save + + else + render action: "new" + + end + + end + + + def update + @p_article = PArticle.find(params[:id]) + + + if @p_article.update_attributes(params.require(:p_article).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_article = PArticle.find(params[:id]) + @p_article.destroy + + end +end diff --git a/app/models/p_article.rb b/app/models/p_article.rb new file mode 100644 index 0000000..325db1a --- /dev/null +++ b/app/models/p_article.rb @@ -0,0 +1,3 @@ +class PArticle < ApplicationRecord + belongs_to :p_product_ref +end diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml new file mode 100644 index 0000000..6561210 --- /dev/null +++ b/app/views/admin/p_articles/_form.html.haml @@ -0,0 +1,12 @@ +=semantic_form_for [:admin, @p_article], :remote => true do |f| + + .content + =f.inputs do + = f.input :p_product_ref, :label => f.object.label_for(:p_product_ref) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_articles/_p_article.html.haml b/app/views/admin/p_articles/_p_article.html.haml new file mode 100644 index 0000000..171a403 --- /dev/null +++ b/app/views/admin/p_articles/_p_article.html.haml @@ -0,0 +1,16 @@ +%tr#p_article_row{:id => p_article.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_article], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_article_path(p_article), :remote => true + = link_to i(:eye), admin_p_article_path(p_article), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_article} + + + + \ No newline at end of file diff --git a/app/views/admin/p_articles/create.js.erb b/app/views/admin/p_articles/create.js.erb new file mode 100644 index 0000000..4638f5f --- /dev/null +++ b/app/views/admin/p_articles/create.js.erb @@ -0,0 +1,2 @@ +$('#p_articles_rows').prepend("<%= escape_javascript(render(@p_article))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_articles/destroy.js.erb b/app/views/admin/p_articles/destroy.js.erb new file mode 100644 index 0000000..267d137 --- /dev/null +++ b/app/views/admin/p_articles/destroy.js.erb @@ -0,0 +1 @@ +$('#p_article_row_<%= @p_article.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_articles/edit.js.erb b/app/views/admin/p_articles/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_articles/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_articles/index.html.haml b/app/views/admin/p_articles/index.html.haml new file mode 100644 index 0000000..2b77ca5 --- /dev/null +++ b/app/views/admin/p_articles/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_article_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PArticle.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_articles} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_articles} + + + diff --git a/app/views/admin/p_articles/new.js.erb b/app/views/admin/p_articles/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_articles/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_articles/show.html.haml b/app/views/admin/p_articles/show.html.haml new file mode 100644 index 0000000..63cfc6a --- /dev/null +++ b/app/views/admin/p_articles/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_article \ No newline at end of file diff --git a/app/views/admin/p_articles/update.js.erb b/app/views/admin/p_articles/update.js.erb new file mode 100644 index 0000000..54d637a --- /dev/null +++ b/app/views/admin/p_articles/update.js.erb @@ -0,0 +1,2 @@ +$('#p_article_row_<%= @p_article.id %>').replaceWith("<%= escape_javascript(render(@p_article))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 226c9c5..482f7d5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_articles do + member do + + end + collection do + + end + end + end + namespace :admin do resources :buy_lists do member do diff --git a/db/migrate/20210826135742_create_p_articles.rb b/db/migrate/20210826135742_create_p_articles.rb new file mode 100644 index 0000000..67ccbf1 --- /dev/null +++ b/db/migrate/20210826135742_create_p_articles.rb @@ -0,0 +1,9 @@ +class CreatePArticles < ActiveRecord::Migration[6.0] + def change + create_table :p_articles do |t| + t.references :p_product_ref, foreign_key: true + + t.timestamps + end + end +end diff --git a/test/fixtures/p_articles.yml b/test/fixtures/p_articles.yml new file mode 100644 index 0000000..28280d4 --- /dev/null +++ b/test/fixtures/p_articles.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + p_product_ref: one + +two: + p_product_ref: two diff --git a/test/models/p_article_test.rb b/test/models/p_article_test.rb new file mode 100644 index 0000000..8e6e762 --- /dev/null +++ b/test/models/p_article_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PArticleTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 2897a604550348e4dc4478d7a0133b778241bcb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 26 Aug 2021 16:03:24 +0200 Subject: [PATCH 004/121] p_article migration --- db/schema.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 734a9dc..b3956ac 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_07_06_171352) do +ActiveRecord::Schema.define(version: 2021_08_26_135742) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -970,6 +970,13 @@ ActiveRecord::Schema.define(version: 2021_07_06_171352) do t.datetime "updated_at", precision: 6, null: false end + create_table "p_articles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.bigint "p_product_ref_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["p_product_ref_id"], name: "index_p_articles_on_p_product_ref_id" + end + create_table "p_bank_accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.bigint "p_bank_id" t.string "iban" @@ -2336,7 +2343,6 @@ ActiveRecord::Schema.define(version: 2021_07_06_171352) do t.integer "order_hist_id" t.boolean "imported", default: false t.date "validation_date" - t.date "cc_validation_date" t.string "cc_state" t.index ["p_customer_id"], name: "index_price_line_blocks_on_p_customer_id" end @@ -3050,6 +3056,7 @@ ActiveRecord::Schema.define(version: 2021_07_06_171352) do add_foreign_key "order_hist_lines", "p_customers" add_foreign_key "order_hist_lines", "p_payment_types" add_foreign_key "order_hist_lines", "p_product_refs" + add_foreign_key "p_articles", "p_product_refs" add_foreign_key "p_commercial_object_brands", "p_commercial_objectives" add_foreign_key "p_commercial_object_brands", "p_commercials" add_foreign_key "p_commercial_object_brands", "s_brands" From 6222b44a9b0fb55be687864b2c6cb2d036656556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 26 Aug 2021 16:04:27 +0200 Subject: [PATCH 005/121] generate qis p_serial_num_type --- .../admin/p_serial_num_types_controller.rb | 76 +++++++++++++++++++ app/models/p_serial_num_type.rb | 2 + .../admin/p_serial_num_types/_form.html.haml | 12 +++ .../_p_serial_num_type.html.haml | 16 ++++ .../admin/p_serial_num_types/create.js.erb | 2 + .../admin/p_serial_num_types/destroy.js.erb | 1 + .../admin/p_serial_num_types/edit.js.erb | 1 + .../admin/p_serial_num_types/index.html.haml | 16 ++++ app/views/admin/p_serial_num_types/new.js.erb | 1 + .../admin/p_serial_num_types/show.html.haml | 10 +++ .../admin/p_serial_num_types/update.js.erb | 2 + config/routes.rb | 11 +++ ...0210826140333_create_p_serial_num_types.rb | 9 +++ db/schema.rb | 8 +- test/fixtures/p_serial_num_types.yml | 7 ++ test/models/p_serial_num_type_test.rb | 7 ++ 16 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/p_serial_num_types_controller.rb create mode 100644 app/models/p_serial_num_type.rb create mode 100644 app/views/admin/p_serial_num_types/_form.html.haml create mode 100644 app/views/admin/p_serial_num_types/_p_serial_num_type.html.haml create mode 100644 app/views/admin/p_serial_num_types/create.js.erb create mode 100644 app/views/admin/p_serial_num_types/destroy.js.erb create mode 100644 app/views/admin/p_serial_num_types/edit.js.erb create mode 100644 app/views/admin/p_serial_num_types/index.html.haml create mode 100644 app/views/admin/p_serial_num_types/new.js.erb create mode 100644 app/views/admin/p_serial_num_types/show.html.haml create mode 100644 app/views/admin/p_serial_num_types/update.js.erb create mode 100644 db/migrate/20210826140333_create_p_serial_num_types.rb create mode 100644 test/fixtures/p_serial_num_types.yml create mode 100644 test/models/p_serial_num_type_test.rb diff --git a/app/controllers/admin/p_serial_num_types_controller.rb b/app/controllers/admin/p_serial_num_types_controller.rb new file mode 100644 index 0000000..7fa9e38 --- /dev/null +++ b/app/controllers/admin/p_serial_num_types_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PSerialNumTypesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_serial_num_types = PSerialNumType.all + + @p_serial_num_types = sort_by_sorting(@p_serial_num_types, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_serial_num_types = @p_serial_num_types.page(page).per(per_page) + + } + end + end + + def show + @p_serial_num_type = PSerialNumType.find(params[:id]) + + end + + def new + @p_serial_num_type = PSerialNumType.new + + end + + def edit + @p_serial_num_type = PSerialNumType.find(params[:id]) + + end + + def create + @p_serial_num_type = PSerialNumType.new(params.require(:p_serial_num_type).permit!) + + if @p_serial_num_type.save + + else + render action: "new" + + end + + end + + + def update + @p_serial_num_type = PSerialNumType.find(params[:id]) + + + if @p_serial_num_type.update_attributes(params.require(:p_serial_num_type).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_serial_num_type = PSerialNumType.find(params[:id]) + @p_serial_num_type.destroy + + end +end diff --git a/app/models/p_serial_num_type.rb b/app/models/p_serial_num_type.rb new file mode 100644 index 0000000..62c20f6 --- /dev/null +++ b/app/models/p_serial_num_type.rb @@ -0,0 +1,2 @@ +class PSerialNumType < ApplicationRecord +end diff --git a/app/views/admin/p_serial_num_types/_form.html.haml b/app/views/admin/p_serial_num_types/_form.html.haml new file mode 100644 index 0000000..70b89fe --- /dev/null +++ b/app/views/admin/p_serial_num_types/_form.html.haml @@ -0,0 +1,12 @@ +=semantic_form_for [:admin, @p_serial_num_type], :remote => true do |f| + + .content + =f.inputs do + = f.input :type, :label => f.object.label_for(:type) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/_p_serial_num_type.html.haml b/app/views/admin/p_serial_num_types/_p_serial_num_type.html.haml new file mode 100644 index 0000000..db6e57b --- /dev/null +++ b/app/views/admin/p_serial_num_types/_p_serial_num_type.html.haml @@ -0,0 +1,16 @@ +%tr#p_serial_num_type_row{:id => p_serial_num_type.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_serial_num_type], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_serial_num_type_path(p_serial_num_type), :remote => true + = link_to i(:eye), admin_p_serial_num_type_path(p_serial_num_type), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_serial_num_type} + + + + \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/create.js.erb b/app/views/admin/p_serial_num_types/create.js.erb new file mode 100644 index 0000000..1bcfb90 --- /dev/null +++ b/app/views/admin/p_serial_num_types/create.js.erb @@ -0,0 +1,2 @@ +$('#p_serial_num_types_rows').prepend("<%= escape_javascript(render(@p_serial_num_type))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/destroy.js.erb b/app/views/admin/p_serial_num_types/destroy.js.erb new file mode 100644 index 0000000..25bf828 --- /dev/null +++ b/app/views/admin/p_serial_num_types/destroy.js.erb @@ -0,0 +1 @@ +$('#p_serial_num_type_row_<%= @p_serial_num_type.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/edit.js.erb b/app/views/admin/p_serial_num_types/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_serial_num_types/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/index.html.haml b/app/views/admin/p_serial_num_types/index.html.haml new file mode 100644 index 0000000..6e9745d --- /dev/null +++ b/app/views/admin/p_serial_num_types/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_serial_num_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PSerialNumType.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_serial_num_types} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_serial_num_types} + + + diff --git a/app/views/admin/p_serial_num_types/new.js.erb b/app/views/admin/p_serial_num_types/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_serial_num_types/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/show.html.haml b/app/views/admin/p_serial_num_types/show.html.haml new file mode 100644 index 0000000..6ab5cdf --- /dev/null +++ b/app/views/admin/p_serial_num_types/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_serial_num_type \ No newline at end of file diff --git a/app/views/admin/p_serial_num_types/update.js.erb b/app/views/admin/p_serial_num_types/update.js.erb new file mode 100644 index 0000000..beac1d8 --- /dev/null +++ b/app/views/admin/p_serial_num_types/update.js.erb @@ -0,0 +1,2 @@ +$('#p_serial_num_type_row_<%= @p_serial_num_type.id %>').replaceWith("<%= escape_javascript(render(@p_serial_num_type))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 482f7d5..f5c5493 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_serial_num_types do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_articles do member do diff --git a/db/migrate/20210826140333_create_p_serial_num_types.rb b/db/migrate/20210826140333_create_p_serial_num_types.rb new file mode 100644 index 0000000..e713124 --- /dev/null +++ b/db/migrate/20210826140333_create_p_serial_num_types.rb @@ -0,0 +1,9 @@ +class CreatePSerialNumTypes < ActiveRecord::Migration[6.0] + def change + create_table :p_serial_num_types do |t| + t.string :type + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index b3956ac..0cdad91 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_26_135742) do +ActiveRecord::Schema.define(version: 2021_08_26_140333) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1866,6 +1866,12 @@ ActiveRecord::Schema.define(version: 2021_08_26_135742) do t.index ["p_payment_type_id"], name: "index_p_remises_on_p_payment_type_id" end + create_table "p_serial_num_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.string "type" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "p_sheet_line_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.bigint "p_sheet_line_id" t.bigint "p_brut_product_id" diff --git a/test/fixtures/p_serial_num_types.yml b/test/fixtures/p_serial_num_types.yml new file mode 100644 index 0000000..860f9b8 --- /dev/null +++ b/test/fixtures/p_serial_num_types.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + type: + +two: + type: diff --git a/test/models/p_serial_num_type_test.rb b/test/models/p_serial_num_type_test.rb new file mode 100644 index 0000000..63011d9 --- /dev/null +++ b/test/models/p_serial_num_type_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PSerialNumTypeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 99801d37a7063d116028386e798be4a9c8ae96cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 26 Aug 2021 16:05:22 +0200 Subject: [PATCH 006/121] generate qis p_serial_num_value --- .../admin/p_serial_num_values_controller.rb | 76 +++++++++++++++++++ app/models/p_serial_num_value.rb | 2 + .../admin/p_serial_num_values/_form.html.haml | 12 +++ .../_p_serial_num_value.html.haml | 16 ++++ .../admin/p_serial_num_values/create.js.erb | 2 + .../admin/p_serial_num_values/destroy.js.erb | 1 + .../admin/p_serial_num_values/edit.js.erb | 1 + .../admin/p_serial_num_values/index.html.haml | 16 ++++ .../admin/p_serial_num_values/new.js.erb | 1 + .../admin/p_serial_num_values/show.html.haml | 10 +++ .../admin/p_serial_num_values/update.js.erb | 2 + config/routes.rb | 11 +++ ...210826140445_create_p_serial_num_values.rb | 9 +++ db/schema.rb | 8 +- test/fixtures/p_serial_num_values.yml | 7 ++ test/models/p_serial_num_value_test.rb | 7 ++ 16 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/p_serial_num_values_controller.rb create mode 100644 app/models/p_serial_num_value.rb create mode 100644 app/views/admin/p_serial_num_values/_form.html.haml create mode 100644 app/views/admin/p_serial_num_values/_p_serial_num_value.html.haml create mode 100644 app/views/admin/p_serial_num_values/create.js.erb create mode 100644 app/views/admin/p_serial_num_values/destroy.js.erb create mode 100644 app/views/admin/p_serial_num_values/edit.js.erb create mode 100644 app/views/admin/p_serial_num_values/index.html.haml create mode 100644 app/views/admin/p_serial_num_values/new.js.erb create mode 100644 app/views/admin/p_serial_num_values/show.html.haml create mode 100644 app/views/admin/p_serial_num_values/update.js.erb create mode 100644 db/migrate/20210826140445_create_p_serial_num_values.rb create mode 100644 test/fixtures/p_serial_num_values.yml create mode 100644 test/models/p_serial_num_value_test.rb diff --git a/app/controllers/admin/p_serial_num_values_controller.rb b/app/controllers/admin/p_serial_num_values_controller.rb new file mode 100644 index 0000000..05c3bde --- /dev/null +++ b/app/controllers/admin/p_serial_num_values_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PSerialNumValuesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_serial_num_values = PSerialNumValue.all + + @p_serial_num_values = sort_by_sorting(@p_serial_num_values, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_serial_num_values = @p_serial_num_values.page(page).per(per_page) + + } + end + end + + def show + @p_serial_num_value = PSerialNumValue.find(params[:id]) + + end + + def new + @p_serial_num_value = PSerialNumValue.new + + end + + def edit + @p_serial_num_value = PSerialNumValue.find(params[:id]) + + end + + def create + @p_serial_num_value = PSerialNumValue.new(params.require(:p_serial_num_value).permit!) + + if @p_serial_num_value.save + + else + render action: "new" + + end + + end + + + def update + @p_serial_num_value = PSerialNumValue.find(params[:id]) + + + if @p_serial_num_value.update_attributes(params.require(:p_serial_num_value).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_serial_num_value = PSerialNumValue.find(params[:id]) + @p_serial_num_value.destroy + + end +end diff --git a/app/models/p_serial_num_value.rb b/app/models/p_serial_num_value.rb new file mode 100644 index 0000000..735a10d --- /dev/null +++ b/app/models/p_serial_num_value.rb @@ -0,0 +1,2 @@ +class PSerialNumValue < ApplicationRecord +end diff --git a/app/views/admin/p_serial_num_values/_form.html.haml b/app/views/admin/p_serial_num_values/_form.html.haml new file mode 100644 index 0000000..7ad0960 --- /dev/null +++ b/app/views/admin/p_serial_num_values/_form.html.haml @@ -0,0 +1,12 @@ +=semantic_form_for [:admin, @p_serial_num_value], :remote => true do |f| + + .content + =f.inputs do + = f.input :value, :label => f.object.label_for(:value) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/_p_serial_num_value.html.haml b/app/views/admin/p_serial_num_values/_p_serial_num_value.html.haml new file mode 100644 index 0000000..52d6eee --- /dev/null +++ b/app/views/admin/p_serial_num_values/_p_serial_num_value.html.haml @@ -0,0 +1,16 @@ +%tr#p_serial_num_value_row{:id => p_serial_num_value.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_serial_num_value], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_serial_num_value_path(p_serial_num_value), :remote => true + = link_to i(:eye), admin_p_serial_num_value_path(p_serial_num_value), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_serial_num_value} + + + + \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/create.js.erb b/app/views/admin/p_serial_num_values/create.js.erb new file mode 100644 index 0000000..f53ff23 --- /dev/null +++ b/app/views/admin/p_serial_num_values/create.js.erb @@ -0,0 +1,2 @@ +$('#p_serial_num_values_rows').prepend("<%= escape_javascript(render(@p_serial_num_value))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/destroy.js.erb b/app/views/admin/p_serial_num_values/destroy.js.erb new file mode 100644 index 0000000..1622e2d --- /dev/null +++ b/app/views/admin/p_serial_num_values/destroy.js.erb @@ -0,0 +1 @@ +$('#p_serial_num_value_row_<%= @p_serial_num_value.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/edit.js.erb b/app/views/admin/p_serial_num_values/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_serial_num_values/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/index.html.haml b/app/views/admin/p_serial_num_values/index.html.haml new file mode 100644 index 0000000..7e600fc --- /dev/null +++ b/app/views/admin/p_serial_num_values/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_serial_num_value_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PSerialNumValue.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_serial_num_values} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_serial_num_values} + + + diff --git a/app/views/admin/p_serial_num_values/new.js.erb b/app/views/admin/p_serial_num_values/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_serial_num_values/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/show.html.haml b/app/views/admin/p_serial_num_values/show.html.haml new file mode 100644 index 0000000..e9b982d --- /dev/null +++ b/app/views/admin/p_serial_num_values/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_serial_num_value \ No newline at end of file diff --git a/app/views/admin/p_serial_num_values/update.js.erb b/app/views/admin/p_serial_num_values/update.js.erb new file mode 100644 index 0000000..d272f5f --- /dev/null +++ b/app/views/admin/p_serial_num_values/update.js.erb @@ -0,0 +1,2 @@ +$('#p_serial_num_value_row_<%= @p_serial_num_value.id %>').replaceWith("<%= escape_javascript(render(@p_serial_num_value))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f5c5493..c06dc26 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_serial_num_values do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_serial_num_types do member do diff --git a/db/migrate/20210826140445_create_p_serial_num_values.rb b/db/migrate/20210826140445_create_p_serial_num_values.rb new file mode 100644 index 0000000..79660b3 --- /dev/null +++ b/db/migrate/20210826140445_create_p_serial_num_values.rb @@ -0,0 +1,9 @@ +class CreatePSerialNumValues < ActiveRecord::Migration[6.0] + def change + create_table :p_serial_num_values do |t| + t.string :value + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 0cdad91..5bc2582 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_26_140333) do +ActiveRecord::Schema.define(version: 2021_08_26_140445) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1872,6 +1872,12 @@ ActiveRecord::Schema.define(version: 2021_08_26_140333) do t.datetime "updated_at", precision: 6, null: false end + create_table "p_serial_num_values", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.string "value" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "p_sheet_line_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.bigint "p_sheet_line_id" t.bigint "p_brut_product_id" diff --git a/test/fixtures/p_serial_num_values.yml b/test/fixtures/p_serial_num_values.yml new file mode 100644 index 0000000..ebe29a0 --- /dev/null +++ b/test/fixtures/p_serial_num_values.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + value: MyString + +two: + value: MyString diff --git a/test/models/p_serial_num_value_test.rb b/test/models/p_serial_num_value_test.rb new file mode 100644 index 0000000..812717c --- /dev/null +++ b/test/models/p_serial_num_value_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PSerialNumValueTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 02614f1ec245571e4732501c3846868557895e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 26 Aug 2021 16:07:23 +0200 Subject: [PATCH 007/121] generate qis p_article_serial_num --- .../admin/p_article_serial_nums_controller.rb | 76 +++++++++++++++++++ app/models/p_article_serial_num.rb | 5 ++ .../p_article_serial_nums/_form.html.haml | 14 ++++ .../_p_article_serial_num.html.haml | 16 ++++ .../admin/p_article_serial_nums/create.js.erb | 2 + .../p_article_serial_nums/destroy.js.erb | 1 + .../admin/p_article_serial_nums/edit.js.erb | 1 + .../p_article_serial_nums/index.html.haml | 16 ++++ .../admin/p_article_serial_nums/new.js.erb | 1 + .../p_article_serial_nums/show.html.haml | 10 +++ .../admin/p_article_serial_nums/update.js.erb | 2 + config/routes.rb | 11 +++ ...0826140648_create_p_article_serial_nums.rb | 11 +++ db/schema.rb | 16 +++- test/fixtures/p_article_serial_nums.yml | 11 +++ test/models/p_article_serial_num_test.rb | 7 ++ 16 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/p_article_serial_nums_controller.rb create mode 100644 app/models/p_article_serial_num.rb create mode 100644 app/views/admin/p_article_serial_nums/_form.html.haml create mode 100644 app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml create mode 100644 app/views/admin/p_article_serial_nums/create.js.erb create mode 100644 app/views/admin/p_article_serial_nums/destroy.js.erb create mode 100644 app/views/admin/p_article_serial_nums/edit.js.erb create mode 100644 app/views/admin/p_article_serial_nums/index.html.haml create mode 100644 app/views/admin/p_article_serial_nums/new.js.erb create mode 100644 app/views/admin/p_article_serial_nums/show.html.haml create mode 100644 app/views/admin/p_article_serial_nums/update.js.erb create mode 100644 db/migrate/20210826140648_create_p_article_serial_nums.rb create mode 100644 test/fixtures/p_article_serial_nums.yml create mode 100644 test/models/p_article_serial_num_test.rb diff --git a/app/controllers/admin/p_article_serial_nums_controller.rb b/app/controllers/admin/p_article_serial_nums_controller.rb new file mode 100644 index 0000000..000d7cb --- /dev/null +++ b/app/controllers/admin/p_article_serial_nums_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PArticleSerialNumsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_article_serial_nums = PArticleSerialNum.all + + @p_article_serial_nums = sort_by_sorting(@p_article_serial_nums, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_article_serial_nums = @p_article_serial_nums.page(page).per(per_page) + + } + end + end + + def show + @p_article_serial_num = PArticleSerialNum.find(params[:id]) + + end + + def new + @p_article_serial_num = PArticleSerialNum.new + + end + + def edit + @p_article_serial_num = PArticleSerialNum.find(params[:id]) + + end + + def create + @p_article_serial_num = PArticleSerialNum.new(params.require(:p_article_serial_num).permit!) + + if @p_article_serial_num.save + + else + render action: "new" + + end + + end + + + def update + @p_article_serial_num = PArticleSerialNum.find(params[:id]) + + + if @p_article_serial_num.update_attributes(params.require(:p_article_serial_num).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_article_serial_num = PArticleSerialNum.find(params[:id]) + @p_article_serial_num.destroy + + end +end diff --git a/app/models/p_article_serial_num.rb b/app/models/p_article_serial_num.rb new file mode 100644 index 0000000..c4c2da1 --- /dev/null +++ b/app/models/p_article_serial_num.rb @@ -0,0 +1,5 @@ +class PArticleSerialNum < ApplicationRecord + belongs_to :p_article + belongs_to :p_serial_num_type + belongs_to :p_serial_num_value +end diff --git a/app/views/admin/p_article_serial_nums/_form.html.haml b/app/views/admin/p_article_serial_nums/_form.html.haml new file mode 100644 index 0000000..88c40df --- /dev/null +++ b/app/views/admin/p_article_serial_nums/_form.html.haml @@ -0,0 +1,14 @@ +=semantic_form_for [:admin, @p_article_serial_num], :remote => true do |f| + + .content + =f.inputs do + = f.input :p_article, :label => f.object.label_for(:p_article) + = f.input :p_serial_num_type, :label => f.object.label_for(:p_serial_num_type) + = f.input :p_serial_num_value, :label => f.object.label_for(:p_serial_num_value) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml b/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml new file mode 100644 index 0000000..b6e652b --- /dev/null +++ b/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml @@ -0,0 +1,16 @@ +%tr#p_article_serial_num_row{:id => p_article_serial_num.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_article_serial_num], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_article_serial_num_path(p_article_serial_num), :remote => true + = link_to i(:eye), admin_p_article_serial_num_path(p_article_serial_num), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_article_serial_num} + + + + \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/create.js.erb b/app/views/admin/p_article_serial_nums/create.js.erb new file mode 100644 index 0000000..0f45d7b --- /dev/null +++ b/app/views/admin/p_article_serial_nums/create.js.erb @@ -0,0 +1,2 @@ +$('#p_article_serial_nums_rows').prepend("<%= escape_javascript(render(@p_article_serial_num))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/destroy.js.erb b/app/views/admin/p_article_serial_nums/destroy.js.erb new file mode 100644 index 0000000..bfed426 --- /dev/null +++ b/app/views/admin/p_article_serial_nums/destroy.js.erb @@ -0,0 +1 @@ +$('#p_article_serial_num_row_<%= @p_article_serial_num.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/edit.js.erb b/app/views/admin/p_article_serial_nums/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_article_serial_nums/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/index.html.haml b/app/views/admin/p_article_serial_nums/index.html.haml new file mode 100644 index 0000000..2a60940 --- /dev/null +++ b/app/views/admin/p_article_serial_nums/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_article_serial_num_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PArticleSerialNum.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_article_serial_nums} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_article_serial_nums} + + + diff --git a/app/views/admin/p_article_serial_nums/new.js.erb b/app/views/admin/p_article_serial_nums/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_article_serial_nums/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/show.html.haml b/app/views/admin/p_article_serial_nums/show.html.haml new file mode 100644 index 0000000..b32815c --- /dev/null +++ b/app/views/admin/p_article_serial_nums/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_article_serial_num \ No newline at end of file diff --git a/app/views/admin/p_article_serial_nums/update.js.erb b/app/views/admin/p_article_serial_nums/update.js.erb new file mode 100644 index 0000000..2a1b65c --- /dev/null +++ b/app/views/admin/p_article_serial_nums/update.js.erb @@ -0,0 +1,2 @@ +$('#p_article_serial_num_row_<%= @p_article_serial_num.id %>').replaceWith("<%= escape_javascript(render(@p_article_serial_num))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c06dc26..00b564d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_article_serial_nums do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_serial_num_values do member do diff --git a/db/migrate/20210826140648_create_p_article_serial_nums.rb b/db/migrate/20210826140648_create_p_article_serial_nums.rb new file mode 100644 index 0000000..a68ebe3 --- /dev/null +++ b/db/migrate/20210826140648_create_p_article_serial_nums.rb @@ -0,0 +1,11 @@ +class CreatePArticleSerialNums < ActiveRecord::Migration[6.0] + def change + create_table :p_article_serial_nums do |t| + t.references :p_article, foreign_key: true + t.references :p_serial_num_type, foreign_key: true + t.references :p_serial_num_value, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5bc2582..53e2114 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_26_140445) do +ActiveRecord::Schema.define(version: 2021_08_26_140648) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -970,6 +970,17 @@ ActiveRecord::Schema.define(version: 2021_08_26_140445) do t.datetime "updated_at", precision: 6, null: false end + create_table "p_article_serial_nums", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.bigint "p_article_id" + t.bigint "p_serial_num_type_id" + t.bigint "p_serial_num_value_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["p_article_id"], name: "index_p_article_serial_nums_on_p_article_id" + t.index ["p_serial_num_type_id"], name: "index_p_article_serial_nums_on_p_serial_num_type_id" + t.index ["p_serial_num_value_id"], name: "index_p_article_serial_nums_on_p_serial_num_value_id" + end + create_table "p_articles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.bigint "p_product_ref_id" t.datetime "created_at", precision: 6, null: false @@ -3068,6 +3079,9 @@ ActiveRecord::Schema.define(version: 2021_08_26_140445) do add_foreign_key "order_hist_lines", "p_customers" add_foreign_key "order_hist_lines", "p_payment_types" add_foreign_key "order_hist_lines", "p_product_refs" + add_foreign_key "p_article_serial_nums", "p_articles" + add_foreign_key "p_article_serial_nums", "p_serial_num_types" + add_foreign_key "p_article_serial_nums", "p_serial_num_values" add_foreign_key "p_articles", "p_product_refs" add_foreign_key "p_commercial_object_brands", "p_commercial_objectives" add_foreign_key "p_commercial_object_brands", "p_commercials" diff --git a/test/fixtures/p_article_serial_nums.yml b/test/fixtures/p_article_serial_nums.yml new file mode 100644 index 0000000..b464109 --- /dev/null +++ b/test/fixtures/p_article_serial_nums.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + p_article: one + p_serial_num_type: one + p_serial_num_value: one + +two: + p_article: two + p_serial_num_type: two + p_serial_num_value: two diff --git a/test/models/p_article_serial_num_test.rb b/test/models/p_article_serial_num_test.rb new file mode 100644 index 0000000..046c2fb --- /dev/null +++ b/test/models/p_article_serial_num_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PArticleSerialNumTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From fd0801b23d5a982bd7afc7a0fc720ef90cca8f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 26 Aug 2021 17:01:28 +0200 Subject: [PATCH 008/121] rename type (reserved) --- ...45816_rename_column_type_by_name_in_p_serial_num_types.rb | 5 +++++ db/schema.rb | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20210826145816_rename_column_type_by_name_in_p_serial_num_types.rb diff --git a/db/migrate/20210826145816_rename_column_type_by_name_in_p_serial_num_types.rb b/db/migrate/20210826145816_rename_column_type_by_name_in_p_serial_num_types.rb new file mode 100644 index 0000000..2fe6872 --- /dev/null +++ b/db/migrate/20210826145816_rename_column_type_by_name_in_p_serial_num_types.rb @@ -0,0 +1,5 @@ +class RenameColumnTypeByNameInPSerialNumTypes < ActiveRecord::Migration[6.0] + def change + rename_column :p_serial_num_types, :type, :name + end +end diff --git a/db/schema.rb b/db/schema.rb index 53e2114..8d9270f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_26_140648) do +ActiveRecord::Schema.define(version: 2021_08_26_145816) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1878,7 +1878,7 @@ ActiveRecord::Schema.define(version: 2021_08_26_140648) do end create_table "p_serial_num_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "type" + t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end From 9db1d17d9a34bf30073c832dd71e7032531f449a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 26 Aug 2021 17:55:49 +0200 Subject: [PATCH 009/121] serial num sorting + form --- .../admin/p_article_serial_nums_controller.rb | 2 +- .../admin/p_articles_controller.rb | 2 +- app/controllers/application_controller.rb | 2 ++ app/models/p_article.rb | 15 +++++++++++ app/models/p_article_serial_num.rb | 14 +++++++++- app/models/p_product.rb | 3 +-- app/models/p_product_ref.rb | 3 +++ app/models/p_serial_num_type.rb | 1 + app/models/p_serial_num_value.rb | 1 + .../p_article_serial_nums/_form.html.haml | 10 ++++--- .../_p_article_serial_num.html.haml | 26 +++++++++++++++++-- app/views/admin/p_articles/_form.html.haml | 4 +-- .../admin/p_articles/_p_article.html.haml | 25 +++++++++++++++++- .../admin/p_serial_num_values/_form.html.haml | 14 +++++----- 14 files changed, 101 insertions(+), 21 deletions(-) diff --git a/app/controllers/admin/p_article_serial_nums_controller.rb b/app/controllers/admin/p_article_serial_nums_controller.rb index 000d7cb..069ade6 100644 --- a/app/controllers/admin/p_article_serial_nums_controller.rb +++ b/app/controllers/admin/p_article_serial_nums_controller.rb @@ -33,7 +33,7 @@ class Admin::PArticleSerialNumsController < ApplicationController def new @p_article_serial_num = PArticleSerialNum.new - + @p_article_serial_num.build_p_serial_num_value end def edit diff --git a/app/controllers/admin/p_articles_controller.rb b/app/controllers/admin/p_articles_controller.rb index 62a2b86..03af6b9 100644 --- a/app/controllers/admin/p_articles_controller.rb +++ b/app/controllers/admin/p_articles_controller.rb @@ -33,7 +33,7 @@ class Admin::PArticlesController < ApplicationController def new @p_article = PArticle.new - + @p_article.build_p_product_ref end def edit diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f693d7e..6c5880a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -65,6 +65,7 @@ class ApplicationController < ActionController::Base if current_admin.has_permission?("products") set_sub_menu :stocks, :p_products, "Produits", admin_p_products_path set_sub_menu :stocks, :p_product_refs, "Références", admin_p_product_refs_path + set_sub_menu :stocks, :p_articles, "Articles", admin_p_articles_path set_sub_menu :stocks, :promos_p_products, "Offres spots", promos_admin_p_products_path end @@ -97,6 +98,7 @@ class ApplicationController < ActionController::Base if current_admin.has_permission?("boutique") set_sub_menu :stocks, :p_product_colors, "Couleurs" + set_sub_menu :stocks, :p_article_serial_nums, "Numero série" set_sub_menu :stocks, :p_product_powers, "Types de chargeurs" set_sub_menu :stocks, :p_product_zones, "Zones produits" diff --git a/app/models/p_article.rb b/app/models/p_article.rb index 325db1a..d2825e3 100644 --- a/app/models/p_article.rb +++ b/app/models/p_article.rb @@ -1,3 +1,18 @@ class PArticle < ApplicationRecord belongs_to :p_product_ref + has_one :p_product, through: :p_product_ref + belongs_to :p_product_color + has_many :p_article_serial_nums, dependent: :destroy + # accepts_nested_attributes_for :p_article_serial_nums + validates_presence_of :p_product_ref + + + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :p_product_ref_code => {:name => "Code ref", :reorder => true}, + :p_product_ref => {:name => "Désignation", :reorder => true}, + :color => {:name => "Couleur"}, + :p_article_serial_nums => {:name => "N° identifiants"}, + :actions => {:name => "Actions", :reorder => false}, + } end diff --git a/app/models/p_article_serial_num.rb b/app/models/p_article_serial_num.rb index c4c2da1..aae27cd 100644 --- a/app/models/p_article_serial_num.rb +++ b/app/models/p_article_serial_num.rb @@ -1,5 +1,17 @@ class PArticleSerialNum < ApplicationRecord belongs_to :p_article belongs_to :p_serial_num_type - belongs_to :p_serial_num_value + belongs_to :p_serial_num_value, inverse_of: :p_article_serial_nums + accepts_nested_attributes_for :p_serial_num_value + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :p_article => {:name => "Article", :reorder => true}, + :p_article_id => {:name => "Article ID", :reorder => true}, + :p_serial_num_type => {:name => "Type", :reorder => true}, + :p_serial_num_value => {:name => "N°", :reorder => true}, + + :actions => {:name => "Actions", :reorder => true} + + } end diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 1d77cd4..12a0795 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -5,8 +5,6 @@ class PProduct < ApplicationRecord has_many :p_product_refs, :dependent => :destroy accepts_nested_attributes_for :p_product_refs, allow_destroy: true - - has_many :p_product_ingredients, :dependent => :destroy accepts_nested_attributes_for :p_product_ingredients, allow_destroy: true @@ -17,6 +15,7 @@ class PProduct < ApplicationRecord has_many :p_product_nutris, :dependent => :destroy accepts_nested_attributes_for :p_product_nutris, allow_destroy: true + has_many :p_articles, through: :p_product_refs has_many :p_product_images diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index ae959f6..12da04b 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -9,6 +9,9 @@ class PProductRef < ApplicationRecord has_many :p_product_ref_price_histories belongs_to :p_product_color + has_many :p_articles + has_many :p_article_serial_nums, through: :p_articles + accepts_nested_attributes_for :p_article_serial_nums, allow_destroy: true #validates :ct_price_ht, :presence => true diff --git a/app/models/p_serial_num_type.rb b/app/models/p_serial_num_type.rb index 62c20f6..83f5ce7 100644 --- a/app/models/p_serial_num_type.rb +++ b/app/models/p_serial_num_type.rb @@ -1,2 +1,3 @@ class PSerialNumType < ApplicationRecord + has_many :p_article_serial_nums end diff --git a/app/models/p_serial_num_value.rb b/app/models/p_serial_num_value.rb index 735a10d..12a74bd 100644 --- a/app/models/p_serial_num_value.rb +++ b/app/models/p_serial_num_value.rb @@ -1,2 +1,3 @@ class PSerialNumValue < ApplicationRecord + has_many :p_article_serial_nums, inverse_of: :p_serial_num_value end diff --git a/app/views/admin/p_article_serial_nums/_form.html.haml b/app/views/admin/p_article_serial_nums/_form.html.haml index 88c40df..caad0f5 100644 --- a/app/views/admin/p_article_serial_nums/_form.html.haml +++ b/app/views/admin/p_article_serial_nums/_form.html.haml @@ -2,13 +2,15 @@ .content =f.inputs do - = f.input :p_article, :label => f.object.label_for(:p_article) - = f.input :p_serial_num_type, :label => f.object.label_for(:p_serial_num_type) - = f.input :p_serial_num_value, :label => f.object.label_for(:p_serial_num_value) + = f.input :p_article, as: :select, collection: PArticle.pluck(:id) ,:label => f.object.label_for(:p_article) + = f.input :p_serial_num_type, :label => f.object.label_for(:p_serial_num_type) + = f.semantic_fields_for :p_serial_num_value do | form | + + =render :partial => "admin/p_serial_num_values/form", :locals => {:f => form} .actions=f.submit "sauvegarder", :class => "btn btn-primary" - \ No newline at end of file + diff --git a/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml b/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml index b6e652b..59de1cd 100644 --- a/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml +++ b/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml @@ -1,6 +1,28 @@ %tr#p_article_serial_num_row{:id => p_article_serial_num.id} -tr = {} - + + -tr[:p_article_id] = capture do + %td + = p_article_serial_num.p_article.id + + -tr[:p_article] = capture do + %td + = p_article_serial_num.p_article.p_product.name + \- + = p_article_serial_num.p_article.p_product_ref.ct_sub_name + \- + = p_article_serial_num.p_article.p_product_ref.p_product_color.name + + + -tr[:p_serial_num_type] = capture do + %td + = p_article_serial_num.p_serial_num_type.name + + -tr[:p_serial_num_value] = capture do + %td + = p_article_serial_num.p_serial_num_value.value + + -tr[:actions] = capture do %td.actions = link_to i(:"trash-o"), [:admin, p_article_serial_num], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true @@ -13,4 +35,4 @@ - \ No newline at end of file + diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml index 6561210..8ab680b 100644 --- a/app/views/admin/p_articles/_form.html.haml +++ b/app/views/admin/p_articles/_form.html.haml @@ -2,11 +2,11 @@ .content =f.inputs do - = f.input :p_product_ref, :label => f.object.label_for(:p_product_ref) + = f.input :p_product_ref, as: :select, collection: PProductRef.all, :label => f.object.label_for(:p_product_ref) .actions=f.submit "sauvegarder", :class => "btn btn-primary" - \ No newline at end of file + diff --git a/app/views/admin/p_articles/_p_article.html.haml b/app/views/admin/p_articles/_p_article.html.haml index 171a403..13e29ca 100644 --- a/app/views/admin/p_articles/_p_article.html.haml +++ b/app/views/admin/p_articles/_p_article.html.haml @@ -1,6 +1,29 @@ %tr#p_article_row{:id => p_article.id} -tr = {} + -tr[:p_product_ref_code] = capture do + %td + = p_article.p_product_ref.code + + + -tr[:color] = capture do + %td + = p_article.p_product_ref.p_product_color.color + + -tr[:p_product_ref] = capture do + %td + = p_article.p_product_ref.p_product.name + \- + = p_article.p_product_ref.ct_sub_name + \- + = p_article.p_product_ref.p_product_color.name + + -tr[:p_article_serial_nums] = capture do + %td + - p_article.p_article_serial_nums.each do |sn| + = sn.p_serial_num_type.name + " : " + sn.p_serial_num_value.value + + -tr[:actions] = capture do %td.actions = link_to i(:"trash-o"), [:admin, p_article], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true @@ -13,4 +36,4 @@ - \ No newline at end of file + diff --git a/app/views/admin/p_serial_num_values/_form.html.haml b/app/views/admin/p_serial_num_values/_form.html.haml index 7ad0960..1872e5e 100644 --- a/app/views/admin/p_serial_num_values/_form.html.haml +++ b/app/views/admin/p_serial_num_values/_form.html.haml @@ -1,12 +1,12 @@ -=semantic_form_for [:admin, @p_serial_num_value], :remote => true do |f| +/ =semantic_form_for [:admin, @p_serial_num_value], :remote => true do |f| + + +=f.inputs do + = f.input :value, :label => "Numéro" - .content - =f.inputs do - = f.input :value, :label => f.object.label_for(:value) - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" - \ No newline at end of file + / .actions=f.submit "sauvegarder", :class => "btn btn-primary" + From dfdd4439986144767864b92092f36c64fbc83f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 09:46:02 +0200 Subject: [PATCH 010/121] generate p_spec_type --- .../admin/p_spec_types_controller.rb | 76 +++++++++++++++++++ app/models/p_spec_type.rb | 2 + app/views/admin/p_spec_types/_form.html.haml | 12 +++ .../admin/p_spec_types/_p_spec_type.html.haml | 16 ++++ app/views/admin/p_spec_types/create.js.erb | 2 + app/views/admin/p_spec_types/destroy.js.erb | 1 + app/views/admin/p_spec_types/edit.js.erb | 1 + app/views/admin/p_spec_types/index.html.haml | 16 ++++ app/views/admin/p_spec_types/new.js.erb | 1 + app/views/admin/p_spec_types/show.html.haml | 10 +++ app/views/admin/p_spec_types/update.js.erb | 2 + config/routes.rb | 11 +++ .../20210827074532_create_p_spec_types.rb | 9 +++ db/schema.rb | 8 +- test/fixtures/p_spec_types.yml | 7 ++ test/models/p_spec_type_test.rb | 7 ++ 16 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/p_spec_types_controller.rb create mode 100644 app/models/p_spec_type.rb create mode 100644 app/views/admin/p_spec_types/_form.html.haml create mode 100644 app/views/admin/p_spec_types/_p_spec_type.html.haml create mode 100644 app/views/admin/p_spec_types/create.js.erb create mode 100644 app/views/admin/p_spec_types/destroy.js.erb create mode 100644 app/views/admin/p_spec_types/edit.js.erb create mode 100644 app/views/admin/p_spec_types/index.html.haml create mode 100644 app/views/admin/p_spec_types/new.js.erb create mode 100644 app/views/admin/p_spec_types/show.html.haml create mode 100644 app/views/admin/p_spec_types/update.js.erb create mode 100644 db/migrate/20210827074532_create_p_spec_types.rb create mode 100644 test/fixtures/p_spec_types.yml create mode 100644 test/models/p_spec_type_test.rb diff --git a/app/controllers/admin/p_spec_types_controller.rb b/app/controllers/admin/p_spec_types_controller.rb new file mode 100644 index 0000000..5d3ed6b --- /dev/null +++ b/app/controllers/admin/p_spec_types_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PSpecTypesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_spec_types = PSpecType.all + + @p_spec_types = sort_by_sorting(@p_spec_types, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_spec_types = @p_spec_types.page(page).per(per_page) + + } + end + end + + def show + @p_spec_type = PSpecType.find(params[:id]) + + end + + def new + @p_spec_type = PSpecType.new + + end + + def edit + @p_spec_type = PSpecType.find(params[:id]) + + end + + def create + @p_spec_type = PSpecType.new(params.require(:p_spec_type).permit!) + + if @p_spec_type.save + + else + render action: "new" + + end + + end + + + def update + @p_spec_type = PSpecType.find(params[:id]) + + + if @p_spec_type.update_attributes(params.require(:p_spec_type).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_spec_type = PSpecType.find(params[:id]) + @p_spec_type.destroy + + end +end diff --git a/app/models/p_spec_type.rb b/app/models/p_spec_type.rb new file mode 100644 index 0000000..30aea9e --- /dev/null +++ b/app/models/p_spec_type.rb @@ -0,0 +1,2 @@ +class PSpecType < ApplicationRecord +end diff --git a/app/views/admin/p_spec_types/_form.html.haml b/app/views/admin/p_spec_types/_form.html.haml new file mode 100644 index 0000000..0a8acc2 --- /dev/null +++ b/app/views/admin/p_spec_types/_form.html.haml @@ -0,0 +1,12 @@ +=semantic_form_for [:admin, @p_spec_type], :remote => true do |f| + + .content + =f.inputs do + = f.input :type, :label => f.object.label_for(:type) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_spec_types/_p_spec_type.html.haml b/app/views/admin/p_spec_types/_p_spec_type.html.haml new file mode 100644 index 0000000..fd475e3 --- /dev/null +++ b/app/views/admin/p_spec_types/_p_spec_type.html.haml @@ -0,0 +1,16 @@ +%tr#p_spec_type_row{:id => p_spec_type.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_spec_type], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_spec_type_path(p_spec_type), :remote => true + = link_to i(:eye), admin_p_spec_type_path(p_spec_type), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_spec_type} + + + + \ No newline at end of file diff --git a/app/views/admin/p_spec_types/create.js.erb b/app/views/admin/p_spec_types/create.js.erb new file mode 100644 index 0000000..e9f7774 --- /dev/null +++ b/app/views/admin/p_spec_types/create.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_types_rows').prepend("<%= escape_javascript(render(@p_spec_type))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/destroy.js.erb b/app/views/admin/p_spec_types/destroy.js.erb new file mode 100644 index 0000000..e97e73c --- /dev/null +++ b/app/views/admin/p_spec_types/destroy.js.erb @@ -0,0 +1 @@ +$('#p_spec_type_row_<%= @p_spec_type.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/edit.js.erb b/app/views/admin/p_spec_types/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_types/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/index.html.haml b/app/views/admin/p_spec_types/index.html.haml new file mode 100644 index 0000000..46d02ec --- /dev/null +++ b/app/views/admin/p_spec_types/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PSpecType.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_spec_types} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_spec_types} + + + diff --git a/app/views/admin/p_spec_types/new.js.erb b/app/views/admin/p_spec_types/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_types/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_spec_types/show.html.haml b/app/views/admin/p_spec_types/show.html.haml new file mode 100644 index 0000000..6005a84 --- /dev/null +++ b/app/views/admin/p_spec_types/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_spec_type \ No newline at end of file diff --git a/app/views/admin/p_spec_types/update.js.erb b/app/views/admin/p_spec_types/update.js.erb new file mode 100644 index 0000000..2f952cc --- /dev/null +++ b/app/views/admin/p_spec_types/update.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_type_row_<%= @p_spec_type.id %>').replaceWith("<%= escape_javascript(render(@p_spec_type))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 00b564d..59c5ff0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_spec_types do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_article_serial_nums do member do diff --git a/db/migrate/20210827074532_create_p_spec_types.rb b/db/migrate/20210827074532_create_p_spec_types.rb new file mode 100644 index 0000000..ab9699c --- /dev/null +++ b/db/migrate/20210827074532_create_p_spec_types.rb @@ -0,0 +1,9 @@ +class CreatePSpecTypes < ActiveRecord::Migration[6.0] + def change + create_table :p_spec_types do |t| + t.string :type + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8d9270f..2ebe559 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_26_145816) do +ActiveRecord::Schema.define(version: 2021_08_27_074532) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1978,6 +1978,12 @@ ActiveRecord::Schema.define(version: 2021_08_26_145816) do t.index ["p_fournisseur_id"], name: "index_p_ship_bills_on_p_fournisseur_id" end + create_table "p_spec_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.string "type" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "p_tank_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.datetime "ok_at" t.boolean "enabled", default: false diff --git a/test/fixtures/p_spec_types.yml b/test/fixtures/p_spec_types.yml new file mode 100644 index 0000000..860f9b8 --- /dev/null +++ b/test/fixtures/p_spec_types.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + type: + +two: + type: diff --git a/test/models/p_spec_type_test.rb b/test/models/p_spec_type_test.rb new file mode 100644 index 0000000..97553a9 --- /dev/null +++ b/test/models/p_spec_type_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PSpecTypeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 374c92b9a4d1d3e62ca214452996fdc15baabcfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 09:46:35 +0200 Subject: [PATCH 011/121] generate p_spec_value --- .../admin/p_spec_values_controller.rb | 76 +++++++++++++++++++ app/models/p_spec_value.rb | 2 + app/views/admin/p_spec_values/_form.html.haml | 13 ++++ .../p_spec_values/_p_spec_value.html.haml | 16 ++++ app/views/admin/p_spec_values/create.js.erb | 2 + app/views/admin/p_spec_values/destroy.js.erb | 1 + app/views/admin/p_spec_values/edit.js.erb | 1 + app/views/admin/p_spec_values/index.html.haml | 16 ++++ app/views/admin/p_spec_values/new.js.erb | 1 + app/views/admin/p_spec_values/show.html.haml | 10 +++ app/views/admin/p_spec_values/update.js.erb | 2 + config/routes.rb | 11 +++ .../20210827074615_create_p_spec_values.rb | 10 +++ db/schema.rb | 9 ++- test/fixtures/p_spec_values.yml | 9 +++ test/models/p_spec_value_test.rb | 7 ++ 16 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/p_spec_values_controller.rb create mode 100644 app/models/p_spec_value.rb create mode 100644 app/views/admin/p_spec_values/_form.html.haml create mode 100644 app/views/admin/p_spec_values/_p_spec_value.html.haml create mode 100644 app/views/admin/p_spec_values/create.js.erb create mode 100644 app/views/admin/p_spec_values/destroy.js.erb create mode 100644 app/views/admin/p_spec_values/edit.js.erb create mode 100644 app/views/admin/p_spec_values/index.html.haml create mode 100644 app/views/admin/p_spec_values/new.js.erb create mode 100644 app/views/admin/p_spec_values/show.html.haml create mode 100644 app/views/admin/p_spec_values/update.js.erb create mode 100644 db/migrate/20210827074615_create_p_spec_values.rb create mode 100644 test/fixtures/p_spec_values.yml create mode 100644 test/models/p_spec_value_test.rb diff --git a/app/controllers/admin/p_spec_values_controller.rb b/app/controllers/admin/p_spec_values_controller.rb new file mode 100644 index 0000000..2dfd736 --- /dev/null +++ b/app/controllers/admin/p_spec_values_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PSpecValuesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_spec_values = PSpecValue.all + + @p_spec_values = sort_by_sorting(@p_spec_values, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_spec_values = @p_spec_values.page(page).per(per_page) + + } + end + end + + def show + @p_spec_value = PSpecValue.find(params[:id]) + + end + + def new + @p_spec_value = PSpecValue.new + + end + + def edit + @p_spec_value = PSpecValue.find(params[:id]) + + end + + def create + @p_spec_value = PSpecValue.new(params.require(:p_spec_value).permit!) + + if @p_spec_value.save + + else + render action: "new" + + end + + end + + + def update + @p_spec_value = PSpecValue.find(params[:id]) + + + if @p_spec_value.update_attributes(params.require(:p_spec_value).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_spec_value = PSpecValue.find(params[:id]) + @p_spec_value.destroy + + end +end diff --git a/app/models/p_spec_value.rb b/app/models/p_spec_value.rb new file mode 100644 index 0000000..17c7684 --- /dev/null +++ b/app/models/p_spec_value.rb @@ -0,0 +1,2 @@ +class PSpecValue < ApplicationRecord +end diff --git a/app/views/admin/p_spec_values/_form.html.haml b/app/views/admin/p_spec_values/_form.html.haml new file mode 100644 index 0000000..6d0339f --- /dev/null +++ b/app/views/admin/p_spec_values/_form.html.haml @@ -0,0 +1,13 @@ +=semantic_form_for [:admin, @p_spec_value], :remote => true do |f| + + .content + =f.inputs do + = f.input :value, :label => f.object.label_for(:value) + = f.input :unit, :label => f.object.label_for(:unit) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_spec_values/_p_spec_value.html.haml b/app/views/admin/p_spec_values/_p_spec_value.html.haml new file mode 100644 index 0000000..64de749 --- /dev/null +++ b/app/views/admin/p_spec_values/_p_spec_value.html.haml @@ -0,0 +1,16 @@ +%tr#p_spec_value_row{:id => p_spec_value.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_spec_value], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_spec_value_path(p_spec_value), :remote => true + = link_to i(:eye), admin_p_spec_value_path(p_spec_value), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_spec_value} + + + + \ No newline at end of file diff --git a/app/views/admin/p_spec_values/create.js.erb b/app/views/admin/p_spec_values/create.js.erb new file mode 100644 index 0000000..8aef8dd --- /dev/null +++ b/app/views/admin/p_spec_values/create.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_values_rows').prepend("<%= escape_javascript(render(@p_spec_value))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/destroy.js.erb b/app/views/admin/p_spec_values/destroy.js.erb new file mode 100644 index 0000000..643c933 --- /dev/null +++ b/app/views/admin/p_spec_values/destroy.js.erb @@ -0,0 +1 @@ +$('#p_spec_value_row_<%= @p_spec_value.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/edit.js.erb b/app/views/admin/p_spec_values/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_values/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/index.html.haml b/app/views/admin/p_spec_values/index.html.haml new file mode 100644 index 0000000..8f34bd1 --- /dev/null +++ b/app/views/admin/p_spec_values/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_value_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PSpecValue.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_spec_values} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_spec_values} + + + diff --git a/app/views/admin/p_spec_values/new.js.erb b/app/views/admin/p_spec_values/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_spec_values/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_spec_values/show.html.haml b/app/views/admin/p_spec_values/show.html.haml new file mode 100644 index 0000000..6414fbc --- /dev/null +++ b/app/views/admin/p_spec_values/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_spec_value \ No newline at end of file diff --git a/app/views/admin/p_spec_values/update.js.erb b/app/views/admin/p_spec_values/update.js.erb new file mode 100644 index 0000000..b7e6986 --- /dev/null +++ b/app/views/admin/p_spec_values/update.js.erb @@ -0,0 +1,2 @@ +$('#p_spec_value_row_<%= @p_spec_value.id %>').replaceWith("<%= escape_javascript(render(@p_spec_value))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 59c5ff0..b1d1e69 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_spec_values do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_spec_types do member do diff --git a/db/migrate/20210827074615_create_p_spec_values.rb b/db/migrate/20210827074615_create_p_spec_values.rb new file mode 100644 index 0000000..442275a --- /dev/null +++ b/db/migrate/20210827074615_create_p_spec_values.rb @@ -0,0 +1,10 @@ +class CreatePSpecValues < ActiveRecord::Migration[6.0] + def change + create_table :p_spec_values do |t| + t.string :value + t.string :unit + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 2ebe559..a09865a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_27_074532) do +ActiveRecord::Schema.define(version: 2021_08_27_074615) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1984,6 +1984,13 @@ ActiveRecord::Schema.define(version: 2021_08_27_074532) do t.datetime "updated_at", precision: 6, null: false end + create_table "p_spec_values", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.string "value" + t.string "unit" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "p_tank_stocks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.datetime "ok_at" t.boolean "enabled", default: false diff --git a/test/fixtures/p_spec_values.yml b/test/fixtures/p_spec_values.yml new file mode 100644 index 0000000..b54b2ea --- /dev/null +++ b/test/fixtures/p_spec_values.yml @@ -0,0 +1,9 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + value: MyString + unit: MyString + +two: + value: MyString + unit: MyString diff --git a/test/models/p_spec_value_test.rb b/test/models/p_spec_value_test.rb new file mode 100644 index 0000000..021bdc7 --- /dev/null +++ b/test/models/p_spec_value_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PSpecValueTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From b1df8ad4c5cd4218ef7141f2897a7c1a6d9c8319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 09:48:30 +0200 Subject: [PATCH 012/121] generate p_product_ref_spec --- .../admin/p_product_ref_specs_controller.rb | 76 +++++++++++++++++++ app/models/p_product_ref_spec.rb | 5 ++ .../admin/p_product_ref_specs/_form.html.haml | 14 ++++ .../_p_product_ref_spec.html.haml | 16 ++++ .../admin/p_product_ref_specs/create.js.erb | 2 + .../admin/p_product_ref_specs/destroy.js.erb | 1 + .../admin/p_product_ref_specs/edit.js.erb | 1 + .../admin/p_product_ref_specs/index.html.haml | 16 ++++ .../admin/p_product_ref_specs/new.js.erb | 1 + .../admin/p_product_ref_specs/show.html.haml | 10 +++ .../admin/p_product_ref_specs/update.js.erb | 2 + config/routes.rb | 11 +++ ...210827074812_create_p_product_ref_specs.rb | 11 +++ db/schema.rb | 16 +++- test/fixtures/p_product_ref_specs.yml | 11 +++ test/models/p_product_ref_spec_test.rb | 7 ++ 16 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/p_product_ref_specs_controller.rb create mode 100644 app/models/p_product_ref_spec.rb create mode 100644 app/views/admin/p_product_ref_specs/_form.html.haml create mode 100644 app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml create mode 100644 app/views/admin/p_product_ref_specs/create.js.erb create mode 100644 app/views/admin/p_product_ref_specs/destroy.js.erb create mode 100644 app/views/admin/p_product_ref_specs/edit.js.erb create mode 100644 app/views/admin/p_product_ref_specs/index.html.haml create mode 100644 app/views/admin/p_product_ref_specs/new.js.erb create mode 100644 app/views/admin/p_product_ref_specs/show.html.haml create mode 100644 app/views/admin/p_product_ref_specs/update.js.erb create mode 100644 db/migrate/20210827074812_create_p_product_ref_specs.rb create mode 100644 test/fixtures/p_product_ref_specs.yml create mode 100644 test/models/p_product_ref_spec_test.rb diff --git a/app/controllers/admin/p_product_ref_specs_controller.rb b/app/controllers/admin/p_product_ref_specs_controller.rb new file mode 100644 index 0000000..7522ebb --- /dev/null +++ b/app/controllers/admin/p_product_ref_specs_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PProductRefSpecsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_product_ref_specs = PProductRefSpec.all + + @p_product_ref_specs = sort_by_sorting(@p_product_ref_specs, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_product_ref_specs = @p_product_ref_specs.page(page).per(per_page) + + } + end + end + + def show + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + + end + + def new + @p_product_ref_spec = PProductRefSpec.new + + end + + def edit + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + + end + + def create + @p_product_ref_spec = PProductRefSpec.new(params.require(:p_product_ref_spec).permit!) + + if @p_product_ref_spec.save + + else + render action: "new" + + end + + end + + + def update + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + + + if @p_product_ref_spec.update_attributes(params.require(:p_product_ref_spec).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_product_ref_spec = PProductRefSpec.find(params[:id]) + @p_product_ref_spec.destroy + + end +end diff --git a/app/models/p_product_ref_spec.rb b/app/models/p_product_ref_spec.rb new file mode 100644 index 0000000..3b80fce --- /dev/null +++ b/app/models/p_product_ref_spec.rb @@ -0,0 +1,5 @@ +class PProductRefSpec < ApplicationRecord + belongs_to :p_product_ref + belongs_to :p_spec_type + belongs_to :p_spec_value +end diff --git a/app/views/admin/p_product_ref_specs/_form.html.haml b/app/views/admin/p_product_ref_specs/_form.html.haml new file mode 100644 index 0000000..8fd4851 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/_form.html.haml @@ -0,0 +1,14 @@ +=semantic_form_for [:admin, @p_product_ref_spec], :remote => true do |f| + + .content + =f.inputs do + = f.input :p_product_ref, :label => f.object.label_for(:p_product_ref) + = f.input :p_spec_type, :label => f.object.label_for(:p_spec_type) + = f.input :p_spec_value, :label => f.object.label_for(:p_spec_value) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml b/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml new file mode 100644 index 0000000..e91add0 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml @@ -0,0 +1,16 @@ +%tr#p_product_ref_spec_row{:id => p_product_ref_spec.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_product_ref_spec], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_product_ref_spec_path(p_product_ref_spec), :remote => true + = link_to i(:eye), admin_p_product_ref_spec_path(p_product_ref_spec), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_product_ref_spec} + + + + \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/create.js.erb b/app/views/admin/p_product_ref_specs/create.js.erb new file mode 100644 index 0000000..d7a17bc --- /dev/null +++ b/app/views/admin/p_product_ref_specs/create.js.erb @@ -0,0 +1,2 @@ +$('#p_product_ref_specs_rows').prepend("<%= escape_javascript(render(@p_product_ref_spec))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/destroy.js.erb b/app/views/admin/p_product_ref_specs/destroy.js.erb new file mode 100644 index 0000000..5e87c5d --- /dev/null +++ b/app/views/admin/p_product_ref_specs/destroy.js.erb @@ -0,0 +1 @@ +$('#p_product_ref_spec_row_<%= @p_product_ref_spec.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/edit.js.erb b/app/views/admin/p_product_ref_specs/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/index.html.haml b/app/views/admin/p_product_ref_specs/index.html.haml new file mode 100644 index 0000000..f486839 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_product_ref_spec_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PProductRefSpec.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_product_ref_specs} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_ref_specs} + + + diff --git a/app/views/admin/p_product_ref_specs/new.js.erb b/app/views/admin/p_product_ref_specs/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/show.html.haml b/app/views/admin/p_product_ref_specs/show.html.haml new file mode 100644 index 0000000..e56e759 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_product_ref_spec \ No newline at end of file diff --git a/app/views/admin/p_product_ref_specs/update.js.erb b/app/views/admin/p_product_ref_specs/update.js.erb new file mode 100644 index 0000000..ccaba69 --- /dev/null +++ b/app/views/admin/p_product_ref_specs/update.js.erb @@ -0,0 +1,2 @@ +$('#p_product_ref_spec_row_<%= @p_product_ref_spec.id %>').replaceWith("<%= escape_javascript(render(@p_product_ref_spec))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index b1d1e69..a585b05 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_product_ref_specs do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_spec_values do member do diff --git a/db/migrate/20210827074812_create_p_product_ref_specs.rb b/db/migrate/20210827074812_create_p_product_ref_specs.rb new file mode 100644 index 0000000..0731732 --- /dev/null +++ b/db/migrate/20210827074812_create_p_product_ref_specs.rb @@ -0,0 +1,11 @@ +class CreatePProductRefSpecs < ActiveRecord::Migration[6.0] + def change + create_table :p_product_ref_specs do |t| + t.references :p_product_ref, foreign_key: true + t.references :p_spec_type, foreign_key: true + t.references :p_spec_value, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a09865a..7edf151 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_27_074615) do +ActiveRecord::Schema.define(version: 2021_08_27_074812) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1745,6 +1745,17 @@ ActiveRecord::Schema.define(version: 2021_08_27_074615) do t.index ["p_product_ref_id"], name: "index_p_product_ref_price_histories_on_p_product_ref_id" end + create_table "p_product_ref_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.bigint "p_product_ref_id" + t.bigint "p_spec_type_id" + t.bigint "p_spec_value_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["p_product_ref_id"], name: "index_p_product_ref_specs_on_p_product_ref_id" + t.index ["p_spec_type_id"], name: "index_p_product_ref_specs_on_p_spec_type_id" + t.index ["p_spec_value_id"], name: "index_p_product_ref_specs_on_p_spec_value_id" + end + create_table "p_product_refs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "ref" t.integer "p_product_id" @@ -3126,6 +3137,9 @@ ActiveRecord::Schema.define(version: 2021_08_27_074615) do add_foreign_key "p_product_prices", "p_price_cats" add_foreign_key "p_product_prices", "p_product_refs" add_foreign_key "p_product_ref_price_histories", "p_product_refs" + add_foreign_key "p_product_ref_specs", "p_product_refs" + add_foreign_key "p_product_ref_specs", "p_spec_types" + add_foreign_key "p_product_ref_specs", "p_spec_values" add_foreign_key "p_product_utilisations", "p_products" add_foreign_key "p_product_utilisations", "p_utilisations" add_foreign_key "partition_lines", "partitions" diff --git a/test/fixtures/p_product_ref_specs.yml b/test/fixtures/p_product_ref_specs.yml new file mode 100644 index 0000000..e22eda8 --- /dev/null +++ b/test/fixtures/p_product_ref_specs.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + p_product_ref: one + p_spec_type: one + p_spec_value: one + +two: + p_product_ref: two + p_spec_type: two + p_spec_value: two diff --git a/test/models/p_product_ref_spec_test.rb b/test/models/p_product_ref_spec_test.rb new file mode 100644 index 0000000..59dbd78 --- /dev/null +++ b/test/models/p_product_ref_spec_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PProductRefSpecTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From c1d3c255ee5c2df96c23ee5e1ffbc39d776c4a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 10:29:37 +0200 Subject: [PATCH 013/121] Rename type column --- ...10827082814_rename_column_type_by_name_in_p_spec_types.rb | 5 +++++ db/schema.rb | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20210827082814_rename_column_type_by_name_in_p_spec_types.rb diff --git a/db/migrate/20210827082814_rename_column_type_by_name_in_p_spec_types.rb b/db/migrate/20210827082814_rename_column_type_by_name_in_p_spec_types.rb new file mode 100644 index 0000000..4b890e8 --- /dev/null +++ b/db/migrate/20210827082814_rename_column_type_by_name_in_p_spec_types.rb @@ -0,0 +1,5 @@ +class RenameColumnTypeByNameInPSpecTypes < ActiveRecord::Migration[6.0] + def change + rename_column :p_spec_types, :type, :name + end +end diff --git a/db/schema.rb b/db/schema.rb index 7edf151..fc2f026 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_27_074812) do +ActiveRecord::Schema.define(version: 2021_08_27_082814) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1990,7 +1990,7 @@ ActiveRecord::Schema.define(version: 2021_08_27_074812) do end create_table "p_spec_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| - t.string "type" + t.string "name" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end From bc96c5bc23abd3ec09597c581c1f63f870fc20e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 10:44:15 +0200 Subject: [PATCH 014/121] form and menu for p_spec --- .../admin/p_product_ref_specs_controller.rb | 4 +++- app/controllers/application_controller.rb | 1 + app/models/p_product_ref.rb | 8 +++++++- app/models/p_product_ref_spec.rb | 13 +++++++++++++ app/models/p_spec_type.rb | 3 +++ app/models/p_spec_value.rb | 3 +++ .../admin/p_product_ref_specs/_form.html.haml | 11 +++++++---- .../_p_product_ref_spec.html.haml | 19 +++++++++++++++++-- app/views/admin/p_spec_types/_form.html.haml | 14 ++------------ app/views/admin/p_spec_values/_form.html.haml | 16 +++------------- 10 files changed, 59 insertions(+), 33 deletions(-) diff --git a/app/controllers/admin/p_product_ref_specs_controller.rb b/app/controllers/admin/p_product_ref_specs_controller.rb index 7522ebb..9935030 100644 --- a/app/controllers/admin/p_product_ref_specs_controller.rb +++ b/app/controllers/admin/p_product_ref_specs_controller.rb @@ -33,7 +33,9 @@ class Admin::PProductRefSpecsController < ApplicationController def new @p_product_ref_spec = PProductRefSpec.new - + @p_product_ref_spec.build_p_spec_type + @p_product_ref_spec.build_p_spec_value + end def edit diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6c5880a..0812d32 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -99,6 +99,7 @@ class ApplicationController < ActionController::Base if current_admin.has_permission?("boutique") set_sub_menu :stocks, :p_product_colors, "Couleurs" set_sub_menu :stocks, :p_article_serial_nums, "Numero série" + set_sub_menu :stocks, :p_product_ref_specs, "Specs" set_sub_menu :stocks, :p_product_powers, "Types de chargeurs" set_sub_menu :stocks, :p_product_zones, "Zones produits" diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 12da04b..07926e6 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -9,10 +9,14 @@ class PProductRef < ApplicationRecord has_many :p_product_ref_price_histories belongs_to :p_product_color + has_many :p_articles has_many :p_article_serial_nums, through: :p_articles accepts_nested_attributes_for :p_article_serial_nums, allow_destroy: true + has_many :p_product_ref_specs + accepts_nested_attributes_for :p_product_ref_specs, allow_destroy: true + #validates :ct_price_ht, :presence => true @@ -67,7 +71,9 @@ class PProductRef < ApplicationRecord def ca_name - self.p_product.name if self.p_product + if self.p_product + self.p_product.name + " - " + self.ct_sub_name + end end def ca_code diff --git a/app/models/p_product_ref_spec.rb b/app/models/p_product_ref_spec.rb index 3b80fce..a036951 100644 --- a/app/models/p_product_ref_spec.rb +++ b/app/models/p_product_ref_spec.rb @@ -2,4 +2,17 @@ class PProductRefSpec < ApplicationRecord belongs_to :p_product_ref belongs_to :p_spec_type belongs_to :p_spec_value + + accepts_nested_attributes_for :p_spec_type, :p_spec_value + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :p_product_ref => {:name => "Référence produit", :reorder => true}, + :p_product_ref_id => {:name => "ID Ref produit", :reorder => true}, + :p_spec_type => {:name => "Type", :reorder => true}, + :p_spec_value => {:name => "Valeur", :reorder => true}, + + :actions => {:name => "Actions", :reorder => true} + + } end diff --git a/app/models/p_spec_type.rb b/app/models/p_spec_type.rb index 30aea9e..a656aa6 100644 --- a/app/models/p_spec_type.rb +++ b/app/models/p_spec_type.rb @@ -1,2 +1,5 @@ class PSpecType < ApplicationRecord + has_many :p_product_ref_specs + + TYPES = ["Ram", "Stockage"] end diff --git a/app/models/p_spec_value.rb b/app/models/p_spec_value.rb index 17c7684..a44875c 100644 --- a/app/models/p_spec_value.rb +++ b/app/models/p_spec_value.rb @@ -1,2 +1,5 @@ class PSpecValue < ApplicationRecord + has_many :p_product_ref_specs + + UNITS = ["Go", "Mo"] end diff --git a/app/views/admin/p_product_ref_specs/_form.html.haml b/app/views/admin/p_product_ref_specs/_form.html.haml index 8fd4851..aed2719 100644 --- a/app/views/admin/p_product_ref_specs/_form.html.haml +++ b/app/views/admin/p_product_ref_specs/_form.html.haml @@ -2,13 +2,16 @@ .content =f.inputs do - = f.input :p_product_ref, :label => f.object.label_for(:p_product_ref) - = f.input :p_spec_type, :label => f.object.label_for(:p_spec_type) - = f.input :p_spec_value, :label => f.object.label_for(:p_spec_value) + = f.input :p_product_ref, as: :select, collection: PProductRef.pluck(:cc_name, :id) ,:label => f.object.label_for(:p_product_ref) + = f.semantic_fields_for :p_spec_type do | form | + =render :partial => "admin/p_spec_types/form", :locals => {:f => form} + = f.semantic_fields_for :p_spec_value do | form | + =render :partial => "admin/p_spec_values/form", :locals => {:f => form} + / = f.input :p_spec_value, :label => f.object.label_for(:p_spec_value) .actions=f.submit "sauvegarder", :class => "btn btn-primary" - \ No newline at end of file + diff --git a/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml b/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml index e91add0..b696059 100644 --- a/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml +++ b/app/views/admin/p_product_ref_specs/_p_product_ref_spec.html.haml @@ -1,6 +1,21 @@ %tr#p_product_ref_spec_row{:id => p_product_ref_spec.id} -tr = {} - + -tr[:p_product_ref] = capture do + %td + = p_product_ref_spec.p_product_ref.cc_name + + -tr[:p_product_ref_id] = capture do + %td + = p_product_ref_spec.p_product_ref.id + + -tr[:p_spec_type] = capture do + %td + = p_product_ref_spec.p_spec_type.name + -tr[:p_spec_value] = capture do + %td + = p_product_ref_spec.p_spec_value.value + = p_product_ref_spec.p_spec_value.unit + -tr[:actions] = capture do %td.actions = link_to i(:"trash-o"), [:admin, p_product_ref_spec], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true @@ -13,4 +28,4 @@ - \ No newline at end of file + diff --git a/app/views/admin/p_spec_types/_form.html.haml b/app/views/admin/p_spec_types/_form.html.haml index 0a8acc2..ab615d2 100644 --- a/app/views/admin/p_spec_types/_form.html.haml +++ b/app/views/admin/p_spec_types/_form.html.haml @@ -1,12 +1,2 @@ -=semantic_form_for [:admin, @p_spec_type], :remote => true do |f| - - .content - =f.inputs do - = f.input :type, :label => f.object.label_for(:type) - - - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" - \ No newline at end of file +=f.inputs do + = f.input :name, :label => "Type", as: :select, collection: PSpecType::TYPES diff --git a/app/views/admin/p_spec_values/_form.html.haml b/app/views/admin/p_spec_values/_form.html.haml index 6d0339f..d44dd69 100644 --- a/app/views/admin/p_spec_values/_form.html.haml +++ b/app/views/admin/p_spec_values/_form.html.haml @@ -1,13 +1,3 @@ -=semantic_form_for [:admin, @p_spec_value], :remote => true do |f| - - .content - =f.inputs do - = f.input :value, :label => f.object.label_for(:value) - = f.input :unit, :label => f.object.label_for(:unit) - - - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" - \ No newline at end of file +=f.inputs do + = f.input :value, :label => "Valeur" + = f.input :unit, :label => "Unité", as: :select, collection: PSpecValue::UNITS From 11cf27c1cc883bc13799891698b533b6681a40c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 15:52:47 +0200 Subject: [PATCH 015/121] edit menu --- app/controllers/application_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0812d32..8ff974b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -66,13 +66,13 @@ class ApplicationController < ActionController::Base set_sub_menu :stocks, :p_products, "Produits", admin_p_products_path set_sub_menu :stocks, :p_product_refs, "Références", admin_p_product_refs_path set_sub_menu :stocks, :p_articles, "Articles", admin_p_articles_path - set_sub_menu :stocks, :promos_p_products, "Offres spots", promos_admin_p_products_path + # set_sub_menu :stocks, :promos_p_products, "Offres spots", promos_admin_p_products_path end if current_admin.has_permission?("product-cats") set_sub_menu :stocks, :p_product_cats, "Catégories produits", admin_p_product_cats_path - set_sub_menu :stocks, :p_product_sub_cats, "Sous catégories produits", admin_p_product_sub_cats_path + # set_sub_menu :stocks, :p_product_sub_cats, "Sous catégories produits", admin_p_product_sub_cats_path end @@ -99,6 +99,7 @@ class ApplicationController < ActionController::Base if current_admin.has_permission?("boutique") set_sub_menu :stocks, :p_product_colors, "Couleurs" set_sub_menu :stocks, :p_article_serial_nums, "Numero série" + set_sub_menu :stocks, :p_serial_num_types, "Types de Numero série" set_sub_menu :stocks, :p_product_ref_specs, "Specs" set_sub_menu :stocks, :p_product_powers, "Types de chargeurs" set_sub_menu :stocks, :p_product_zones, "Zones produits" From 181089058cb92b209c69d7cfa9ece4ccec680c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 15:53:37 +0200 Subject: [PATCH 016/121] p_spec & p_serial_num form and table --- .../admin/p_articles_controller.rb | 5 ++- .../admin/p_products_controller.rb | 7 +++- app/models/p_article.rb | 5 ++- app/models/p_product.rb | 7 ++++ app/models/p_serial_num_type.rb | 6 +++ .../p_article_serial_nums/_form.html.haml | 26 ++++++------ app/views/admin/p_articles/_form.html.haml | 5 ++- .../admin/p_product_ref_specs/_form.html.haml | 42 ++++++++++++------- .../admin/p_product_refs/_form.html.haml | 25 +++++++---- .../admin/p_serial_num_types/_form.html.haml | 4 +- app/views/admin/p_spec_values/_form.html.haml | 7 +++- 11 files changed, 94 insertions(+), 45 deletions(-) diff --git a/app/controllers/admin/p_articles_controller.rb b/app/controllers/admin/p_articles_controller.rb index 03af6b9..006eeda 100644 --- a/app/controllers/admin/p_articles_controller.rb +++ b/app/controllers/admin/p_articles_controller.rb @@ -33,7 +33,10 @@ class Admin::PArticlesController < ApplicationController def new @p_article = PArticle.new - @p_article.build_p_product_ref + @p_article_serial_nums = @p_article.p_article_serial_nums.build + + @p_serial_num_type = @p_article_serial_nums.build_p_serial_num_type + @p_serial_num_value = @p_article_serial_nums.build_p_serial_num_value end def edit diff --git a/app/controllers/admin/p_products_controller.rb b/app/controllers/admin/p_products_controller.rb index a0ae7f9..9cb4915 100644 --- a/app/controllers/admin/p_products_controller.rb +++ b/app/controllers/admin/p_products_controller.rb @@ -73,8 +73,11 @@ class Admin::PProductsController < ApplicationController @p_product = PProduct.new #(:p_customer_cat_ids => [3]) - @p_product.p_product_refs << PProductRef.new - + # @p_product.p_product_refs << PProductRef.new + @p_product_refs = @p_product.p_product_refs.build + @p_product_ref_specs = @p_product_refs.p_product_ref_specs.build + @p_spec_type = @p_product_ref_specs.build_p_spec_type + @p_spec_value = @p_product_ref_specs.build_p_spec_value end diff --git a/app/models/p_article.rb b/app/models/p_article.rb index d2825e3..3ff569b 100644 --- a/app/models/p_article.rb +++ b/app/models/p_article.rb @@ -3,9 +3,10 @@ class PArticle < ApplicationRecord has_one :p_product, through: :p_product_ref belongs_to :p_product_color has_many :p_article_serial_nums, dependent: :destroy - # accepts_nested_attributes_for :p_article_serial_nums + accepts_nested_attributes_for :p_article_serial_nums validates_presence_of :p_product_ref - + # has_many :p_product_ref_specs, through: :p_product_ref + # accepts_nested_attributes_for :p_product_ref_specs acts_as_sorting :fields => { :id => {:name => "id", :reorder => true}, diff --git a/app/models/p_product.rb b/app/models/p_product.rb index 12a0795..893a83c 100644 --- a/app/models/p_product.rb +++ b/app/models/p_product.rb @@ -17,6 +17,13 @@ class PProduct < ApplicationRecord has_many :p_articles, through: :p_product_refs + # has_many :p_product_ref_specs, through: :p_product_refs + # accepts_nested_attributes_for :p_product_ref_specs + # # has_many :p_spec_types, through: :p_product_ref_specs + # has_many :p_spec_values, through: :p_product_ref_specs + # accepts_nested_attributes_for :p_spec_types, allow_destroy: true + # accepts_nested_attributes_for :p_spec_values, allow_destroy: true + has_many :p_product_images diff --git a/app/models/p_serial_num_type.rb b/app/models/p_serial_num_type.rb index 83f5ce7..596d817 100644 --- a/app/models/p_serial_num_type.rb +++ b/app/models/p_serial_num_type.rb @@ -1,3 +1,9 @@ class PSerialNumType < ApplicationRecord has_many :p_article_serial_nums + + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :name => {:name => "Type", :reorder => true}, + :actions => {:name => "Actions", :reorder => false}, + } end diff --git a/app/views/admin/p_article_serial_nums/_form.html.haml b/app/views/admin/p_article_serial_nums/_form.html.haml index caad0f5..34d893a 100644 --- a/app/views/admin/p_article_serial_nums/_form.html.haml +++ b/app/views/admin/p_article_serial_nums/_form.html.haml @@ -1,16 +1,18 @@ -=semantic_form_for [:admin, @p_article_serial_num], :remote => true do |f| +- if params[:controller] == "admin/p_article_serial_nums" + =semantic_form_for [:admin, @p_article_serial_num], :remote => true do |f| - .content + .content + =f.inputs do + = f.input :p_article, as: :select, collection: PArticle.pluck(:id) ,:label => f.object.label_for(:p_article_id) + = f.input :p_serial_num_type, :label => f.object.label_for(:p_serial_num_type) + = f.semantic_fields_for :p_serial_num_value do | form | + =render :partial => "admin/p_serial_num_values/form", :locals => {:f => form} + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + +- else + .p_article_serial_nums_form.field =f.inputs do - = f.input :p_article, as: :select, collection: PArticle.pluck(:id) ,:label => f.object.label_for(:p_article) - = f.input :p_serial_num_type, :label => f.object.label_for(:p_serial_num_type) + = f.input :p_serial_num_type, :label => "type", as: :select, collection: PSerialNumType.pluck(:name, :id) = f.semantic_fields_for :p_serial_num_value do | form | - =render :partial => "admin/p_serial_num_values/form", :locals => {:f => form} - - - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" - diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml index 8ab680b..f89186c 100644 --- a/app/views/admin/p_articles/_form.html.haml +++ b/app/views/admin/p_articles/_form.html.haml @@ -2,7 +2,10 @@ .content =f.inputs do - = f.input :p_product_ref, as: :select, collection: PProductRef.all, :label => f.object.label_for(:p_product_ref) + = f.input :p_product_ref, as: :select, collection: PProductRef.all.distinct, :label => f.object.label_for(:p_product_ref) + = f.semantic_fields_for :p_article_serial_nums do |f| + =render :partial => "admin/p_article_serial_nums/form", :locals => {:f => f} + diff --git a/app/views/admin/p_product_ref_specs/_form.html.haml b/app/views/admin/p_product_ref_specs/_form.html.haml index aed2719..7fae978 100644 --- a/app/views/admin/p_product_ref_specs/_form.html.haml +++ b/app/views/admin/p_product_ref_specs/_form.html.haml @@ -1,17 +1,27 @@ -=semantic_form_for [:admin, @p_product_ref_spec], :remote => true do |f| +- if params[:controller] == "admin/p_product_ref_specs" + =semantic_form_for [:admin, @p_product_ref_spec], :remote => true do |f| + .content + =f.inputs do + = f.input :p_product_ref, as: :select, collection: PProductRef.pluck(:cc_name, :id) ,:label => f.object.label_for(:p_product_ref) + = f.semantic_fields_for :p_spec_type do | form | + =render :partial => "admin/p_spec_types/form", :locals => {:f => form} + = f.semantic_fields_for :p_spec_value do | form | + =render :partial => "admin/p_spec_values/form", :locals => {:f => form} - .content - =f.inputs do - = f.input :p_product_ref, as: :select, collection: PProductRef.pluck(:cc_name, :id) ,:label => f.object.label_for(:p_product_ref) - = f.semantic_fields_for :p_spec_type do | form | - =render :partial => "admin/p_spec_types/form", :locals => {:f => form} - = f.semantic_fields_for :p_spec_value do | form | - =render :partial => "admin/p_spec_values/form", :locals => {:f => form} - / = f.input :p_spec_value, :label => f.object.label_for(:p_spec_value) - - - - - - .actions=f.submit "sauvegarder", :class => "btn btn-primary" - + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + +- else + .p_product_ref_spec_form.field + %tr + %td + %h4 spec : + + %td + =form.inputs do + = form.semantic_fields_for :p_spec_type do | f | + =render :partial => "admin/p_spec_types/form", :locals => {:f => f} + = form.semantic_fields_for :p_spec_value do | f | + =render :partial => "admin/p_spec_values/form", :locals => {:f => f} + %tr + %td + = link_to_remove_fields ic(:"trash-o"), form diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index bc9ca3b..55f48bf 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -4,10 +4,8 @@ %table.form-table %tr - %td - =# form.input :enabled, :label => "Actif ?" - %td - =# form.input :assembled, :label => "Assemblé ?", :input_html => {:onchange => 'if ($(this).is(":checked")) {$(this).closest(".field").find(".p_product_assembleds_part").show();}else{$(this).closest(".field").find(".p_product_assembleds_part").hide();}'} + =# form.input :enabled, :label => "Actif ?" + =# form.input :assembled, :label => "Assemblé ?", :input_html => {:onchange => 'if ($(this).is(":checked")) {$(this).closest(".field").find(".p_product_assembleds_part").show();}else{$(this).closest(".field").find(".p_product_assembleds_part").hide();}'} %td = form.input :ref, :label => "Réf int. :" @@ -21,8 +19,21 @@ %td =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true - - =# form.input :s_brand_id, :label => "Marque :", :collection => SBrand.all, :as => :select, :include_blank => true + + -if false + %td + =form.semantic_fields_for :p_spec_type do |f| + =render :partial => "admin/p_spec_types/form", :locals => {:f => f} + =form.semantic_fields_for :p_spec_value do |f| + =render :partial => "admin/p_spec_values/form", :locals => {:f => f} + + + %tr + .p_product_ref_specs_form + = form.semantic_fields_for :p_product_ref_specs do |f| + =render :partial => "admin/p_product_ref_specs/form", :locals => {:form => f} + %p= link_to_add_fields "Ajouter une spec", form, :p_product_ref_specs + %tr @@ -42,4 +53,4 @@ %p= link_to_add_fields "Ajouter une référence fournisseur", form, :fournisseur_product_refs - \ No newline at end of file + diff --git a/app/views/admin/p_serial_num_types/_form.html.haml b/app/views/admin/p_serial_num_types/_form.html.haml index 70b89fe..99f609b 100644 --- a/app/views/admin/p_serial_num_types/_form.html.haml +++ b/app/views/admin/p_serial_num_types/_form.html.haml @@ -2,11 +2,11 @@ .content =f.inputs do - = f.input :type, :label => f.object.label_for(:type) + = f.input :name, :label => f.object.label_for(:name) .actions=f.submit "sauvegarder", :class => "btn btn-primary" - \ No newline at end of file + diff --git a/app/views/admin/p_spec_values/_form.html.haml b/app/views/admin/p_spec_values/_form.html.haml index d44dd69..3c4c805 100644 --- a/app/views/admin/p_spec_values/_form.html.haml +++ b/app/views/admin/p_spec_values/_form.html.haml @@ -1,3 +1,6 @@ + =f.inputs do - = f.input :value, :label => "Valeur" - = f.input :unit, :label => "Unité", as: :select, collection: PSpecValue::UNITS + %td + = f.input :value, :label => "Valeur" + %td + = f.input :unit, :label => "Unité", as: :select, collection: PSpecValue::UNITS From 7c0bfc9ae4072eb592d99d0f4cc48d0707bd6707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 18:22:48 +0200 Subject: [PATCH 017/121] search for p_article, p_serial_num, p_article_serial_num --- .../admin/p_article_serial_nums_controller.rb | 14 ++++++++++++- .../admin/p_articles_controller.rb | 21 +++++++++++++++++++ .../admin/p_serial_num_types_controller.rb | 5 +++++ app/models/p_article.rb | 3 ++- app/models/p_article_serial_num.rb | 1 + app/models/p_serial_num_value.rb | 1 + .../p_article_serial_nums/index.html.haml | 13 ++++++++++++ app/views/admin/p_articles/index.html.haml | 16 ++++++++++++++ .../admin/p_serial_num_types/index.html.haml | 8 +++++++ 9 files changed, 80 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/p_article_serial_nums_controller.rb b/app/controllers/admin/p_article_serial_nums_controller.rb index 069ade6..3663027 100644 --- a/app/controllers/admin/p_article_serial_nums_controller.rb +++ b/app/controllers/admin/p_article_serial_nums_controller.rb @@ -11,7 +11,19 @@ class Admin::PArticleSerialNumsController < ApplicationController end def index - @p_article_serial_nums = PArticleSerialNum.all + @p_article_serial_nums = PArticleSerialNum.includes(:p_serial_num_type, :p_product_ref, :p_serial_num_value).all + + if params[:search][:p_serial_num_type_name] + @p_article_serial_nums = @p_article_serial_nums.joins(:p_serial_num_type).where("name LIKE ?", "#{params[:search][:p_serial_num_type_name]}%") + end + + if params[:search][:p_product_ref_cc_name] + @p_article_serial_nums = @p_article_serial_nums.joins(:p_article, :p_product_ref).where("cc_name LIKE ?","#{params[:search][:p_product_ref_cc_name]}%") + end + + if params[:search][:p_serial_num_value_value] + @p_article_serial_nums = @p_article_serial_nums.joins(:p_serial_num_value).where("value LIKE ?","#{params[:search][:p_serial_num_value_value]}%") + end @p_article_serial_nums = sort_by_sorting(@p_article_serial_nums, "id DESC") respond_to do |format| diff --git a/app/controllers/admin/p_articles_controller.rb b/app/controllers/admin/p_articles_controller.rb index 006eeda..24ba78d 100644 --- a/app/controllers/admin/p_articles_controller.rb +++ b/app/controllers/admin/p_articles_controller.rb @@ -13,6 +13,27 @@ class Admin::PArticlesController < ApplicationController def index @p_articles = PArticle.all + if params[:search][:p_product_color].to_s != "" + if params[:search][:p_product_color].to_s == "null" + @p_articles = @p_articles.where(:p_product_color => nil) + else + @p_articles = @p_articles.where(:p_product_color => params[:search][:p_product_color]) + end + end + + if params[:search][:p_product_ref_cc_name] + @p_articles = @p_articles.joins(:p_product_ref).where("cc_name LIKE ?", "#{params[:search][:p_product_ref_cc_name]}%") + end + + if params[:search][:p_product_ref_cc_code] + @p_articles = @p_articles.joins(:p_product_ref).where("cc_code LIKE ?", "#{params[:search][:p_product_ref_cc_code]}%") + end + + if params[:search][:p_serial_num_value] + @p_articles = @p_articles.joins(:p_serial_num_values).where("value LIKE ?", "#{params[:search][:p_serial_num_value]}%") + end + + @p_articles = sort_by_sorting(@p_articles, "id DESC") respond_to do |format| format.html{ diff --git a/app/controllers/admin/p_serial_num_types_controller.rb b/app/controllers/admin/p_serial_num_types_controller.rb index 7fa9e38..34a1208 100644 --- a/app/controllers/admin/p_serial_num_types_controller.rb +++ b/app/controllers/admin/p_serial_num_types_controller.rb @@ -13,6 +13,11 @@ class Admin::PSerialNumTypesController < ApplicationController def index @p_serial_num_types = PSerialNumType.all + if params[:search][:name] + @p_serial_num_types = @p_serial_num_types.where("name LIKE ?","#{params[:search][:name]}%") + end + + @p_serial_num_types = sort_by_sorting(@p_serial_num_types, "id DESC") respond_to do |format| format.html{ diff --git a/app/models/p_article.rb b/app/models/p_article.rb index 3ff569b..3464c36 100644 --- a/app/models/p_article.rb +++ b/app/models/p_article.rb @@ -1,8 +1,9 @@ class PArticle < ApplicationRecord belongs_to :p_product_ref has_one :p_product, through: :p_product_ref - belongs_to :p_product_color + has_one :p_product_color, through: :p_product_ref has_many :p_article_serial_nums, dependent: :destroy + has_many :p_serial_num_values, through: :p_article_serial_nums accepts_nested_attributes_for :p_article_serial_nums validates_presence_of :p_product_ref # has_many :p_product_ref_specs, through: :p_product_ref diff --git a/app/models/p_article_serial_num.rb b/app/models/p_article_serial_num.rb index aae27cd..5941588 100644 --- a/app/models/p_article_serial_num.rb +++ b/app/models/p_article_serial_num.rb @@ -2,6 +2,7 @@ class PArticleSerialNum < ApplicationRecord belongs_to :p_article belongs_to :p_serial_num_type belongs_to :p_serial_num_value, inverse_of: :p_article_serial_nums + has_one :p_product_ref, through: :p_article accepts_nested_attributes_for :p_serial_num_value acts_as_sorting :fields => { diff --git a/app/models/p_serial_num_value.rb b/app/models/p_serial_num_value.rb index 12a74bd..c8a476f 100644 --- a/app/models/p_serial_num_value.rb +++ b/app/models/p_serial_num_value.rb @@ -1,3 +1,4 @@ class PSerialNumValue < ApplicationRecord has_many :p_article_serial_nums, inverse_of: :p_serial_num_value + has_many :p_articles, through: :p_article_serial_nums end diff --git a/app/views/admin/p_article_serial_nums/index.html.haml b/app/views/admin/p_article_serial_nums/index.html.haml index 2a60940..9d294bd 100644 --- a/app/views/admin/p_article_serial_nums/index.html.haml +++ b/app/views/admin/p_article_serial_nums/index.html.haml @@ -7,6 +7,19 @@ .qi_search_row =form_tag "", :method => "get", :onsubmit => "" do + =hidden_field_tag :column, params[:column] + =hidden_field_tag :direction, params[:direction] + + %table + %tr + %td=text_field_tag "search[p_serial_num_type_name]", params[:search][:p_serial_num_type_name],:class => "form-control", :placeholder => "Type" + + %td=text_field_tag "search[p_product_ref_cc_name]", params[:search][:p_product_ref_cc_name],:class => "form-control", :placeholder => "Article" + + %td=text_field_tag "search[p_serial_num_value_value]", params[:search][:p_serial_num_value_value],:class => "form-control", :placeholder => "N° de serie" + + + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_article_serial_nums} diff --git a/app/views/admin/p_articles/index.html.haml b/app/views/admin/p_articles/index.html.haml index 2b77ca5..8bc5e78 100644 --- a/app/views/admin/p_articles/index.html.haml +++ b/app/views/admin/p_articles/index.html.haml @@ -7,6 +7,22 @@ .qi_search_row =form_tag "", :method => "get", :onsubmit => "" do + =hidden_field_tag :column, params[:column] + =hidden_field_tag :direction, params[:direction] + + %table + %tr + %td=text_field_tag "search[p_product_ref_cc_code]", params[:search][:p_product_ref_cc_code],:class => "form-control", :placeholder => "Code" + + %td=text_field_tag "search[p_product_ref_cc_name]", params[:search][:p_product_ref_cc_name],:class => "form-control", :placeholder => "Article" + + %td=text_field_tag "search[p_serial_num_value]", params[:search][:p_serial_num_value],:class => "form-control", :placeholder => "N° de serie" + + %td + Couleur : + =select_tag "search[p_product_color]", options_for_select([["",""],["Aucune","null"]]+PProductColor.pluck(:color, :id), params[:search][:p_product_color]) + + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_articles} diff --git a/app/views/admin/p_serial_num_types/index.html.haml b/app/views/admin/p_serial_num_types/index.html.haml index 6e9745d..522508d 100644 --- a/app/views/admin/p_serial_num_types/index.html.haml +++ b/app/views/admin/p_serial_num_types/index.html.haml @@ -7,6 +7,14 @@ .qi_search_row =form_tag "", :method => "get", :onsubmit => "" do + =hidden_field_tag :column, params[:column] + =hidden_field_tag :direction, params[:direction] + + %table + %tr + + %td=text_field_tag "search[name]", params[:search][:name],:class => "form-control", :placeholder => "Type" + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_serial_num_types} From bea1f58564b91e111ea6886306763aae9523a8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 18:43:38 +0200 Subject: [PATCH 018/121] generate p_grade --- app/controllers/admin/p_grades_controller.rb | 76 ++++++++++++++++++++ app/models/p_grade.rb | 2 + app/views/admin/p_grades/_form.html.haml | 12 ++++ app/views/admin/p_grades/_p_grade.html.haml | 16 +++++ app/views/admin/p_grades/create.js.erb | 2 + app/views/admin/p_grades/destroy.js.erb | 1 + app/views/admin/p_grades/edit.js.erb | 1 + app/views/admin/p_grades/index.html.haml | 16 +++++ app/views/admin/p_grades/new.js.erb | 1 + app/views/admin/p_grades/show.html.haml | 10 +++ app/views/admin/p_grades/update.js.erb | 2 + config/routes.rb | 11 +++ db/migrate/20210827164230_create_p_grades.rb | 9 +++ db/schema.rb | 8 ++- test/fixtures/p_grades.yml | 7 ++ test/models/p_grade_test.rb | 7 ++ 16 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/p_grades_controller.rb create mode 100644 app/models/p_grade.rb create mode 100644 app/views/admin/p_grades/_form.html.haml create mode 100644 app/views/admin/p_grades/_p_grade.html.haml create mode 100644 app/views/admin/p_grades/create.js.erb create mode 100644 app/views/admin/p_grades/destroy.js.erb create mode 100644 app/views/admin/p_grades/edit.js.erb create mode 100644 app/views/admin/p_grades/index.html.haml create mode 100644 app/views/admin/p_grades/new.js.erb create mode 100644 app/views/admin/p_grades/show.html.haml create mode 100644 app/views/admin/p_grades/update.js.erb create mode 100644 db/migrate/20210827164230_create_p_grades.rb create mode 100644 test/fixtures/p_grades.yml create mode 100644 test/models/p_grade_test.rb diff --git a/app/controllers/admin/p_grades_controller.rb b/app/controllers/admin/p_grades_controller.rb new file mode 100644 index 0000000..7a77712 --- /dev/null +++ b/app/controllers/admin/p_grades_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PGradesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @p_grades = PGrade.all + + @p_grades = sort_by_sorting(@p_grades, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_grades = @p_grades.page(page).per(per_page) + + } + end + end + + def show + @p_grade = PGrade.find(params[:id]) + + end + + def new + @p_grade = PGrade.new + + end + + def edit + @p_grade = PGrade.find(params[:id]) + + end + + def create + @p_grade = PGrade.new(params.require(:p_grade).permit!) + + if @p_grade.save + + else + render action: "new" + + end + + end + + + def update + @p_grade = PGrade.find(params[:id]) + + + if @p_grade.update_attributes(params.require(:p_grade).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @p_grade = PGrade.find(params[:id]) + @p_grade.destroy + + end +end diff --git a/app/models/p_grade.rb b/app/models/p_grade.rb new file mode 100644 index 0000000..a60cee5 --- /dev/null +++ b/app/models/p_grade.rb @@ -0,0 +1,2 @@ +class PGrade < ApplicationRecord +end diff --git a/app/views/admin/p_grades/_form.html.haml b/app/views/admin/p_grades/_form.html.haml new file mode 100644 index 0000000..00d2fa0 --- /dev/null +++ b/app/views/admin/p_grades/_form.html.haml @@ -0,0 +1,12 @@ +=semantic_form_for [:admin, @p_grade], :remote => true do |f| + + .content + =f.inputs do + = f.input :grade, :label => f.object.label_for(:grade) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/p_grades/_p_grade.html.haml b/app/views/admin/p_grades/_p_grade.html.haml new file mode 100644 index 0000000..9608e54 --- /dev/null +++ b/app/views/admin/p_grades/_p_grade.html.haml @@ -0,0 +1,16 @@ +%tr#p_grade_row{:id => p_grade.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, p_grade], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_p_grade_path(p_grade), :remote => true + = link_to i(:eye), admin_p_grade_path(p_grade), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_grade} + + + + \ No newline at end of file diff --git a/app/views/admin/p_grades/create.js.erb b/app/views/admin/p_grades/create.js.erb new file mode 100644 index 0000000..d562c04 --- /dev/null +++ b/app/views/admin/p_grades/create.js.erb @@ -0,0 +1,2 @@ +$('#p_grades_rows').prepend("<%= escape_javascript(render(@p_grade))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_grades/destroy.js.erb b/app/views/admin/p_grades/destroy.js.erb new file mode 100644 index 0000000..7e6a917 --- /dev/null +++ b/app/views/admin/p_grades/destroy.js.erb @@ -0,0 +1 @@ +$('#p_grade_row_<%= @p_grade.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/p_grades/edit.js.erb b/app/views/admin/p_grades/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_grades/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_grades/index.html.haml b/app/views/admin/p_grades/index.html.haml new file mode 100644 index 0000000..4dbb173 --- /dev/null +++ b/app/views/admin/p_grades/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_p_grade_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PGrade.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_grades} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_grades} + + + diff --git a/app/views/admin/p_grades/new.js.erb b/app/views/admin/p_grades/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/p_grades/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/p_grades/show.html.haml b/app/views/admin/p_grades/show.html.haml new file mode 100644 index 0000000..e63e6fc --- /dev/null +++ b/app/views/admin/p_grades/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @p_grade \ No newline at end of file diff --git a/app/views/admin/p_grades/update.js.erb b/app/views/admin/p_grades/update.js.erb new file mode 100644 index 0000000..0371e07 --- /dev/null +++ b/app/views/admin/p_grades/update.js.erb @@ -0,0 +1,2 @@ +$('#p_grade_row_<%= @p_grade.id %>').replaceWith("<%= escape_javascript(render(@p_grade))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index a585b05..cdc0dc1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :p_grades do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_product_ref_specs do member do diff --git a/db/migrate/20210827164230_create_p_grades.rb b/db/migrate/20210827164230_create_p_grades.rb new file mode 100644 index 0000000..3851843 --- /dev/null +++ b/db/migrate/20210827164230_create_p_grades.rb @@ -0,0 +1,9 @@ +class CreatePGrades < ActiveRecord::Migration[6.0] + def change + create_table :p_grades do |t| + t.string :grade + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index fc2f026..feae45f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_27_082814) do +ActiveRecord::Schema.define(version: 2021_08_27_164230) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1462,6 +1462,12 @@ ActiveRecord::Schema.define(version: 2021_08_27_082814) do t.datetime "updated_at", precision: 6, null: false end + create_table "p_grades", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.string "grade" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "p_nutris", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" t.boolean "public", default: true diff --git a/test/fixtures/p_grades.yml b/test/fixtures/p_grades.yml new file mode 100644 index 0000000..345f425 --- /dev/null +++ b/test/fixtures/p_grades.yml @@ -0,0 +1,7 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + grade: MyString + +two: + grade: MyString diff --git a/test/models/p_grade_test.rb b/test/models/p_grade_test.rb new file mode 100644 index 0000000..7078651 --- /dev/null +++ b/test/models/p_grade_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PGradeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From b61ff2567f44a76509fcf9488cfaa0a721d03ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 18:51:14 +0200 Subject: [PATCH 019/121] add p_grade references to p_article --- .../20210827164533_add_p_grade_references_to_p_articles.rb | 5 +++++ db/schema.rb | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210827164533_add_p_grade_references_to_p_articles.rb diff --git a/db/migrate/20210827164533_add_p_grade_references_to_p_articles.rb b/db/migrate/20210827164533_add_p_grade_references_to_p_articles.rb new file mode 100644 index 0000000..6185877 --- /dev/null +++ b/db/migrate/20210827164533_add_p_grade_references_to_p_articles.rb @@ -0,0 +1,5 @@ +class AddPGradeReferencesToPArticles < ActiveRecord::Migration[6.0] + def change + add_reference :p_articles, :p_grade, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index feae45f..6f8e516 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_27_164230) do +ActiveRecord::Schema.define(version: 2021_08_27_164533) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -985,6 +985,8 @@ ActiveRecord::Schema.define(version: 2021_08_27_164230) do t.bigint "p_product_ref_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.bigint "p_grade_id" + t.index ["p_grade_id"], name: "index_p_articles_on_p_grade_id" t.index ["p_product_ref_id"], name: "index_p_articles_on_p_product_ref_id" end @@ -3112,6 +3114,7 @@ ActiveRecord::Schema.define(version: 2021_08_27_164230) do add_foreign_key "p_article_serial_nums", "p_articles" add_foreign_key "p_article_serial_nums", "p_serial_num_types" add_foreign_key "p_article_serial_nums", "p_serial_num_values" + add_foreign_key "p_articles", "p_grades" add_foreign_key "p_articles", "p_product_refs" add_foreign_key "p_commercial_object_brands", "p_commercial_objectives" add_foreign_key "p_commercial_object_brands", "p_commercials" From de44f95293c84aa6a2238c9c3f55af3fc881f224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 19:42:35 +0200 Subject: [PATCH 020/121] color search ok --- app/controllers/admin/p_articles_controller.rb | 8 ++++++-- app/views/admin/p_articles/index.html.haml | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/p_articles_controller.rb b/app/controllers/admin/p_articles_controller.rb index 24ba78d..ef8b79a 100644 --- a/app/controllers/admin/p_articles_controller.rb +++ b/app/controllers/admin/p_articles_controller.rb @@ -15,9 +15,9 @@ class Admin::PArticlesController < ApplicationController if params[:search][:p_product_color].to_s != "" if params[:search][:p_product_color].to_s == "null" - @p_articles = @p_articles.where(:p_product_color => nil) + @p_articles = @p_articles.joins(:p_product_ref).where("p_product_color_id = ?", nil) else - @p_articles = @p_articles.where(:p_product_color => params[:search][:p_product_color]) + @p_articles = @p_articles.joins(:p_product_ref).where("p_product_color_id = ?", params[:search][:p_product_color]) end end @@ -25,6 +25,10 @@ class Admin::PArticlesController < ApplicationController @p_articles = @p_articles.joins(:p_product_ref).where("cc_name LIKE ?", "#{params[:search][:p_product_ref_cc_name]}%") end + if params[:search][:p_grade_id] + @p_articles = @p_articles.where("p_grade_id LIKE ?", "#{params[:search][:p_grade_id]}%") + end + if params[:search][:p_product_ref_cc_code] @p_articles = @p_articles.joins(:p_product_ref).where("cc_code LIKE ?", "#{params[:search][:p_product_ref_cc_code]}%") end diff --git a/app/views/admin/p_articles/index.html.haml b/app/views/admin/p_articles/index.html.haml index 8bc5e78..2123172 100644 --- a/app/views/admin/p_articles/index.html.haml +++ b/app/views/admin/p_articles/index.html.haml @@ -18,9 +18,12 @@ %td=text_field_tag "search[p_serial_num_value]", params[:search][:p_serial_num_value],:class => "form-control", :placeholder => "N° de serie" + %td.pl-2 Grade : + %td=select_tag "search[p_grade_id]", options_for_select([["",""],["Aucune","null"]]+PGrade.pluck(:grade, :id), params[:search][:p_grade_id]), class: "custom-select" + + %td.pl-2 Couleur : %td - Couleur : - =select_tag "search[p_product_color]", options_for_select([["",""],["Aucune","null"]]+PProductColor.pluck(:color, :id), params[:search][:p_product_color]) + =select_tag "search[p_product_color]", options_for_select([["",""],["Aucune","null"]]+PProductColor.pluck(:color, :id), params[:search][:p_product_color]),class: "custom-select" =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_articles} From d597960ba9a2450f8ca38390c7d0fbd25a1e5a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 27 Aug 2021 19:43:54 +0200 Subject: [PATCH 021/121] add grade form & menu --- app/controllers/admin/p_serial_num_types_controller.rb | 2 +- app/controllers/application_controller.rb | 3 ++- app/models/p_article.rb | 4 ++++ app/models/p_grade.rb | 8 ++++++++ app/views/admin/p_articles/_form.html.haml | 1 + app/views/admin/p_articles/_p_article.html.haml | 3 +++ app/views/admin/p_serial_num_types/index.html.haml | 4 ++-- 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/p_serial_num_types_controller.rb b/app/controllers/admin/p_serial_num_types_controller.rb index 34a1208..ef1f006 100644 --- a/app/controllers/admin/p_serial_num_types_controller.rb +++ b/app/controllers/admin/p_serial_num_types_controller.rb @@ -14,7 +14,7 @@ class Admin::PSerialNumTypesController < ApplicationController @p_serial_num_types = PSerialNumType.all if params[:search][:name] - @p_serial_num_types = @p_serial_num_types.where("name LIKE ?","#{params[:search][:name]}%") + @p_serial_num_types = @p_serial_num_types.where("id = ?","#{params[:search][:name]}%") end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8ff974b..3ff8eaa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -98,9 +98,10 @@ class ApplicationController < ActionController::Base if current_admin.has_permission?("boutique") set_sub_menu :stocks, :p_product_colors, "Couleurs" - set_sub_menu :stocks, :p_article_serial_nums, "Numero série" + set_sub_menu :stocks, :p_article_serial_nums, "Numeros série" set_sub_menu :stocks, :p_serial_num_types, "Types de Numero série" set_sub_menu :stocks, :p_product_ref_specs, "Specs" + set_sub_menu :stocks, :p_grades, "Grades" set_sub_menu :stocks, :p_product_powers, "Types de chargeurs" set_sub_menu :stocks, :p_product_zones, "Zones produits" diff --git a/app/models/p_article.rb b/app/models/p_article.rb index 3464c36..f1a0294 100644 --- a/app/models/p_article.rb +++ b/app/models/p_article.rb @@ -1,10 +1,13 @@ class PArticle < ApplicationRecord + belongs_to :p_grade belongs_to :p_product_ref has_one :p_product, through: :p_product_ref has_one :p_product_color, through: :p_product_ref + has_many :p_article_serial_nums, dependent: :destroy has_many :p_serial_num_values, through: :p_article_serial_nums accepts_nested_attributes_for :p_article_serial_nums + validates_presence_of :p_product_ref # has_many :p_product_ref_specs, through: :p_product_ref # accepts_nested_attributes_for :p_product_ref_specs @@ -13,6 +16,7 @@ class PArticle < ApplicationRecord :id => {:name => "id", :reorder => true}, :p_product_ref_code => {:name => "Code ref", :reorder => true}, :p_product_ref => {:name => "Désignation", :reorder => true}, + :p_grade => {:name => "Grade", :reorder => true}, :color => {:name => "Couleur"}, :p_article_serial_nums => {:name => "N° identifiants"}, :actions => {:name => "Actions", :reorder => false}, diff --git a/app/models/p_grade.rb b/app/models/p_grade.rb index a60cee5..949f5e1 100644 --- a/app/models/p_grade.rb +++ b/app/models/p_grade.rb @@ -1,2 +1,10 @@ class PGrade < ApplicationRecord + has_many :p_articles + + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :grade => {:name => "Grade", :reorder => true}, + :actions => {:name => "Actions", :reorder => false}, + } + end diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml index f89186c..f336fa7 100644 --- a/app/views/admin/p_articles/_form.html.haml +++ b/app/views/admin/p_articles/_form.html.haml @@ -3,6 +3,7 @@ .content =f.inputs do = f.input :p_product_ref, as: :select, collection: PProductRef.all.distinct, :label => f.object.label_for(:p_product_ref) + = f.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade" = f.semantic_fields_for :p_article_serial_nums do |f| =render :partial => "admin/p_article_serial_nums/form", :locals => {:f => f} diff --git a/app/views/admin/p_articles/_p_article.html.haml b/app/views/admin/p_articles/_p_article.html.haml index 13e29ca..f3631af 100644 --- a/app/views/admin/p_articles/_p_article.html.haml +++ b/app/views/admin/p_articles/_p_article.html.haml @@ -5,6 +5,9 @@ %td = p_article.p_product_ref.code + -tr[:p_grade] = capture do + %td + = p_article.p_grade.grade -tr[:color] = capture do %td diff --git a/app/views/admin/p_serial_num_types/index.html.haml b/app/views/admin/p_serial_num_types/index.html.haml index 522508d..80034b4 100644 --- a/app/views/admin/p_serial_num_types/index.html.haml +++ b/app/views/admin/p_serial_num_types/index.html.haml @@ -12,8 +12,8 @@ %table %tr - - %td=text_field_tag "search[name]", params[:search][:name],:class => "form-control", :placeholder => "Type" + %td Type : + %td=select_tag "search[name]", options_for_select([["",""],["Aucune","null"]]+PSerialNumType.pluck(:name, :id), params[:search][:name]), class: "custom-select" =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_serial_num_types} From 3f22e0c5d53aae9d59200b7c338fac40d145c014 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Mon, 30 Aug 2021 10:17:59 +0200 Subject: [PATCH 022/121] SUite --- .../(__TEMPLATE__)c | Bin 0 -> 5937 bytes .../admin/p_product_ref_specs/_form.html.haml | 28 ++++++++++-------- .../admin/p_product_refs/_form.html.haml | 9 +++--- 3 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 .sass-cache/d6dc4d64a1af1ff4c7903858d908aeb1a0a8c2c1/(__TEMPLATE__)c diff --git a/.sass-cache/d6dc4d64a1af1ff4c7903858d908aeb1a0a8c2c1/(__TEMPLATE__)c b/.sass-cache/d6dc4d64a1af1ff4c7903858d908aeb1a0a8c2c1/(__TEMPLATE__)c new file mode 100644 index 0000000000000000000000000000000000000000..2aaa2431ed50711a9ea0ae97f1640590acffa43b GIT binary patch literal 5937 zcmbVQZFAek5f(KazCe~JI(joD%Pj3GwqlF4BuDn$OnZ%M&#;qtJdx5b`hYorCkhRS zV*yZ(>hZVaFC;&sf2#cp?ZoPn5r8;*RDNi8H& z>(f%beifhxd?b^@<`FA!cC{BY*^0%f~^EgCz21>EXUjzbqMsve8D3>(gQ zbpC1XEm$0>S9ZvQfskY)Jzo6@F2;Xrq|U%sVQh~isMs_`-pj~~JsDJJ0}$L{^6V@U zF+46Z5%kp-+Eg#;rndn{Bg8I11?y!Pi?E9u>D}Zfc_f=GN_}n{_~=HB-jiBinQl$2 zHt79c`?JTkee&j;_h0|<>g6J*ah%Td84AH?M1XHiw>Us7kkYcHAd4X=XE{H#k? z@}uawyxw!m^nRCa;}xjQ_>(?9Fm_hp4y(D(adns8XHB}zHt8c}Nkx*a#MMcXV#bId z&C>;T!Tqty!Izy~hr8boLOBll_75$vly*}9I zop~Z8ZPphMh%S$To4f$d7}-EV9(WUE@Y-rq7T3VWt=wW#T3x;%ptdd#E_H*q< zAOfcWyV+SqIMG|n`PPkmYZ+VvyphK6!HG`9-#=7A$zvlV_qZE-7vgEF@GUu)7a}zB zwj#~Eg>{m*_lnf3tqpGxKugk0nO2t{AIhIf`h^6>g!nBpzMW@0o&`6)`2XX~DngF) zeI&+xxj}EY9A%lrM881xp-&aXtbRBLMk*v2`i$T&_xO~Xj8%Sq?)kOkH!g$`3d_*xk<6G(odOyHoM`-urI=Ap*J{>RURNM8`iHK zj(%uG()aq=Ehss~ubKIcDf1g(@M;bYS3B9+#pV|&(B_*8a`S&SPFTrLFwIY~u+lHN zKu&{;8EzKky3A0X2`psx~*g6$nE0XlCgO$m*TA zf}K}o>A@|sG;Jhivu`zXX_|ejaHhUVTpeTxbQn%$A9<8=_EcLC#c6AR!wT>u_C(Ps zG)skT#M^P;a^J6mEdFu_I%XuzS~zex-Wv3dz?rCkegTOt$piD)wApx#9TmJ+wUaC` z9>-zyu|}$)=zFFA5^Dg1RDe%42f7pW7xzc!{H**O$UDTQBLbu_C&>UfTd|3XnufPF z<*haF&q^MOxVo2li{53;4Cs`-DbROg9HT6{b5`x{y}(LOR#`9}LNf((mpu+V@YWo3 z8qgC-=#GtlmzV?+fIt0S8@B_%w-8fB05=VQn%Dp!`1*Ts`2k1;W}NNBo!`ZtPslqN z4!Q6BUG%@;%s8EsHz*BFT^eE-eZdXz@gON9hI7}aqI?~W)#U+K z+5#MaW~yV60__4*LGFTo=Pp2jtI9))g_Zu3xd7Q1;Ul4@BOfdMBUfgU=wy9Z-*W~| z|C#Yc1PAA9io>DmL)VJ;HN58SD+9FQ=@6)%&BRC*o32-xp#5(G{1?$U?@_cgTYjg1;hMy$v8sWYBmcg7&iZ)l!2Jd zh-+HK8+l-B$^%~wB1$QZ_4k1WwTJ!nukak4`vnsC#Jh=M`I7Tq3gf}w@&(PM?=X$u;G yCliCuHFzcpfWkD(g$U@T7nK^FA}W~v&}=JhqVg{iDWhP6tf?(oWlitF$^QWEV+vgW literal 0 HcmV?d00001 diff --git a/app/views/admin/p_product_ref_specs/_form.html.haml b/app/views/admin/p_product_ref_specs/_form.html.haml index 7fae978..ecaab27 100644 --- a/app/views/admin/p_product_ref_specs/_form.html.haml +++ b/app/views/admin/p_product_ref_specs/_form.html.haml @@ -12,16 +12,20 @@ - else .p_product_ref_spec_form.field - %tr - %td - %h4 spec : + %table + %tr + %td + %h4 spec : - %td - =form.inputs do - = form.semantic_fields_for :p_spec_type do | f | - =render :partial => "admin/p_spec_types/form", :locals => {:f => f} - = form.semantic_fields_for :p_spec_value do | f | - =render :partial => "admin/p_spec_values/form", :locals => {:f => f} - %tr - %td - = link_to_remove_fields ic(:"trash-o"), form + %td + -form.object.p_spec_type = PSpecType.new if !form.object.p_spec_type + -form.object.p_spec_value = PSpecValue.new if !form.object.p_spec_value + + =form.inputs do + = form.semantic_fields_for :p_spec_type do | f | + =render :partial => "admin/p_spec_types/form", :locals => {:f => f} + = form.semantic_fields_for :p_spec_value do | f | + =render :partial => "admin/p_spec_values/form", :locals => {:f => f} + %tr + %td + = link_to_remove_fields ic(:"trash-o"), form diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index 55f48bf..b058492 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -29,10 +29,11 @@ %tr - .p_product_ref_specs_form - = form.semantic_fields_for :p_product_ref_specs do |f| - =render :partial => "admin/p_product_ref_specs/form", :locals => {:form => f} - %p= link_to_add_fields "Ajouter une spec", form, :p_product_ref_specs + %td{:colspan => 4} + .p_product_ref_specs_form + = form.semantic_fields_for :p_product_ref_specs do |f| + =render :partial => "admin/p_product_ref_specs/form", :locals => {:form => f} + %p= link_to_add_fields "Ajouter une spec", form, :p_product_ref_specs From 9bc8251614830c112f726fd193d3a5db9d546786 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Mon, 30 Aug 2021 10:38:26 +0200 Subject: [PATCH 023/121] Suite --- .../admin/p_product_ref_specs/_form.html.haml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/views/admin/p_product_ref_specs/_form.html.haml b/app/views/admin/p_product_ref_specs/_form.html.haml index ecaab27..5c9ea2d 100644 --- a/app/views/admin/p_product_ref_specs/_form.html.haml +++ b/app/views/admin/p_product_ref_specs/_form.html.haml @@ -18,14 +18,19 @@ %h4 spec : %td - -form.object.p_spec_type = PSpecType.new if !form.object.p_spec_type - -form.object.p_spec_value = PSpecValue.new if !form.object.p_spec_value + -#form.object.p_spec_type = PSpecType.new if !form.object.p_spec_type + -#form.object.p_spec_value = PSpecValue.new if !form.object.p_spec_value - =form.inputs do - = form.semantic_fields_for :p_spec_type do | f | - =render :partial => "admin/p_spec_types/form", :locals => {:f => f} - = form.semantic_fields_for :p_spec_value do | f | - =render :partial => "admin/p_spec_values/form", :locals => {:f => f} + = form.input :p_spec_type_id, :label => "Type", as: :select, collection: PSpecType::TYPES, :include_blank => false + %td + = form.input :p_spec_value_id, :label => "Valeur", as: :select, collection: PSpecValue.all, :include_blank => false + + + =#form.inputs do + =# form.semantic_fields_for :p_spec_type do | f | + =#render :partial => "admin/p_spec_types/form", :locals => {:f => f} + =# form.semantic_fields_for :p_spec_value do | f | + =# render :partial => "admin/p_spec_values/form", :locals => {:f => f} %tr %td = link_to_remove_fields ic(:"trash-o"), form From e4467ff8aef77c9e417c8d621e5b3a7c3a52dfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 30 Aug 2021 11:34:17 +0200 Subject: [PATCH 024/121] serial number in p_article_serial_num --- .../20210830091804_add_value_to_p_article_serial_nums.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210830091804_add_value_to_p_article_serial_nums.rb diff --git a/db/migrate/20210830091804_add_value_to_p_article_serial_nums.rb b/db/migrate/20210830091804_add_value_to_p_article_serial_nums.rb new file mode 100644 index 0000000..e80c91e --- /dev/null +++ b/db/migrate/20210830091804_add_value_to_p_article_serial_nums.rb @@ -0,0 +1,5 @@ +class AddValueToPArticleSerialNums < ActiveRecord::Migration[6.0] + def change + add_column :p_article_serial_nums, :value, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 6f8e516..e1898e3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_27_164533) do +ActiveRecord::Schema.define(version: 2021_08_30_091804) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -976,6 +976,7 @@ ActiveRecord::Schema.define(version: 2021_08_27_164533) do t.bigint "p_serial_num_value_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "value" t.index ["p_article_id"], name: "index_p_article_serial_nums_on_p_article_id" t.index ["p_serial_num_type_id"], name: "index_p_article_serial_nums_on_p_serial_num_type_id" t.index ["p_serial_num_value_id"], name: "index_p_article_serial_nums_on_p_serial_num_value_id" From af77d53b9a69781258491dabf61d55a9d92d2270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 30 Aug 2021 13:11:15 +0200 Subject: [PATCH 025/121] Update form & search with serial_num_value inside p_article_serial_num --- .../admin/p_article_serial_nums_controller.rb | 13 +++++++------ app/controllers/admin/p_articles_controller.rb | 6 +++--- app/models/p_article.rb | 4 ++++ app/models/p_article_serial_num.rb | 5 +++-- app/models/p_spec_value.rb | 5 +++++ .../admin/p_article_serial_nums/_form.html.haml | 17 +++++++++-------- .../_p_article_serial_num.html.haml | 4 ++-- .../admin/p_article_serial_nums/index.html.haml | 5 +++-- app/views/admin/p_articles/_form.html.haml | 7 +++++-- app/views/admin/p_articles/_p_article.html.haml | 3 ++- app/views/admin/p_articles/index.html.haml | 2 +- .../admin/p_product_ref_specs/_form.html.haml | 4 ++-- app/views/admin/p_product_refs/_form.html.haml | 6 ------ 13 files changed, 46 insertions(+), 35 deletions(-) diff --git a/app/controllers/admin/p_article_serial_nums_controller.rb b/app/controllers/admin/p_article_serial_nums_controller.rb index 3663027..d7ecbf7 100644 --- a/app/controllers/admin/p_article_serial_nums_controller.rb +++ b/app/controllers/admin/p_article_serial_nums_controller.rb @@ -11,18 +11,19 @@ class Admin::PArticleSerialNumsController < ApplicationController end def index - @p_article_serial_nums = PArticleSerialNum.includes(:p_serial_num_type, :p_product_ref, :p_serial_num_value).all + @p_article_serial_nums = PArticleSerialNum.all + + if params[:search][:p_serial_num_type_name].present? + @p_article_serial_nums = @p_article_serial_nums.where(p_serial_num_type_id: params[:search][:p_serial_num_type_name]) - if params[:search][:p_serial_num_type_name] - @p_article_serial_nums = @p_article_serial_nums.joins(:p_serial_num_type).where("name LIKE ?", "#{params[:search][:p_serial_num_type_name]}%") end if params[:search][:p_product_ref_cc_name] @p_article_serial_nums = @p_article_serial_nums.joins(:p_article, :p_product_ref).where("cc_name LIKE ?","#{params[:search][:p_product_ref_cc_name]}%") end - if params[:search][:p_serial_num_value_value] - @p_article_serial_nums = @p_article_serial_nums.joins(:p_serial_num_value).where("value LIKE ?","#{params[:search][:p_serial_num_value_value]}%") + if params[:search][:value] + @p_article_serial_nums = @p_article_serial_nums.where("value LIKE ?","#{params[:search][:value]}%") end @p_article_serial_nums = sort_by_sorting(@p_article_serial_nums, "id DESC") @@ -45,7 +46,7 @@ class Admin::PArticleSerialNumsController < ApplicationController def new @p_article_serial_num = PArticleSerialNum.new - @p_article_serial_num.build_p_serial_num_value + # @p_article_serial_num.build_p_serial_num_value end def edit diff --git a/app/controllers/admin/p_articles_controller.rb b/app/controllers/admin/p_articles_controller.rb index ef8b79a..0e40f7a 100644 --- a/app/controllers/admin/p_articles_controller.rb +++ b/app/controllers/admin/p_articles_controller.rb @@ -33,8 +33,8 @@ class Admin::PArticlesController < ApplicationController @p_articles = @p_articles.joins(:p_product_ref).where("cc_code LIKE ?", "#{params[:search][:p_product_ref_cc_code]}%") end - if params[:search][:p_serial_num_value] - @p_articles = @p_articles.joins(:p_serial_num_values).where("value LIKE ?", "#{params[:search][:p_serial_num_value]}%") + if params[:search][:p_article_serial_num] + @p_articles = @p_articles.joins(:p_article_serial_nums).where("value LIKE ?", "#{params[:search][:p_article_serial_num]}%") end @@ -61,7 +61,7 @@ class Admin::PArticlesController < ApplicationController @p_article_serial_nums = @p_article.p_article_serial_nums.build @p_serial_num_type = @p_article_serial_nums.build_p_serial_num_type - @p_serial_num_value = @p_article_serial_nums.build_p_serial_num_value + # @p_serial_num_value = @p_article_serial_nums.build_p_serial_num_value end def edit diff --git a/app/models/p_article.rb b/app/models/p_article.rb index f1a0294..f301d09 100644 --- a/app/models/p_article.rb +++ b/app/models/p_article.rb @@ -21,4 +21,8 @@ class PArticle < ApplicationRecord :p_article_serial_nums => {:name => "N° identifiants"}, :actions => {:name => "Actions", :reorder => false}, } + + def member_label + "#{p_product_ref.cc_name}" + end end diff --git a/app/models/p_article_serial_num.rb b/app/models/p_article_serial_num.rb index 5941588..b17ef22 100644 --- a/app/models/p_article_serial_num.rb +++ b/app/models/p_article_serial_num.rb @@ -3,16 +3,17 @@ class PArticleSerialNum < ApplicationRecord belongs_to :p_serial_num_type belongs_to :p_serial_num_value, inverse_of: :p_article_serial_nums has_one :p_product_ref, through: :p_article - accepts_nested_attributes_for :p_serial_num_value + # accepts_nested_attributes_for :p_serial_num_value acts_as_sorting :fields => { :id => {:name => "ID"}, :p_article => {:name => "Article", :reorder => true}, :p_article_id => {:name => "Article ID", :reorder => true}, :p_serial_num_type => {:name => "Type", :reorder => true}, - :p_serial_num_value => {:name => "N°", :reorder => true}, + :value => {:name => "N°", :reorder => true}, :actions => {:name => "Actions", :reorder => true} } + end diff --git a/app/models/p_spec_value.rb b/app/models/p_spec_value.rb index a44875c..dd0809e 100644 --- a/app/models/p_spec_value.rb +++ b/app/models/p_spec_value.rb @@ -2,4 +2,9 @@ class PSpecValue < ApplicationRecord has_many :p_product_ref_specs UNITS = ["Go", "Mo"] + + def member_label + "#{value} #{unit}" + end + end diff --git a/app/views/admin/p_article_serial_nums/_form.html.haml b/app/views/admin/p_article_serial_nums/_form.html.haml index 34d893a..545dbdf 100644 --- a/app/views/admin/p_article_serial_nums/_form.html.haml +++ b/app/views/admin/p_article_serial_nums/_form.html.haml @@ -3,16 +3,17 @@ .content =f.inputs do - = f.input :p_article, as: :select, collection: PArticle.pluck(:id) ,:label => f.object.label_for(:p_article_id) - = f.input :p_serial_num_type, :label => f.object.label_for(:p_serial_num_type) - = f.semantic_fields_for :p_serial_num_value do | form | - =render :partial => "admin/p_serial_num_values/form", :locals => {:f => form} + = f.input :p_article, as: :select, collection: PArticle.all ,:label => f.object.label_for(:p_article_id), member_label: :member_label + = f.input :p_serial_num_type_id, :label => "type", as: :select, collection: PSerialNumType.pluck(:name, :id) + + = f.input :value + .actions=f.submit "sauvegarder", :class => "btn btn-primary" - else .p_article_serial_nums_form.field - =f.inputs do - = f.input :p_serial_num_type, :label => "type", as: :select, collection: PSerialNumType.pluck(:name, :id) - = f.semantic_fields_for :p_serial_num_value do | form | - =render :partial => "admin/p_serial_num_values/form", :locals => {:f => form} + =form.inputs do + = form.input :p_serial_num_type_id, :label => "type", as: :select, collection: PSerialNumType.pluck(:name, :id) + = form.input :value + diff --git a/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml b/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml index 59de1cd..08acd41 100644 --- a/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml +++ b/app/views/admin/p_article_serial_nums/_p_article_serial_num.html.haml @@ -18,9 +18,9 @@ %td = p_article_serial_num.p_serial_num_type.name - -tr[:p_serial_num_value] = capture do + -tr[:value] = capture do %td - = p_article_serial_num.p_serial_num_value.value + = p_article_serial_num.value -tr[:actions] = capture do diff --git a/app/views/admin/p_article_serial_nums/index.html.haml b/app/views/admin/p_article_serial_nums/index.html.haml index 9d294bd..0c3ea96 100644 --- a/app/views/admin/p_article_serial_nums/index.html.haml +++ b/app/views/admin/p_article_serial_nums/index.html.haml @@ -12,11 +12,12 @@ %table %tr - %td=text_field_tag "search[p_serial_num_type_name]", params[:search][:p_serial_num_type_name],:class => "form-control", :placeholder => "Type" + %td Type : + %td=select_tag "search[p_serial_num_type_name]", options_for_select([["",""],["Aucune","null"]]+PSerialNumType.pluck(:name, :id), params[:search][:p_serial_num_type_name]), class: "custom-select" %td=text_field_tag "search[p_product_ref_cc_name]", params[:search][:p_product_ref_cc_name],:class => "form-control", :placeholder => "Article" - %td=text_field_tag "search[p_serial_num_value_value]", params[:search][:p_serial_num_value_value],:class => "form-control", :placeholder => "N° de serie" + %td=text_field_tag "search[value]", params[:search][:value],:class => "form-control", :placeholder => "N° de serie" diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml index f336fa7..3bec92b 100644 --- a/app/views/admin/p_articles/_form.html.haml +++ b/app/views/admin/p_articles/_form.html.haml @@ -4,8 +4,11 @@ =f.inputs do = f.input :p_product_ref, as: :select, collection: PProductRef.all.distinct, :label => f.object.label_for(:p_product_ref) = f.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade" - = f.semantic_fields_for :p_article_serial_nums do |f| - =render :partial => "admin/p_article_serial_nums/form", :locals => {:f => f} + %h4 Numero de série : + .p_article_serial_nums_form + = f.semantic_fields_for :p_article_serial_nums do |form| + =render :partial => "admin/p_article_serial_nums/form", :locals => {:form => form} + %p= link_to_add_fields "Ajouter un numéro de série", f, :p_article_serial_nums, {:class => "btn btn-primary"} diff --git a/app/views/admin/p_articles/_p_article.html.haml b/app/views/admin/p_articles/_p_article.html.haml index f3631af..8d4a1ed 100644 --- a/app/views/admin/p_articles/_p_article.html.haml +++ b/app/views/admin/p_articles/_p_article.html.haml @@ -24,7 +24,8 @@ -tr[:p_article_serial_nums] = capture do %td - p_article.p_article_serial_nums.each do |sn| - = sn.p_serial_num_type.name + " : " + sn.p_serial_num_value.value + = sn.p_serial_num_type.name + " : " + sn.value + %br -tr[:actions] = capture do diff --git a/app/views/admin/p_articles/index.html.haml b/app/views/admin/p_articles/index.html.haml index 2123172..0064c5c 100644 --- a/app/views/admin/p_articles/index.html.haml +++ b/app/views/admin/p_articles/index.html.haml @@ -16,7 +16,7 @@ %td=text_field_tag "search[p_product_ref_cc_name]", params[:search][:p_product_ref_cc_name],:class => "form-control", :placeholder => "Article" - %td=text_field_tag "search[p_serial_num_value]", params[:search][:p_serial_num_value],:class => "form-control", :placeholder => "N° de serie" + %td=text_field_tag "search[p_article_serial_num]", params[:search][:p_article_serial_num],:class => "form-control", :placeholder => "N° de serie" %td.pl-2 Grade : %td=select_tag "search[p_grade_id]", options_for_select([["",""],["Aucune","null"]]+PGrade.pluck(:grade, :id), params[:search][:p_grade_id]), class: "custom-select" diff --git a/app/views/admin/p_product_ref_specs/_form.html.haml b/app/views/admin/p_product_ref_specs/_form.html.haml index 5c9ea2d..ffde9d3 100644 --- a/app/views/admin/p_product_ref_specs/_form.html.haml +++ b/app/views/admin/p_product_ref_specs/_form.html.haml @@ -21,9 +21,9 @@ -#form.object.p_spec_type = PSpecType.new if !form.object.p_spec_type -#form.object.p_spec_value = PSpecValue.new if !form.object.p_spec_value - = form.input :p_spec_type_id, :label => "Type", as: :select, collection: PSpecType::TYPES, :include_blank => false + = form.input :p_spec_type_id, :label => "Type", as: :select, collection: PSpecType.all, :include_blank => false %td - = form.input :p_spec_value_id, :label => "Valeur", as: :select, collection: PSpecValue.all, :include_blank => false + = form.input :p_spec_value_id, :label => "Valeur", as: :select, collection: PSpecValue.all, :include_blank => false, :member_label => :member_label =#form.inputs do diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index b058492..b7ff800 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -20,12 +20,6 @@ %td =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true - -if false - %td - =form.semantic_fields_for :p_spec_type do |f| - =render :partial => "admin/p_spec_types/form", :locals => {:f => f} - =form.semantic_fields_for :p_spec_value do |f| - =render :partial => "admin/p_spec_values/form", :locals => {:f => f} %tr From 74161b876af517f08bc3755950d06528e01c1091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 30 Aug 2021 14:52:50 +0200 Subject: [PATCH 026/121] Spec value menu --- app/controllers/application_controller.rb | 1 + app/models/p_spec_value.rb | 8 +++++++ app/views/admin/p_spec_values/_form.html.haml | 22 ++++++++++++++----- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3ff8eaa..9ab496c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -101,6 +101,7 @@ class ApplicationController < ActionController::Base set_sub_menu :stocks, :p_article_serial_nums, "Numeros série" set_sub_menu :stocks, :p_serial_num_types, "Types de Numero série" set_sub_menu :stocks, :p_product_ref_specs, "Specs" + set_sub_menu :stocks, :p_spec_values, "Valeur de specs" set_sub_menu :stocks, :p_grades, "Grades" set_sub_menu :stocks, :p_product_powers, "Types de chargeurs" set_sub_menu :stocks, :p_product_zones, "Zones produits" diff --git a/app/models/p_spec_value.rb b/app/models/p_spec_value.rb index dd0809e..8471de5 100644 --- a/app/models/p_spec_value.rb +++ b/app/models/p_spec_value.rb @@ -7,4 +7,12 @@ class PSpecValue < ApplicationRecord "#{value} #{unit}" end + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :value => {:name => "Valeur", :reorder => true}, + :unit => {:name => "Unité", :reorder => true}, + :actions => {:name => "Actions", :reorder => true} + } + + end diff --git a/app/views/admin/p_spec_values/_form.html.haml b/app/views/admin/p_spec_values/_form.html.haml index 3c4c805..509bf70 100644 --- a/app/views/admin/p_spec_values/_form.html.haml +++ b/app/views/admin/p_spec_values/_form.html.haml @@ -1,6 +1,18 @@ +- if params[:controller] == "admin/p_spec_values" + =semantic_form_for [:admin, @p_spec_value], :remote => true do |f| -=f.inputs do - %td - = f.input :value, :label => "Valeur" - %td - = f.input :unit, :label => "Unité", as: :select, collection: PSpecValue::UNITS + .content + =f.inputs do + %td + = f.input :value, :label => "Valeur" + %td + = f.input :unit, :label => "Unité", as: :select, collection: PSpecValue::UNITS + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + +- else + =f.inputs do + %td + = f.input :value, :label => "Valeur" + %td + = f.input :unit, :label => "Unité", as: :select, collection: PSpecValue::UNITS From c870d581223691a48cf94039f2dac4971095c3de Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Mon, 30 Aug 2021 16:20:40 +0200 Subject: [PATCH 027/121] Suite --- app/models/price_line.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/price_line.rb b/app/models/price_line.rb index 7a82893..0f9a174 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -209,7 +209,7 @@ class PriceLine < ApplicationRecord def ca_product_no_remise - if self.p_product_ref and self.p_customer and p_customer_product_price = self.p_product_ref.p_customer_product_prices.where(:p_customer_id => self.p_customer.id).first + if false #self.p_product_ref and self.p_customer and p_customer_product_price = self.p_product_ref.p_customer_product_prices.where(:p_customer_id => self.p_customer.id).first p_customer_product_price.no_remise From 7baa9a4435b4a951cad0efce96c25bc118bbe8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 30 Aug 2021 19:49:28 +0200 Subject: [PATCH 028/121] TVA rates fix --- .../(__TEMPLATE__)c | Bin 0 -> 5961 bytes .../admin/p_customer_sheets_controller.rb | 13 ++++++++----- .../admin/p_product_refs_controller.rb | 14 ++++++++------ app/models/p_customer.rb | 9 +++++++++ app/views/admin/price_lines/_form.html.haml | 2 +- 5 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 .sass-cache/2008dff8cddf4c9967017d710d180856df6a3c9d/(__TEMPLATE__)c diff --git a/.sass-cache/2008dff8cddf4c9967017d710d180856df6a3c9d/(__TEMPLATE__)c b/.sass-cache/2008dff8cddf4c9967017d710d180856df6a3c9d/(__TEMPLATE__)c new file mode 100644 index 0000000000000000000000000000000000000000..e13aa0321643ab633d299c9ffc3efbd90872cbe3 GIT binary patch literal 5961 zcmbVQ+j85;5fxP_ULZ>py}Fr_WrlXNwpJEtNnY7ARmsF&yNan@muscXiylw|a6};s zVi*9lS8@3*`Gw>&@>9t#B#%k=;4&N%(n|Y84AIkbx~KbeHxBoY_m8aOqoZT)9yrd+ zbAIsLIS}2WL-!?r)^}e#=i-HXEWUPxbJ(?hRh8u436CN|PD3FG`CiKSo$QM{WQn;K zp5G5ea8{cZ8v6o;>cnCpJfD?&?e&L_>|feZ%wsQ#y+4mdR3_y&r{pdh@h}p78zm!2 z+R1Sz!WV8VLqcB5;gFvQ*b%s*N*38r3>^_hXJtw5PYY*q6?zBXKb(2*4M)Dnq!tpX z^=YYIzY5R;J`}z7+AMBbJB8Q27YMHmemM7hfwEn|7LA=h0dDmu$DxZBRZm1*h7A`y zy7)Zz7A%g`D?8-DKuEHY9NOZZK{`a)7yZf5n>mhg7q?tMcBoS^ltK#Jd#Zor9QU}d~~Bm?@6t%Ot&Uh z8}xp!{l#P3K7I4u`)_}L`o^}Ol)*uCTas3Sx|bdbLG%`IM3+%4hUnlBf~nWu>--SG zb#@#c2HX)H7b2(gDp`Ef8HED;VDr%kwSred!F~G|?A%}x+>wnJWq$RTOIPxv=(@b#qs#Pumu}5a`^m(w!NBKceM?oWvnSL5=PpJ$?Q9`K#ks6ILqqPuNTP zC8>LTu+Ka9L`d4KFCZvg9s_520h}?ift)<>CdlBm)ut@2fsI?a#kktfEXIo>4K@Nx z?dURy`A?)8h>xi!DV|=ePkYeNN7fZ<6(lh083>vg0%CN zvy>g=+KoU2t^?Myvr2KQx0ds*8~N5UxCZznjp4&noru4EsDhHmMo8{+H}*b=y;k8{ zav?v6(8$}0H1ihLN#5QoQm?i)yhQ*lNi$_&U6y<(iz?|C5*QQWx6Jrc*a&7xeF8OoDf)+}Tz<&B^1FRtUMm78R#&NU?4%{)uh=7zTdL8uQ~ek5bN_Y73$`Z4GdU z0iML3C^~~?sj!WBI}Tj#`*o1TU+zFBjigx%2M)(ugWeH16BW>}AkigxU>=(`8?UjW zg7>O+k_E=&IE+5kNHr9Fuk=4+4Pd|u@TulNccT8{{^)|Am!AQ7huCyPfE4B@831Q1 zHc?U2@YbfhwFdrK$wLuW_cCwMyR4Z3ow7Ft`fiNll|^^XtKI$QSn0_s3&ulereGek z$AJglnuAUQdLjwkvGMN`lRyISr{8Pib^!PmVyXz>rU6hB8vq1f|0pg$0;$04vz@r} zhuHH8c_+gm_r1S}{&##-fz}D+peMjS4%$s9Uqe2E-vt(pd=6t62tczxu#@E#Na_ZX z2a~Qs^HX=FG+x(zu=2jaU`2Me4DGv<+HuGeF#e(oi4~2wE8s6Dgl1eodwG@TOuU9h z#9PdbMbLCcVT@=+IXC{xzr*rZKrJ<=yLkuG^xB)&YBxS^K?)p@e zufwsrJm5-OfCJD>bu3b#U0^E6UGSgW1t@S;c}TIa(tk4-AR8lmB-C`|W2JxQ%1jcS ztPkt^&cNwEHNKSKKz&VdI8uG+TJgSy*SvjYfHpiGLe*x}k?JukLlbumv`+N}H(si$uyO*dS|aOIBIa HdwBYP#Xb{> literal 0 HcmV?d00001 diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index f99ea9f..5729f1c 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -174,12 +174,14 @@ class Admin::PCustomerSheetsController < ApplicationController @p_customer_sheet.admin = current_admin - @p_customer = @p_customer_sheet.p_customer + if @p_customer_sheet.save - @p_customer_sheets = PCustomerSheet.order(:id).all + redirect_to admin_p_customer_sheet_path(@p_customer_sheet) else + @p_customer = @p_customer_sheet.price_line_block.p_customer + render action: "new" end @@ -189,13 +191,14 @@ class Admin::PCustomerSheetsController < ApplicationController def update @p_customer_sheet = PCustomerSheet.find(params[:id]) - @p_customer = @p_customer_sheet.p_customer + if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!) - @p_customer_sheets = PCustomerSheet.order(:id).all - + @p_customer = @p_customer_sheet.price_line_block.p_customer + + redirect_to admin_p_customer_sheet_path(@p_customer_sheet) else render action: "edit" diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index c72e779..5648846 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -138,27 +138,29 @@ class Admin::PProductRefsController < ApplicationController def get_infos + @p_product_ref = PProductRef.find(params[:id]) if params[:type] == "price" price = @p_product_ref.get_price(:p_customer_id => params[:p_customer_id], :qte => params[:qte]) - puts params[:p_fournisseur_id] - + + if params[:p_customer_id].to_s != "" p_customer = PCustomer.find(params[:p_customer_id]) accounting_zone_id = p_customer.accounting_zone_id + if p_customer.tva_rate tva_account_id = p_customer.tva_rate.id tva_account_value = p_customer.tva_rate.rate - + else tva_account_id = @p_product_ref.p_product.tva_rate(accounting_zone_id).id if @p_product_ref.p_product.tva_rate(accounting_zone_id) tva_account_value = @p_product_ref.p_product.tva_rate(accounting_zone_id).rate if @p_product_ref.p_product.tva_rate(accounting_zone_id) - - + + end - + elsif params[:p_fournisseur_id].to_s != "" p_fournisseur = PFournisseur.find(params[:p_fournisseur_id]) accounting_zone_id = p_fournisseur.accounting_zone_id diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index 3fd7005..e1ee85d 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -192,6 +192,15 @@ class PCustomer < ApplicationRecord end + def tva_rate + if tva = TvaRate.where(:accounting_zone_id => self.accounting_zone_id).first + return tva + else + return nil + end + end + + def update_caches diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 9920ecb..67bd84d 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -118,7 +118,7 @@ -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", :disabled => true + =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" #, :disabled => true From cb88543c4174b97c27b4f18143aacf02d0fcc5c8 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Mon, 30 Aug 2021 22:03:29 +0200 Subject: [PATCH 029/121] =?UTF-8?q?Probl=C3=A8me=20stocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/line_stock.rb | 4 ++-- app/views/admin/stock_movement_lines/_form_cred.html.haml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/line_stock.rb b/app/models/line_stock.rb index 06e170d..ab34132 100644 --- a/app/models/line_stock.rb +++ b/app/models/line_stock.rb @@ -99,7 +99,7 @@ class LineStock < ApplicationRecord end def ca_price_u_kg_ht - if self.qte_kg_per_unit != 0.0 + if self.qte_kg_per_unit.to_f != 0.0 (self.price_u_ht.to_f / self.qte_kg_per_unit).round(2) else 0.0 @@ -116,7 +116,7 @@ class LineStock < ApplicationRecord end def ca_qte_kg - self.qte * self.qte_kg_per_unit + self.qte.to_f * self.qte_kg_per_unit.to_f end diff --git a/app/views/admin/stock_movement_lines/_form_cred.html.haml b/app/views/admin/stock_movement_lines/_form_cred.html.haml index 75c4daf..3e2afcf 100644 --- a/app/views/admin/stock_movement_lines/_form_cred.html.haml +++ b/app/views/admin/stock_movement_lines/_form_cred.html.haml @@ -91,6 +91,7 @@ %td = form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte"} - %td - = form.input :dluo, :label => "DLUO :", :input_html => {:class => ""}, :as => :date + -if false + %td + = form.input :dluo, :label => "DLUO :", :input_html => {:class => ""}, :as => :date From ed02337d27179615cfed12837d7bf165c404045d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 31 Aug 2021 08:27:31 +0200 Subject: [PATCH 030/121] Mask grade with ACTIVATED --- app/controllers/application_controller.rb | 2 +- app/models/p_article.rb | 30 ++++++++++++++-------- app/models/p_grade.rb | 1 + app/views/admin/p_articles/_form.html.haml | 3 ++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9ab496c..63ae755 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -102,7 +102,7 @@ class ApplicationController < ActionController::Base set_sub_menu :stocks, :p_serial_num_types, "Types de Numero série" set_sub_menu :stocks, :p_product_ref_specs, "Specs" set_sub_menu :stocks, :p_spec_values, "Valeur de specs" - set_sub_menu :stocks, :p_grades, "Grades" + set_sub_menu :stocks, :p_grades, "Grades" if PGrade::ACTIVATED set_sub_menu :stocks, :p_product_powers, "Types de chargeurs" set_sub_menu :stocks, :p_product_zones, "Zones produits" diff --git a/app/models/p_article.rb b/app/models/p_article.rb index f301d09..187741f 100644 --- a/app/models/p_article.rb +++ b/app/models/p_article.rb @@ -12,16 +12,26 @@ class PArticle < ApplicationRecord # has_many :p_product_ref_specs, through: :p_product_ref # accepts_nested_attributes_for :p_product_ref_specs - acts_as_sorting :fields => { - :id => {:name => "id", :reorder => true}, - :p_product_ref_code => {:name => "Code ref", :reorder => true}, - :p_product_ref => {:name => "Désignation", :reorder => true}, - :p_grade => {:name => "Grade", :reorder => true}, - :color => {:name => "Couleur"}, - :p_article_serial_nums => {:name => "N° identifiants"}, - :actions => {:name => "Actions", :reorder => false}, - } - + if PGrade::ACTIVATED + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :p_product_ref_code => {:name => "Code ref", :reorder => true}, + :p_product_ref => {:name => "Désignation", :reorder => true}, + :p_grade => {:name => "Grade", :reorder => true}, + :color => {:name => "Couleur"}, + :p_article_serial_nums => {:name => "N° identifiants"}, + :actions => {:name => "Actions", :reorder => false}, + } + else + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :p_product_ref_code => {:name => "Code ref", :reorder => true}, + :p_product_ref => {:name => "Désignation", :reorder => true}, + :color => {:name => "Couleur"}, + :p_article_serial_nums => {:name => "N° identifiants"}, + :actions => {:name => "Actions", :reorder => false}, + } + end def member_label "#{p_product_ref.cc_name}" end diff --git a/app/models/p_grade.rb b/app/models/p_grade.rb index 949f5e1..648e10e 100644 --- a/app/models/p_grade.rb +++ b/app/models/p_grade.rb @@ -7,4 +7,5 @@ class PGrade < ApplicationRecord :actions => {:name => "Actions", :reorder => false}, } + ACTIVATED = false end diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml index 3bec92b..ae711c0 100644 --- a/app/views/admin/p_articles/_form.html.haml +++ b/app/views/admin/p_articles/_form.html.haml @@ -3,7 +3,8 @@ .content =f.inputs do = f.input :p_product_ref, as: :select, collection: PProductRef.all.distinct, :label => f.object.label_for(:p_product_ref) - = f.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade" + -if PGrade::ACTIVATED + = f.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade" %h4 Numero de série : .p_article_serial_nums_form = f.semantic_fields_for :p_article_serial_nums do |form| From a8ffef183300a1484b7c8b7b5c491740dde191b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 31 Aug 2021 19:10:18 +0200 Subject: [PATCH 031/121] buy_list upgrade --- app/controllers/admin/buy_lists_controller.rb | 50 +++- app/views/admin/buy_lists/index.html.haml | 220 ++++++++++++------ 2 files changed, 197 insertions(+), 73 deletions(-) diff --git a/app/controllers/admin/buy_lists_controller.rb b/app/controllers/admin/buy_lists_controller.rb index cd1b7b6..662c25d 100644 --- a/app/controllers/admin/buy_lists_controller.rb +++ b/app/controllers/admin/buy_lists_controller.rb @@ -14,11 +14,57 @@ class Admin::BuyListsController < ApplicationController @price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids) + if params[:search][:s_brand].present? && params[:search][:s_brand] != "" + @price_lines = @price_lines.joins(p_product_ref: :p_product).where("s_brand_id = ?", params[:search][:s_brand]) + end + + if params[:search][:state].present? && params[:search][:state] != "" + @p_customer_sheets = @p_customer_sheets.where(:state => params[:search][:state]) + @price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids) + @price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids) + end + + if params[:search][:p_customer_code].present? + @p_customer_sheets = @p_customer_sheets.joins(:p_customer).where("code LIKE ?", params[:search][:p_customer_code]) + @price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids) + @price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids) + end + + date_regex = /^(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/](19|20)\d\d$/i + + + params[:start] = Date.today.beginning_of_month.strftime('%d/%m/%Y') if !params[:start] + + if params[:start] and params[:start] =~ date_regex + #fsfds = sdfsfd + @start = Date.parse(params[:start]).beginning_of_day + params[:start]= @start.strftime('%d/%m/%Y') + else + @start = nil + end + + if true + params[:stop] = Date.today.end_of_month.strftime('%d/%m/%Y') if !params[:stop] + + + if params[:stop].to_s != "" # and params[:stop] =~ date_regex + @stop = Date.parse(params[:stop]).end_of_day + + params[:stop]= @stop.strftime('%d/%m/%Y') + + + else + @stop = nil + end + + end + @price_lines = @price_lines.where("price_lines.cc_creation_date >= ?", @start) if @start + @price_lines = @price_lines.where("price_lines.cc_creation_date <= ?", @stop.end_of_day) if @stop + + respond_to do |format| format.html{ - - } end diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index fdde1af..8274a67 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -1,3 +1,4 @@ +-checkbox = false .qi_header .right =link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add" @@ -10,16 +11,48 @@ =form_tag "", :method => "get", :onsubmit => "" do -params[:search] =params[:search] || {} - + %p Date de consultation : %table - %tr - + %tr.form-inline + %td + Début + %td.input-group + =text_field_tag :start, params[:start],:class => "form-control datepicker", :placeholder => "Début" + .input-group-append + %span.input-group-text{:onclick => "$(this).prev('input').val('');"} + =ic(:times) + %td.pl-4 + Fin + %td.input-group + =text_field_tag :stop, params[:stop],:class => "form-control datepicker", :placeholder => "Fin" + .input-group-append + %span.input-group-text{:onclick => "$(this).prev('input').val('');"} + =ic(:times) %td Statut : - =select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]) - - - + =select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]), class: "custom-select" + + %td + Marque : + =select_tag "search[s_brand]", options_for_select([["",""],["Aucune","null"]]+SBrand.pluck(:name, :id), params[:search][:s_brand]), class: "custom-select" + %td + Code client : + =text_field_tag "search[p_customer_code]", params[:search][:p_customer_code],:class => "form-control" + + %tr.form-inline + %td{width: "110px"} + + %td.right.mx-4 + -if @start and @stop + + =link_to "< Mois précédent",request.query_parameters.merge({start: ((@start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + %td{width: "20px"} + %td.mr-auto + -if @start and @stop + =link_to "Mois suivant >",request.query_parameters.merge({start: ((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + + + =link_to ic(:search)+" Rechercher", "#", :class => "btn btn-default btn-qi-search", :onclick => "$(this).closest('form').submit();$(this).html('...');return false;" @@ -44,13 +77,15 @@ %table.table.table-striped.table-hover.table-bordered.data_table %thead.header %tr - %th + -if checkbox + %th %th Produit %th Référence - %th Qté - + / %th Qté + %th.mask + =ic("plus-square-o") %th.mask N° Commande %th.mask @@ -63,7 +98,11 @@ %th.mask Date livraison (ETA) %th.mask - Qté commandée + Qté nécessaire + %th.mask + Qté en stock + %th.mask + Qté souhaité %th.mask Commentaire %th.mask BPA %th.mask AV BPA @@ -89,7 +128,9 @@ -ppr_lines = @price_lines.where(:p_product_ref_id => plr.p_product_ref.id) %tr.ref_tr - %td + -if checkbox + %td + %td =link_to plr.p_product_ref.p_product.name, [:admin, plr.p_product_ref] %td @@ -97,79 +138,100 @@ =plr.p_product_ref.ct_sub_name =plr.p_product_ref.p_product_color.name if plr.p_product_ref.p_product_color + %td.plus + =link_to ic("plus-square-o"), "#" %td - =ppr_lines.sum(:qte) %td.mask + / %td.mask %td.mask %td.mask %td.mask %td.mask %td.mask + ∑ + =ppr_lines.sum(:qte).to_i + %br + %span.asap + =ic(:fire) + =ppr_lines.asap_triage(10).first + %br + %span.non-asap + =ic(:hourglass) + =ppr_lines.asap_triage(10).last %td.mask + = LineStock.where(p_product_ref_id: plr.p_product_ref.id).sum(:qte_available).to_i + + %td.mask + =text_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input" %td.mask %td.mask - =ppr_lines.where(:cc_state => "BPA").sum(:qte) + =ppr_lines.where(:cc_state => "BPA").sum(:qte).to_i %td.mask - =ppr_lines.where(:cc_state => "AV BPA").sum(:qte) + =ppr_lines.where(:cc_state => "AV BPA").sum(:qte).to_i %td.mask - =ppr_lines.where(:cc_state => "PAS BPA").sum(:qte) + =ppr_lines.where(:cc_state => "PAS BPA").sum(:qte).to_i - -ppr_lines.each do |price_line| - %tr - %td - =check_box_tag :"price_line_ids[]", price_line.id - %td - %td - %td - %td - =link_to [:admin, price_line.price_line_block.price_lineable] do - =price_line.price_line_block.price_lineable.id - =price_line.price_line_block.price_lineable.past_id - - - - %td - =link_to price_line.p_customer.show_name, [:admin, price_line.p_customer] - - %td - =state_helper price_line.price_line_block.price_lineable.state - - %td - = l price_line.cc_creation_date, :format => :short_date - - %td - = l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date - - - %td - = l price_line.cc_wish_date, :format => "semaine %V (%Y)" - - %td - =price_line.qte - - %td - =price_line.comment - - %td - =price_line.qte if price_line.cc_state == "BPA" - - %td - =price_line.qte if price_line.cc_state == "AV BPA" - - %td - =price_line.qte if price_line.cc_state == "PAS BPA" - + %tbody.detail + -ppr_lines.each do |price_line| + %tr.details + - if checkbox + %td + =check_box_tag :"price_line_ids[]", price_line.id + / %td + %td + %td + %td + %td + =link_to [:admin, price_line.price_line_block.price_lineable] do + =price_line.price_line_block.price_lineable.id + =price_line.price_line_block.price_lineable.past_id + + + + %td + =link_to price_line.p_customer.show_name, [:admin, price_line.p_customer] + + %td + =state_helper price_line.price_line_block.price_lineable.state + + %td + = l price_line.cc_creation_date, :format => :short_date + + %td + = l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date + + %td + = l price_line.cc_wish_date, :format => "semaine %V (%Y)" + + %td + =price_line.qte.to_i + %td + + %td + + %td + =price_line.comment + + %td + =price_line.qte.to_i if price_line.cc_state == "BPA" + + %td + =price_line.qte.to_i if price_line.cc_state == "AV BPA" + + %td + =price_line.qte.to_i if price_line.cc_state == "PAS BPA" + -p_product_id = plr.p_product_id - - %tr - -nbr_td.times.each do - %td - - =submit_tag "Créer une demande de prix", :class => "btn btn-primary" + + %tr + -nbr_td.times.each do + %td + + =submit_tag "Créer une demande de prix", :class => "btn btn-primary" @@ -187,10 +249,26 @@ border-bottom:3px solid red; } } + + .asap { + color: red; + } + + .non-asap { + color: darkblue; + } + + .small-input { + max-width: 100px; + } + +:javascript + $('.plus').click(function(event){ + console.log(event.currentTarget); + $(event.currentTarget).parent().parent().next('tbody.detail').toggle(); + $(event.currentTarget).find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o') + }); + - - - - \ No newline at end of file From fa354b1366cbe97bf85c1b32ce6de55a78ed4443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 31 Aug 2021 19:10:55 +0200 Subject: [PATCH 032/121] display url instead of path --- app/views/admin/price_documents/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 6dc2903..3178d8e 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -77,7 +77,7 @@ %td Lien pour consultation %td - =link_to consult_admin_price_document_path(:id => @price_document.f_token, :lang => nil), consult_admin_price_document_path(:id => @price_document.f_token, :lang => nil) + =link_to consult_admin_price_document_url(:id => @price_document.f_token, :lang => nil), consult_admin_price_document_url(:id => @price_document.f_token, :lang => nil) From e9e0f009a61e8f93ec389df59ccd04f99ef3e52c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 31 Aug 2021 19:12:25 +0200 Subject: [PATCH 033/121] demade de prix --- .../admin/price_documents_controller.rb | 14 +++- app/models/price_document.rb | 4 +- app/models/price_line.rb | 7 +- .../admin/price_documents/_form.html.haml | 23 +++-- .../price_documents/_price_document.html.haml | 13 ++- .../admin/price_documents/index.html.haml | 83 ++++++++++--------- app/views/admin/price_documents/new.html.haml | 4 +- 7 files changed, 89 insertions(+), 59 deletions(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 2b92020..4a079ad 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -235,11 +235,17 @@ class Admin::PriceDocumentsController < ApplicationController @price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) if @price_document.price_document_type.label == "Demande prix" - @ref_price_lines = PriceLine.where(:id => params[:price_line_ids]) - - @ref_price_lines.group(:p_product_ref_id).each do |plr| - @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) + p_product_ref_id = params[:qte].keys + p_product_ref_qte = params[:qte].values + + p_product_ref_id.each_with_index do |key, i| + @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => key, :qte => p_product_ref_qte[i]) end + + # @ref_price_lines = PriceLine.where(:id => params[:price_line_ids]) + # @ref_price_lines.group(:p_product_ref_id).each do |plr| + # @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) + # end end diff --git a/app/models/price_document.rb b/app/models/price_document.rb index ec4b0f8..6328710 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -27,6 +27,8 @@ class PriceDocument < ApplicationRecord PURCHASES = ["Demande prix", "Commande achat", "Facture d'achat"] SALES = ["Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] + # AVANCEMENT = ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"] + AVANCEMENT = ["0%", "25%", "50%", "75%", "100"] validates :public_fournisseur_name, :presence => true, :if => :public_fournisseur_name_needed? @@ -291,7 +293,7 @@ class PriceDocument < ApplicationRecord :cc_cost_ht => {:name => "Coût HT", :reorder => true, :as => :currency}, :cc_marge_ht => {:name => "Marge HT", :reorder => true, :as => :currency}, :cost_ok => {:name => "Marge calculée", :reorder => true, :as => :boolean}, - + :f_token => {:name => "Liens consultation"}, diff --git a/app/models/price_line.rb b/app/models/price_line.rb index 0f9a174..f02360b 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -597,7 +597,12 @@ class PriceLine < ApplicationRecord AVOIR_TO_RESET = %w(block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) - + def self.asap_triage(limit) + total = self.sum(:qte).to_i + asap = self.where('cc_wish_date > ?', Date.today + limit).sum(:qte).to_i + non_asap = total - asap + return [asap, non_asap] + end diff --git a/app/views/admin/price_documents/_form.html.haml b/app/views/admin/price_documents/_form.html.haml index fa414d2..1a74d5a 100644 --- a/app/views/admin/price_documents/_form.html.haml +++ b/app/views/admin/price_documents/_form.html.haml @@ -24,14 +24,23 @@ = @price_document.price_line_block.block_type -if @price_document.label == "Demande prix" - =f.input :avancement, :label => "Avancement (%) :" - =f.input :list_designaton, :label => "Désignation de la liste :" - =f.input :end_date, :label => "Fin de consultation :", :as => :date - =f.input :dp_comment, :label => "Commentaire demande de prix :" - =f.input :acheteur_text, :label => "Envoyé à :" - + .row + .col-4 + .row + .col + =f.input :end_date, :label => "Fin de consultation :", :as => :date + .col + =f.input :avancement, :label => "Avancement (%) :", as: :select, collection: PriceDocument::AVANCEMENT, selected: PriceDocument::AVANCEMENT.first + =f.input :list_designaton, as: :string, :label => "Désignation de la liste :" + .col + =f.input :acheteur_text, :label => "Envoyé à :", input_html: {rows: 5} + .col + =f.input :dp_comment, :label => "Commentaire demande de prix :", input_html: {rows: 5} + + + -if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 7 = f.input :date, :label => "Date du document :", :as => :date .price_line_block_form @@ -50,4 +59,4 @@ - \ No newline at end of file + diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index 77a3096..923ddb6 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -50,8 +50,15 @@ -if price_document.label == "Avoir" =number_to_currency price_document.cc_to_paid_ttc - - + -tr[:f_token] = capture do + %td + = consult_admin_price_document_url(:id => price_document.f_token, :lang => nil) + + -tr[:avancement] = capture do + %td + - if price_document.avancement + = price_document.avancement.to_s + " %" + -tr[:stock_ok] = capture do %td @@ -147,4 +154,4 @@ =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => price_document} - \ No newline at end of file + diff --git a/app/views/admin/price_documents/index.html.haml b/app/views/admin/price_documents/index.html.haml index 18a695a..8513399 100644 --- a/app/views/admin/price_documents/index.html.haml +++ b/app/views/admin/price_documents/index.html.haml @@ -13,7 +13,7 @@ -else =link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary bgbd-ventes" %h1 - Documents comptables + Documents %span Liste @@ -33,50 +33,50 @@ %table.qi_search_row_top - %tr + %tr.form-inline %td Début - %td - .input-group - =text_field_tag :start, params[:start],:class => "form-control datepicker", :placeholder => "Début" - %span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"} + %td.input-group + =text_field_tag :start, params[:start],:class => "form-control datepicker", :placeholder => "Début" + .input-group-append + %span.input-group-text{:onclick => "$(this).prev('input').val('');"} =ic(:times) - - %br - -if @start and @stop - - =link_to "< Mois précédent",request.query_parameters.merge({start: ((@start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-default" - - - %td + %td.pl-4 Fin - %td - .input-group - =text_field_tag :stop, params[:stop],:class => "form-control datepicker", :placeholder => "Fin" - %span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"} + %td.input-group + =text_field_tag :stop, params[:stop],:class => "form-control datepicker", :placeholder => "Fin" + .input-group-append + %span.input-group-text{:onclick => "$(this).prev('input').val('');"} =ic(:times) - %br + + %tr.form-inline + %td.right.ml-auto -if @start and @stop - =link_to "Mois suivant >",request.query_parameters.merge({start: ((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-default" - - + + =link_to "< Mois précédent",request.query_parameters.merge({start: ((@start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + %td.mr-auto + -if @start and @stop + =link_to "Mois suivant >",request.query_parameters.merge({start: ((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + + -params[:price_document_type_ids] = params[:price_document_type_ids] || [] + %tr.form-inline %td Type de document : %td - - -if [6,7].include?(params[:price_document_type_id].to_i)or (params[:price_document_type_ids] and (params[:price_document_type_ids].include?("6") or params[:price_document_type_ids].include?("7"))) + + -if [1,2,6,7].include?(params[:price_document_type_id].to_i)or (params[:price_document_type_ids] and (params[:price_document_type_ids].include?("6") or params[:price_document_type_ids].include?("7"))) -PriceDocumentType.where(:label => PriceDocument::PURCHASES, :enabled => true).order("id DESC").each do |pdt| - %p - = check_box_tag :"price_document_type_ids[]", pdt.id, (true if params[:price_document_type_ids].include?(pdt.id.to_s)), {:id => "price_document_type_ids_#{pdt.id}"} - = label_tag "price_document_type_ids_"+pdt.id.to_s, pdt.label + %p.d-inline-flex.ml-3 + = check_box_tag :"price_document_type_ids[]", pdt.id, (true if params[:price_document_type_ids].include?(pdt.id.to_s)), {:id => "price_document_type_ids_#{pdt.id}", class: "my-auto"} + = label_tag "price_document_type_ids_"+pdt.id.to_s, pdt.label, class: "ml-3 my-auto" -else -PriceDocumentType.where(:label => PriceDocument::SALES, :enabled => true).order("id DESC").each do |pdt| - %p + %p.d-inline-flex = check_box_tag :"price_document_type_ids[]", pdt.id, (true if params[:price_document_type_ids].include?(pdt.id.to_s)), {:id => "price_document_type_ids_#{pdt.id}"} - = label_tag "price_document_type_ids_"+pdt.id.to_s, pdt.label - + = label_tag "price_document_type_ids_"+pdt.id.to_s, pdt.label, class: "ml-3" + %br %table %tr %td @@ -95,18 +95,19 @@ Commercial : =select_tag "search[p_commercial_id]", options_for_select([["",""],["Aucun","null"]]+PCommercial.order(:name).all.map{|a| [a.member_label, a.id]}, params[:search][:p_commercial_id]) - %td - Type de paiement : - =select_tag "search[p_payment_type_id]", options_for_select([["",""]]+PPaymentType.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_payment_type_id]) + -if [6].include?(params[:price_document_type_id].to_i) + %td + Type de paiement : + =select_tag "search[p_payment_type_id]", options_for_select([["",""]]+PPaymentType.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_payment_type_id]) - %td - Soldé ? - =select_tag "search[cc_solded]", options_for_select([[""], "Oui", "Non"], params[:search][:cc_solded]) - - %td - Importé ? - =select_tag "search[imported]", options_for_select([[""], "Oui", "Non"], params[:search][:imported]) + %td + Soldé ? + =select_tag "search[cc_solded]", options_for_select([[""], "Oui", "Non"], params[:search][:cc_solded]) + + %td + Importé ? + =select_tag "search[imported]", options_for_select([[""], "Oui", "Non"], params[:search][:imported]) %table %tr @@ -155,4 +156,4 @@ } - \ No newline at end of file + diff --git a/app/views/admin/price_documents/new.html.haml b/app/views/admin/price_documents/new.html.haml index 995cf0e..c9c0084 100644 --- a/app/views/admin/price_documents/new.html.haml +++ b/app/views/admin/price_documents/new.html.haml @@ -1,10 +1,10 @@ .qi_header %h1 - Documents comptables + Documents %span Ajouter un document -.qi_row=render :partial => "form" \ No newline at end of file +.qi_row=render :partial => "form" From b09b941321fe5be73669eebb82e55c7650d41b08 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Wed, 1 Sep 2021 00:54:56 +0200 Subject: [PATCH 034/121] =?UTF-8?q?Am=C3=A9lioration=20interface=20saisie?= =?UTF-8?q?=20des=20prix=20par=20les=20fournisseurs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consulter le lien avec le token en navigation privée, épuration de l'affichage, méthodes dédiées... --- .../admin/price_documents_controller.rb | 25 ++- .../admin/price_lines_controller.rb | 2 +- app/helpers/translation_helper.rb | 2 +- app/models/price_line.rb | 6 +- .../admin/price_documents/consult.html.haml | 42 +++-- .../price_documents/consult_edit.html.haml | 38 ++++ .../_form_reponse_fournisseur.html.haml | 22 +-- app/views/admin/price_lines/_form.html.haml | 2 +- .../_form_reponse_fournisseur.html.haml | 2 +- .../admin/price_lines/_price_line.html.haml | 6 +- .../_reponse_pane_hover_form.html.haml | 61 +++++++ app/views/admin/price_lines/edit.js.erb | 2 +- app/views/layouts/admin.html.haml | 166 +++++++++--------- config/routes.rb | 7 +- 14 files changed, 264 insertions(+), 119 deletions(-) create mode 100644 app/views/admin/price_documents/consult_edit.html.haml create mode 100644 app/views/admin/price_lines/_reponse_pane_hover_form.html.haml diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 4a079ad..492ed2c 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -2,7 +2,7 @@ class Admin::PriceDocumentsController < ApplicationController layout "admin" - before_action :auth_admin, :except => :print + before_action :auth_admin, :except => [:print, :consult, :consult_create, :consult_edit, :consult_update] before_action :admin_space, :except => :print @@ -267,6 +267,7 @@ class Admin::PriceDocumentsController < ApplicationController def consult + @consult = true @demande = PriceDocument.where(:f_token => params[:id]).first @@ -284,6 +285,28 @@ class Admin::PriceDocumentsController < ApplicationController end + + def consult_create + @consult = true + + @price_document = PriceDocument.new(params.require(:price_document).permit!) + @price_document.date = Date.today + if @price_document.save + redirect_to consult_edit_admin_price_document_path(:id => @price_document.token) + else + render action: "consult" + + end + + end + + + def consult_edit + @consult = true + + @price_document = PriceDocument.where(:token => params[:id]).first + end + def edit @price_document = PriceDocument.find(params[:id]) diff --git a/app/controllers/admin/price_lines_controller.rb b/app/controllers/admin/price_lines_controller.rb index 18930ce..0874893 100644 --- a/app/controllers/admin/price_lines_controller.rb +++ b/app/controllers/admin/price_lines_controller.rb @@ -2,7 +2,7 @@ class Admin::PriceLinesController < ApplicationController layout "admin" - before_action :auth_admin + before_action :auth_admin, :except => [:edit, :update] before_action :admin_space diff --git a/app/helpers/translation_helper.rb b/app/helpers/translation_helper.rb index 9021c6e..a608c96 100755 --- a/app/helpers/translation_helper.rb +++ b/app/helpers/translation_helper.rb @@ -32,7 +32,7 @@ module TranslationHelper content = capture(&block) if block_given? r = "" - if current_admin.id == 1 + if current_admin and current_admin.id == 1 r += "" r += ic(:"stethoscope") if show_icon diff --git a/app/models/price_line.rb b/app/models/price_line.rb index f02360b..840396a 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -17,7 +17,10 @@ class PriceLine < ApplicationRecord :ref => {:name => "Ref", :reorder => true}, :title => {:name => "Désignation", :reorder => true}, :qte => {:name => "Qté", :reorder => true}, + :qte_available => {:name => "Qté dispo.", :reorder => true}, + + :ct_u_price_ht => {:name => "Prix de vente", :reorder => true}, :ref_fournisseur => {:name => "Réf. fournisseur", :reorder => true}, :p_product_power_id => {:name => "Chargeur", :reorder => true}, :p_product_zone_id => {:name => "Zone", :reorder => true}, @@ -26,7 +29,8 @@ class PriceLine < ApplicationRecord :ram_unit => {:name => "Ram unité", :reorder => true}, :eu => {:name => "EU ?", :reorder => true}, :fullkit => {:name => "Fullkit ?", :reorder => true}, - :lang_start => {:name => "Démarrage écran langue ?", :reorder => true} + :lang_start => {:name => "Démarrage écran langue ?", :reorder => true}, + :actions => {:name => "Actions"} } diff --git a/app/views/admin/price_documents/consult.html.haml b/app/views/admin/price_documents/consult.html.haml index bc946db..5554f0f 100644 --- a/app/views/admin/price_documents/consult.html.haml +++ b/app/views/admin/price_documents/consult.html.haml @@ -1,15 +1,24 @@ -.qi_header +-if current_admin + .qi_header - %h1 - Consultation fournisseur - %span - =@demande.list_designaton + %h1 + Consultation fournisseur + %span + =@demande.list_designaton .qi_row - =semantic_form_for [:admin, @price_document], :html => {:class => "qi_price_form"}, :remote => false do |f| + %p{:style => "text-align:center;font-size:1.2em;"} + Vous allez pouvoir répondre à une demande de cotation envoyée par Arcom. + %p{:style => "text-align:center;font-size:1.2em;"} + Pour cela, merci de nous indiquer pour quelle société vous répondez à notre demande de chiffrage. + + + + + =semantic_form_for [:admin, @price_document], :url => consult_create_admin_price_documents_path(), :html => {:class => "qi_price_form"}, :remote => false do |f| -@p_customer = @price_document.p_customer =diag do =f.object.errors.messages @@ -22,24 +31,23 @@ =f.hidden_field :price_document_type_id - = f.input :public_fournisseur_name, :label => "Nom entreprise" + %center= f.input :public_fournisseur_name, :label => "Nom de votre société :" + + %p{:style => "text-align:center;font-size:1.2em;"} + Vous pouvez également indiquer votre référence interne : + + =hidden_field_tag :public_edit, params[:public_edit] - = @price_document.price_line_block.block_type - - + .price_line_block_form =f.semantic_fields_for :price_line_block do |f| - =render :partial => "admin/price_line_blocks/form_#{f.object.block_type_slug}", :locals => {:f => f} + %center=render :partial => "admin/price_line_blocks/form_#{f.object.block_type_slug}", :locals => {:f => f} - - - - - .large_actions - .actions=f.submit "sauvegarder", :class => "btn btn-primary" + %center + =f.submit "sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/price_documents/consult_edit.html.haml b/app/views/admin/price_documents/consult_edit.html.haml new file mode 100644 index 0000000..a031c76 --- /dev/null +++ b/app/views/admin/price_documents/consult_edit.html.haml @@ -0,0 +1,38 @@ + +.qi_row + .qi_pannel.padding + + %table.table.table-striped + %tr + %td + Numéro réponse + + %td + =@price_document.d_number + %tr + %td + Nom fournisseur saisi + %td + =@price_document.public_fournisseur_name + + + +-params[:search][:per_page] = params[:search][:per_page] || 5000 +-per_page = params[:search][:per_page] +-page = (params[:page] and params[:page] != "") ? params[:page] : 1 + +-@price_lines = @price_document.price_line_block.price_lines + + + + +-@price_lines = sort_by_sorting(@price_lines, "created_at DESC") +-@price_lines = @price_lines.page(page).per(per_page) +%br + + + +.clear +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_lines, :key => "reponses-prix-show"} + + diff --git a/app/views/admin/price_line_blocks/_form_reponse_fournisseur.html.haml b/app/views/admin/price_line_blocks/_form_reponse_fournisseur.html.haml index 06bc0c4..15332b8 100644 --- a/app/views/admin/price_line_blocks/_form_reponse_fournisseur.html.haml +++ b/app/views/admin/price_line_blocks/_form_reponse_fournisseur.html.haml @@ -3,17 +3,19 @@ -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") - .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} - - = f.input :p_fournisseur_id, :label => "Fournisseur", :collection => PFournisseur.all, :as => :select, :member_label => :name if @price_document.label == "Réponse fournisseur" and current_admin - = f.input :customer_ref, :label => "Référence cotation fournisseur :" - - - .price_lines_form - =f.semantic_fields_for :price_lines do |f| - =render :partial => "admin/price_lines/form_#{f.object.block_type_slug}", :locals => {:form => f} - %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary"} + + = f.input :p_fournisseur_id, :label => "Fournisseur", :collection => PFournisseur.all, :as => :select, :member_label => :name if @price_document.label == "Réponse fournisseur" and current_admin + = f.input :customer_ref, :label => "Votre référence de cotation :" + + + %div{:style => ("display:none" if !current_admin)} + + .price_lines_form + =f.semantic_fields_for :price_lines do |f| + =render :partial => "admin/price_lines/form_#{f.object.block_type_slug}", :locals => {:form => f} + + %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary"} if current_admin \ No newline at end of file diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 67bd84d..ed95396 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -97,7 +97,7 @@ -else =qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :") - %div{:style => ("display:none;" if !current_admin.has_permission?("customer-sheets-personalised-price"))} + %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"} diff --git a/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml b/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml index 169acc5..bf511fa 100644 --- a/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml +++ b/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml @@ -33,7 +33,7 @@ = form.input :ram, :label => "Ram" %td - = form.input :ram, :label => "Ram unité" + = form.input :ram_unit, :label => "Ram unité" %td diff --git a/app/views/admin/price_lines/_price_line.html.haml b/app/views/admin/price_lines/_price_line.html.haml index 73c945d..4b7dee4 100644 --- a/app/views/admin/price_lines/_price_line.html.haml +++ b/app/views/admin/price_lines/_price_line.html.haml @@ -1,5 +1,7 @@ -%tr#price_document_row{:id => price_line.id} +%tr#price_line_row{:id => price_line.id} -tr = {} - + -tr[:actions] = capture do + %td + =link_to ic(:pencil), edit_admin_price_line_path(price_line), :remote => true =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => price_line} \ No newline at end of file diff --git a/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml b/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml new file mode 100644 index 0000000..4444417 --- /dev/null +++ b/app/views/admin/price_lines/_reponse_pane_hover_form.html.haml @@ -0,0 +1,61 @@ + + +=semantic_form_for [:admin, @price_line], :remote => true do |form| + + .content + Produit : + =form.object.p_product_ref.cc_name if form.object.p_product_ref + %br + Quantité à satisfaire : + =form.object.qte + + %br + %br + + %table.top_td{:style => "width:100%;"} + %tr + + %td + = form.input :p_product_power_id, :label => "Type de chargeur", :collection => PProductPower.all, :include_blank => false, :as => :select + + %td + = form.input :qte_available, :label => "Qté disponible :", :input_html => {:class => "input_price_line_qte"} + + + %td + = form.input :ct_u_price_ht, :label => "Prix vente" + + %td + = form.input :ready_stock, :label => "Ready stock", :as => :select + + %td + = form.input :ram, :label => "Ram" + + %td + = form.input :ram_unit, :label => "Ram unité" + + + %td + = form.input :eu, :label => "EU ?", :as => :select + + + %td + = form.input :p_product_zone_id, :label => "Zone", :collection => PProductZone.all, :include_blank => true, :as => :select + + + + %td + = form.input :fullkit, :label => "Fullkit", :as => :select + + %td + = form.input :lang_start, :label => "Démarage sur l'écran de langue (starting on screen language)", :as => :select + + + + + + + = form.input :comment, :label => "Commentaire", :input_html => {:style => "height:70px;"} + + .actions= form.submit "Sauvegarder", :class => "btn btn-primary" + diff --git a/app/views/admin/price_lines/edit.js.erb b/app/views/admin/price_lines/edit.js.erb index 6c8f015..30200cb 100644 --- a/app/views/admin/price_lines/edit.js.erb +++ b/app/views/admin/price_lines/edit.js.erb @@ -1 +1 @@ -show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file +show_pane_hover("<%= escape_javascript(render(:partial => "reponse_pane_hover_form"))%>",1200,900); \ No newline at end of file diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 23443a3..3fd69a3 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -30,50 +30,51 @@ =link_to image_tag("/logo-presta.png"), "/", :id => "logo" + -if current_admin - -@qi_menus.each do |k,v| + -@qi_menus.each do |k,v| - :scss - #body_#{k.to_s}{ - #admin_nav{ - //background:$big_color_#{k.to_s} !important; - background-color: #{v[:color].to_s} !important; - } + :scss + #body_#{k.to_s}{ + #admin_nav{ + //background:$big_color_#{k.to_s} !important; + background-color: #{v[:color].to_s} !important; + } - } - #big_cat_#{k.to_s}.active, #big_cat_#{k.to_s}:hover{ - //color:$big_color_#{k.to_s} !important; - //background-color: #{v[:color].to_s} !important; - color:white !important; - border-right:4px solid #{v[:color].to_s}; - } + } + #big_cat_#{k.to_s}.active, #big_cat_#{k.to_s}:hover{ + //color:$big_color_#{k.to_s} !important; + //background-color: #{v[:color].to_s} !important; + color:white !important; + border-right:4px solid #{v[:color].to_s}; + } - #big_cat_#{k.to_s}{ - //color:$big_color_#{k.to_s} !important; - color: rgba(white, 0.5) !important; - border-right:4px solid transparent; - } + #big_cat_#{k.to_s}{ + //color:$big_color_#{k.to_s} !important; + color: rgba(white, 0.5) !important; + border-right:4px solid transparent; + } - .bgbd-#{k.to_s}{ - background-color: #{v[:color].to_s} !important; - border-color: #{v[:color].to_s} !important; - } + .bgbd-#{k.to_s}{ + background-color: #{v[:color].to_s} !important; + border-color: #{v[:color].to_s} !important; + } - .element - =link_to v[:link] do - .cat#big_cat{:id => k.to_s} - =ic v[:icon].to_s.to_sym - =v[:name] + .element + =link_to v[:link] do + .cat#big_cat{:id => k.to_s} + =ic v[:icon].to_s.to_sym + =v[:name] .bottom .element - -if current_admin.has_permission?("admins") + -if current_admin and current_admin.has_permission?("admins") =link_to admin_admins_path do .cat#big_cat_preferences =ic :"cog" @@ -90,92 +91,93 @@ %nav#admin_nav.navbar.navbar-expand-lg.navbar-dark.bg-light %button.navbar-toggler{"aria-controls" => "navbarSupportedContent", "aria-expanded" => "false", "aria-label" => "Toggle navigation", "data-target" => "#navbarSupportedContent", "data-toggle" => "collapse", :type => "button"} %span.navbar-toggler-icon - #navbarSupportedContent.collapse.navbar-collapse - %ul.navbar-nav.mr-auto - -if @qi_menu_active - -qi_menu_active = @qi_menus[@qi_menu_active] + -if current_admin + #navbarSupportedContent.collapse.navbar-collapse + %ul.navbar-nav.mr-auto + -if @qi_menu_active + -qi_menu_active = @qi_menus[@qi_menu_active] - -if qi_menu_active[:elements] - -qi_menu_active[:elements].each do |k,v| - %li.nav-item= link_to v[:name], v[:link], :class => "nav-link "+("active" if (@qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)).to_s + -if qi_menu_active[:elements] + -qi_menu_active[:elements].each do |k,v| + %li.nav-item= link_to v[:name], v[:link], :class => "nav-link "+("active" if (@qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)).to_s - %script - =raw '$("#big_cat_'+@qi_menu_active.to_s+'").addClass("active");' + %script + =raw '$("#big_cat_'+@qi_menu_active.to_s+'").addClass("active");' - %form.form-inline.my-2.my-lg-0 - %ul.nav.navbar-nav.navbar-right - %li.nav-item.qi_help_remove{:style => ("display:none" if !session[:qi_helps] )} + %form.form-inline.my-2.my-lg-0 + %ul.nav.navbar-nav.navbar-right + %li.nav-item.qi_help_remove{:style => ("display:none" if !session[:qi_helps] )} - =link_to ic(:"question-circle"), admin_qi_helps_path(), :onclick => '$(".qi_help").hide();$(".qi_help_add").show();$(".qi_help_remove").hide();', :remote => true, :class => "nav-link" + =link_to ic(:"question-circle"), admin_qi_helps_path(), :onclick => '$(".qi_help").hide();$(".qi_help_add").show();$(".qi_help_remove").hide();', :remote => true, :class => "nav-link" - %li.nav-item.qi_help_add{:style => ("display:none" if session[:qi_helps] )} - =link_to ic(:"question-circle-o"), admin_qi_helps_path(:enabled => true), :onclick => '$(".qi_help").show();$(".qi_help_add").hide();$(".qi_help_remove").show();', :remote => true, :class => "nav-link" + %li.nav-item.qi_help_add{:style => ("display:none" if session[:qi_helps] )} + =link_to ic(:"question-circle-o"), admin_qi_helps_path(:enabled => true), :onclick => '$(".qi_help").show();$(".qi_help_add").hide();$(".qi_help_remove").show();', :remote => true, :class => "nav-link" - -if session[:qi_helps] - :scss - .qi_help{ - display:inherit; + -if session[:qi_helps] + :scss + .qi_help{ + display:inherit; + + } + -else + :scss + .qi_help{ + display:none; } - -else - :scss - .qi_help{ - display:none; - - } - %li.nav-item.qi_stat_remove{:style => ("display:none" if !session[:qi_stats] )} + %li.nav-item.qi_stat_remove{:style => ("display:none" if !session[:qi_stats] )} - =link_to raw(""+ic(:"pie-chart")+""), admin_qi_stats_path(), :onclick => '$(".qi_stat, .qi_kpi").show();$(".qi_stat_add").show();$(".qi_stat_remove").hide();', :remote => true, :class => "nav-link" + =link_to raw(""+ic(:"pie-chart")+""), admin_qi_stats_path(), :onclick => '$(".qi_stat, .qi_kpi").show();$(".qi_stat_add").show();$(".qi_stat_remove").hide();', :remote => true, :class => "nav-link" - %li.nav-item.qi_stat_add{:style => ("display:none" if session[:qi_stats] )} - =link_to ic(:"pie-chart"), admin_qi_stats_path(:enabled => true), :onclick => '$(".qi_stat, .qi_kpi").hide();$(".qi_stat_add").hide();$(".qi_stat_remove").show();', :remote => true, :class => "nav-link" + %li.nav-item.qi_stat_add{:style => ("display:none" if session[:qi_stats] )} + =link_to ic(:"pie-chart"), admin_qi_stats_path(:enabled => true), :onclick => '$(".qi_stat, .qi_kpi").hide();$(".qi_stat_add").hide();$(".qi_stat_remove").show();', :remote => true, :class => "nav-link" - -if session[:qi_stats] - :scss - .qi_stat, .qi_kpi{ - display:none; - - } - - -else - :scss - .qi_stat, .qi_kpi{ - display:inherit; + -if session[:qi_stats] + :scss + .qi_stat, .qi_kpi{ + display:none; } + -else + :scss + .qi_stat, .qi_kpi{ + display:inherit; + + } + - %li.nav-item.dropdown - %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"} - =current_admin.firstname - =current_admin.name + %li.nav-item.dropdown + %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"} + =current_admin.firstname + =current_admin.name - .dropdown-menu{"aria-labelledby" => "navbarDropdown"} - = link_to "Gestion des admins", admin_admins_path, :class => "dropdown-item" if current_admin.super_admin - .dropdown-divider - =link_to "Se déconnecter", admin_admin_auth_path(1), method: :delete, :class => "dropdown-item" + .dropdown-menu{"aria-labelledby" => "navbarDropdown"} + = link_to "Gestion des admins", admin_admins_path, :class => "dropdown-item" if current_admin.super_admin + .dropdown-divider + =link_to "Se déconnecter", admin_admin_auth_path(1), method: :delete, :class => "dropdown-item" - -if super_current_admin - %li.nav-item - =link_to ic(:"user-secret"), admin_admins_path, :class => "nav-link" + -if super_current_admin + %li.nav-item + =link_to ic(:"user-secret"), admin_admins_path, :class => "nav-link" - %li.nav-item - =link_to ic(:refresh), "#", :onclick => "location.reload();", :class => "nav-link" + %li.nav-item + =link_to ic(:refresh), "#", :onclick => "location.reload();", :class => "nav-link" diff --git a/config/routes.rb b/config/routes.rb index cdc0dc1..2ec3aac 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -612,10 +612,15 @@ Rails.application.routes.draw do get :consult post :consult_save + post :consult_create + get :consult_edit + put :consult_update + end collection do get :search_to_affect - + post :consult_create + end end end From 4de195ad5f565bbee1ec9d6e6dca0c69333a3bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 1 Sep 2021 08:53:56 +0200 Subject: [PATCH 035/121] details hide by default --- app/views/admin/buy_lists/index.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 8274a67..3c91d27 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -263,6 +263,7 @@ } :javascript + $('.detail').hide() $('.plus').click(function(event){ console.log(event.currentTarget); $(event.currentTarget).parent().parent().next('tbody.detail').toggle(); From f360c0d0045d36d574c9701526e5932fd851a9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 1 Sep 2021 09:55:14 +0200 Subject: [PATCH 036/121] update mask --- app/views/admin/buy_lists/index.html.haml | 76 ++++++++++++++--------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 3c91d27..bc45103 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -60,7 +60,7 @@ =#render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_customer_sheets} --nbr_td = 15 +-nbr_td = 10 .qi_pannel.padding.new_table_container .table-slider @@ -79,22 +79,23 @@ %tr -if checkbox %th + %th.mask.plus-all + =link_to ic("plus-square-o"), '#' %th Produit %th Référence / %th Qté - %th.mask - =ic("plus-square-o") - %th.mask + %th.mask.col-detail N° Commande - %th.mask + %th.mask.col-detail Client - %th.mask + %th.mask.col-detail Statut - %th.mask Date saisie - %th.mask Date validation + %th.mask.col-detail Commentaire + %th.mask.col-detail Date saisie + %th.mask.col-detail Date validation %th.mask Date livraison (ETA) %th.mask @@ -103,7 +104,6 @@ Qté en stock %th.mask Qté souhaité - %th.mask Commentaire %th.mask BPA %th.mask AV BPA %th.mask PAS BPA @@ -118,11 +118,14 @@ -if p_product_id != plr.p_product_id -p_product_id = plr.p_product_id %tr.prdct_tr - -nbr_td.times.each do + -nbr_td.times.each do %td - - - + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail @@ -131,6 +134,8 @@ -if checkbox %td + %td.plus + =link_to ic("plus-square-o"), "#" %td =link_to plr.p_product_ref.p_product.name, [:admin, plr.p_product_ref] %td @@ -138,16 +143,15 @@ =plr.p_product_ref.ct_sub_name =plr.p_product_ref.p_product_color.name if plr.p_product_ref.p_product_color - %td.plus - =link_to ic("plus-square-o"), "#" - %td - - - %td.mask + %td.col-detail + + + %td.mask.col-detail / %td.mask - %td.mask - %td.mask - %td.mask + %td.mask.col-detail + %td.mask.col-detail + %td.mask.col-detail + %td.mask.col-detail %td.mask %td.mask ∑ @@ -165,9 +169,7 @@ %td.mask =text_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input" - %td.mask - - + %td.mask =ppr_lines.where(:cc_state => "BPA").sum(:qte).to_i %td.mask @@ -177,7 +179,7 @@ %tbody.detail -ppr_lines.each do |price_line| - %tr.details + %tr - if checkbox %td =check_box_tag :"price_line_ids[]", price_line.id @@ -185,19 +187,21 @@ %td %td %td - %td + %td.col-detail =link_to [:admin, price_line.price_line_block.price_lineable] do =price_line.price_line_block.price_lineable.id =price_line.price_line_block.price_lineable.past_id - %td + %td.col-detail =link_to price_line.p_customer.show_name, [:admin, price_line.p_customer] %td =state_helper price_line.price_line_block.price_lineable.state + %td + =price_line.comment %td = l price_line.cc_creation_date, :format => :short_date @@ -213,8 +217,6 @@ %td - %td - =price_line.comment %td =price_line.qte.to_i if price_line.cc_state == "BPA" @@ -230,6 +232,12 @@ %tr -nbr_td.times.each do %td + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail + %td.col-detail =submit_tag "Créer une demande de prix", :class => "btn btn-primary" @@ -264,11 +272,19 @@ :javascript $('.detail').hide() + $('.col-detail').hide() $('.plus').click(function(event){ + $('.col-detail').toggle() console.log(event.currentTarget); $(event.currentTarget).parent().parent().next('tbody.detail').toggle(); $(event.currentTarget).find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o') }); + $('.plus-all').click(function(event){ + $('.col-detail').toggle() + $('tbody.detail').toggle(); + $(event.currentTarget).find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o') + $('.plus').find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o') + }); From 25a2c24b1aedc8eb3907c9de70137c16039cea09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 1 Sep 2021 18:45:43 +0200 Subject: [PATCH 037/121] Match fournisseur --- .../admin/price_documents_controller.rb | 3 +++ .../_form_p_fournisseur.html.haml | 16 ++++++++++++++++ .../match_p_fournisseur.html.haml | 1 + .../price_documents/match_p_fournisseur.js.erb | 1 + config/routes.rb | 2 +- 5 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 app/views/admin/price_documents/_form_p_fournisseur.html.haml create mode 100644 app/views/admin/price_documents/match_p_fournisseur.html.haml create mode 100644 app/views/admin/price_documents/match_p_fournisseur.js.erb diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 492ed2c..2aed63a 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -595,5 +595,8 @@ class Admin::PriceDocumentsController < ApplicationController end + def match_p_fournisseur + @price_document = PriceDocument.find(params[:id]) + end end diff --git a/app/views/admin/price_documents/_form_p_fournisseur.html.haml b/app/views/admin/price_documents/_form_p_fournisseur.html.haml new file mode 100644 index 0000000..3514749 --- /dev/null +++ b/app/views/admin/price_documents/_form_p_fournisseur.html.haml @@ -0,0 +1,16 @@ +=semantic_form_for [:admin, @price_document], :html => {:class => "qi_price_form"}, :remote => false do |f| + =diag do + =f.object.errors.messages + + .content + %h1.mb-2 Rapprochemnet du fournisseur + .form-row + .col-md-6 + = f.input :public_fournisseur_name, label: "Nom indiqué par le fournisseur :", :input_html => { :disabled => true, class: "mx-3" } + .form-row + .col-md-6 + =f.semantic_fields_for :price_line_block do |form| + =form.input :p_fournisseur, as: :select, collection: PFournisseur.pluck(:name, :id), label: "Correspondance base fournisseurs :", :input_html => { class: "mx-3"} + + .large_actions + .actions=f.submit "sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/price_documents/match_p_fournisseur.html.haml b/app/views/admin/price_documents/match_p_fournisseur.html.haml new file mode 100644 index 0000000..ee81044 --- /dev/null +++ b/app/views/admin/price_documents/match_p_fournisseur.html.haml @@ -0,0 +1 @@ +.qi_row=render :partial => "form_p_fournisseur" diff --git a/app/views/admin/price_documents/match_p_fournisseur.js.erb b/app/views/admin/price_documents/match_p_fournisseur.js.erb new file mode 100644 index 0000000..aca251b --- /dev/null +++ b/app/views/admin/price_documents/match_p_fournisseur.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form_p_fournisseur"))%>",700,900); diff --git a/config/routes.rb b/config/routes.rb index 2ec3aac..f511c3a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -615,7 +615,7 @@ Rails.application.routes.draw do post :consult_create get :consult_edit put :consult_update - + get :match_p_fournisseur end collection do get :search_to_affect From 470ae0edf6a1c92e68b763826f6f75519ddea0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 1 Sep 2021 18:46:55 +0200 Subject: [PATCH 038/121] analyse reponse --- .../admin/price_documents_controller.rb | 7 +- app/models/price_line.rb | 1 + app/models/price_line_block.rb | 2 +- .../analyse_reponses.html.haml | 175 ++++++++++++++++++ .../admin/price_documents/show.html.haml | 8 +- config/routes.rb | 1 + 6 files changed, 189 insertions(+), 5 deletions(-) create mode 100644 app/views/admin/price_documents/analyse_reponses.html.haml diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 2aed63a..b480168 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -598,5 +598,10 @@ class Admin::PriceDocumentsController < ApplicationController def match_p_fournisseur @price_document = PriceDocument.find(params[:id]) end - + + def analyse_reponses + @price_document = PriceDocument.find(params[:id]) + @price_document_responses = PriceDocument.where(:doc_ref_id => @price_document.id ) + + end end diff --git a/app/models/price_line.rb b/app/models/price_line.rb index 840396a..1d56221 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -2,6 +2,7 @@ class PriceLine < ApplicationRecord belongs_to :price_line_block belongs_to :p_product belongs_to :p_product_ref + belongs_to :p_product_power default_scope { order('position ASC') } validates :p_product_ref_id, :presence => true, :if => :p_product_ref_needed? diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index c116b7c..14b7469 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -27,7 +27,7 @@ class PriceLineBlock < ApplicationRecord SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] belongs_to :p_fournisseur - + accepts_nested_attributes_for :p_fournisseur def to_no_archive if self.imported diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml new file mode 100644 index 0000000..49acb65 --- /dev/null +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -0,0 +1,175 @@ +.qi_header + %h1 + Achats + %span + Analyse des réponces à la consiltation n° + = link_to @price_document.d_number, admin_price_document_path(@price_document) + \- + = @price_document.list_designaton + + + +.qi_pannel.padding.new_table_container + .table-slider + .inner + + .table-area{:style => "overflow:auto;"} + .table-area-inner + .freezeTable + %table.table.table-striped.table-hover.table-bordered.data_table + %thead.header + %tr + -nb_resp = @price_document_responses.count + %th{colspan: 12} + Consultation + %th{colspan: nb_resp} + Fournisseurs + + %tr + %th + Qté à + %br + satisfaire + %th + Qté consultée + %th + Produit + %th + Référence + %th + Couleur + %th + Type + %br + chargeur + %th + Target hors + %br + Sorecop + %th + Px d'achat + %br + référence + %th + Marge + %br + théorique + %br + référence + %br + par zone + %th + Fours. + %br + de référence + %th + Date + %br + px référence + %th.limit + Spec + + -@price_document_responses.each do |resp| + %th + =resp.p_fournisseur.name + + + %tbody + -price_lines = @price_document.price_line_block.price_lines + -consult_price_lines = @price_document.price_line_block.price_lines + -price_lines.each do |price_line| + %tr + %td + =# ATTENTION ! On a plus accès direct aux commandes qui on engendré cette demande de prix. donc plus accès aux délais différent entre les différentes commades pour une ref donée + ∑ + =price_line.qte.to_i + %br + - if price_line.cc_wish_date.present? && price_line.cc_wish_date < Date.today + 10.days + %span.red + =ic(:fire) + =price_line.qte.to_i + - else + %span.darkblue + =ic(:hourglass) + =price_line.qte.to_i + %td.ref_tr + Qté en comm + %td + = price_line.p_product_ref.p_product.name + %td + =link_to [:admin, price_line.p_product_ref] do + = price_line.p_product_ref.ct_sub_name + = price_line.p_product_ref.p_product_color.name + + %td + = price_line.p_product_ref.p_product_color.color + %td + = price_line.p_product_power.name + %td + / Target hors Sorecop + %td + / Px d'achat de référence + %td + / Marge théorique de référence par zone + %td + / Fournisseurs de référence + %td + / Date du px de référence + %td + / spec + - @price_document_responses.each do |resp| + -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first + -cell = [] + + - if line.qte_available.to_i > 0 + -if line.qte_available >= price_line.qte.to_i + - cell << "Qté dispo : #{line.qte_available.to_i}" + -else + - cell << "#{ic(:warning, class: "orange")} Qté dispo : #{line.qte_available.to_i} (#{line.qte_available.to_i - price_line.qte.to_i})" + - cell << "PA: #{line.ct_u_price_ht} €" + - # mp = calcul de la marge prévisionelle TODO + - line.id.odd? ? mp = 0.17 : mp = 0.11 + -cell << line.id.odd? + - if mp.present? + -if mp > 0.15 + - cell << "#{ic(:check)} MP: #{mp * 100} %" + -else + - cell << "#{ic(:times, class: "red")} MP: #{mp * 100} %" + -else + - cell << "pas dispo" + -if line.comment.present? + - cell << "#{ic('info-circle')} #{line.comment}" + %td + =sanitize(cell.join('
')) + + + + + + + + +:scss + .limit { + border-right:3px solid green !important; + } + + .red { + color: red; + } + .green { + color: green; + } + .orange { + color: orange; + } + .darkgrey { + color: #darkgrey; + } + .darkblue { + color: darkblue; + } + + .small-input { + max-width: 100px; + } diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 3178d8e..c1be467 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -1,6 +1,8 @@ .qi_header - .right - + .right + -if @price_document.price_document_type_id == 1 + =link_to ic("bar-chart")+" analyse des réponses", analyse_reponses_admin_price_document_path(@price_document), class: "btn btn-primary" + -if @price_document.price_document_type_id == 6 and !@price_document.stock_ok = link_to i(:pencil), edit_admin_price_document_path(:id => @price_document.id, :public_edit => true) if !@price_document.stock_ok @@ -50,7 +52,7 @@ %td Avancement (%) %td - =@price_document.avancement + =@price_document.avancement.to_s + " %" %tr %td Désignation diff --git a/config/routes.rb b/config/routes.rb index f511c3a..a0c1e29 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -616,6 +616,7 @@ Rails.application.routes.draw do get :consult_edit put :consult_update get :match_p_fournisseur + get :analyse_reponses end collection do get :search_to_affect From 1dbe4a100c4354cf6d66a550995caf271bdca0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 1 Sep 2021 18:48:26 +0200 Subject: [PATCH 039/121] index update for response --- app/models/price_document.rb | 3 +- .../price_documents/_price_document.html.haml | 35 +++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/models/price_document.rb b/app/models/price_document.rb index 6328710..07c348c 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -271,7 +271,8 @@ class PriceDocument < ApplicationRecord :end_date => {:name => "Fin de consultation", :reorder => true}, :dp_comment => {:name => "Commentaire", :reorder => true}, :acheteur_text => {:name => "Envoyé à", :reorder => true}, - + :customer_ref => {:name => "Ref cotation", :reorder => false}, + :p_commercial => {:name => "Commercial", :reorder => false}, :p_customer => {:name => "Client", :reorder => false}, diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index 923ddb6..f8e14de 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -1,4 +1,7 @@ %tr#price_document_row{:id => price_document.id} + - if price_document.doc_ref_id.present? + - parent_doc = PriceDocument.find(price_document.doc_ref_id) + -tr = {} -tr[:p_payment_type] = capture do @@ -17,7 +20,13 @@ -tr[:p_fournisseur] = capture do %td - = price_document.p_fournisseur.name if price_document.p_fournisseur + - if price_document.price_document_type_id == 2 + -if price_document.p_fournisseur.present? + = price_document.p_fournisseur.name + - else + =link_to ic('pencil') + " rapprocher le fournisseur", match_p_fournisseur_admin_price_document_path(price_document), remote: true + -else + = price_document.p_fournisseur.name if price_document.p_fournisseur -tr[:com_counter] = capture do %td @@ -58,8 +67,30 @@ %td - if price_document.avancement = price_document.avancement.to_s + " %" + - elsif parent_doc.avancement + = parent_doc.avancement.to_s + " %" + + -tr[:list_designaton] = capture do + %td + = price_document.list_designaton || parent_doc.list_designaton + + -tr[:end_date] = capture do + %td + = price_document.end_date || parent_doc.end_date + + -tr[:dp_comment] = capture do + %td + = price_document.dp_comment || parent_doc.dp_comment + + -tr[:acheteur_text] = capture do + %td + = price_document.acheteur_text || parent_doc.acheteur_text + + -tr[:customer_ref] = capture do + %td + -if price_document.price_line_block.present? + = price_document.price_line_block.customer_ref - -tr[:stock_ok] = capture do %td -if !price_document.imported From 26755a6ab4315489cc1d4b310fe5568f45ed81db Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Wed, 1 Sep 2021 22:49:59 +0200 Subject: [PATCH 040/121] Minor bugfixes --- .../admin/price_documents/_price_document.html.haml | 11 +++++++++-- .../admin/price_documents/analyse_reponses.html.haml | 4 ++-- app/views/layouts/admin.html.haml | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index f8e14de..fc12909 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -1,6 +1,8 @@ %tr#price_document_row{:id => price_document.id} - if price_document.doc_ref_id.present? - parent_doc = PriceDocument.find(price_document.doc_ref_id) + -else + - parent_doc = nil -tr = {} @@ -26,7 +28,7 @@ - else =link_to ic('pencil') + " rapprocher le fournisseur", match_p_fournisseur_admin_price_document_path(price_document), remote: true -else - = price_document.p_fournisseur.name if price_document.p_fournisseur + = price_document.p_fournisseur.name if price_document.p_fournisseur -tr[:com_counter] = capture do %td @@ -76,7 +78,12 @@ -tr[:end_date] = capture do %td - = price_document.end_date || parent_doc.end_date + -if price_document.end_date + =price_document.end_date + + -elsif parent_doc and parent_doc.end_date + =parent_doc.end_date + -tr[:dp_comment] = capture do %td diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 49acb65..1d8c066 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -102,9 +102,9 @@ = price_line.p_product_ref.p_product_color.name %td - = price_line.p_product_ref.p_product_color.color + = price_line.p_product_ref.p_product_color.color if price_line.p_product_ref and price_line.p_product_ref.p_product_color %td - = price_line.p_product_power.name + = price_line.p_product_power.name if price_line.p_product_power %td / Target hors Sorecop %td diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 3fd69a3..3096c58 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -27,7 +27,7 @@ %body.admin{:id => "body_#{@qi_menu_active}"} #right_bar - =link_to image_tag("/logo-presta.png"), "/", :id => "logo" + =link_to image_tag("/logo-arcom.png"), "/", :id => "logo" -if current_admin From f27cf5378d8980735cef662587910ef63c7cfd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 3 Sep 2021 11:28:59 +0200 Subject: [PATCH 041/121] extract navbar + auto dropdown --- app/controllers/application_controller.rb | 6 +- app/views/layouts/_navbar.haml | 77 ++++++++++++++++++ app/views/layouts/admin.html.haml | 97 +---------------------- 3 files changed, 83 insertions(+), 97 deletions(-) create mode 100644 app/views/layouts/_navbar.haml diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 63ae755..f0ed23e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base before_action :init_admin_menu before_action :qi_menu + before_action :set_navbar_dropdown def qi_menu(sym=nil) @@ -499,7 +500,10 @@ class ApplicationController < ActionController::Base end - + def set_navbar_dropdown + @dropdown_elements = [:p_product_cats, :s_brands, :p_product_colors, :p_article_serial_nums, :p_serial_num_types, :p_product_ref_specs, :p_spec_values, :p_grades, :p_product_powers, :p_product_zones] + @dropdown_title = "Parametrage" + end end diff --git a/app/views/layouts/_navbar.haml b/app/views/layouts/_navbar.haml new file mode 100644 index 0000000..1ca0db6 --- /dev/null +++ b/app/views/layouts/_navbar.haml @@ -0,0 +1,77 @@ +#qi_header_wrapper.fh-fixedHeader + %nav#admin_nav.navbar.navbar-expand-lg.navbar-dark.bg-light + %button.navbar-toggler{"type" => "button", "data-toggle" => "collapse", "data-target" => "#navbarSupportedContent", "aria-controls" => "navbarSupportedContent", "aria-expanded" => "false", "aria-label" => "Toggle navigation"} + %span.navbar-toggler-icon + #navbarSupportedContent.collapse.navbar-collapse + %ul.navbar-nav.mr-auto + -if @qi_menu_active + -qi_menu_active = @qi_menus[@qi_menu_active] + + -if qi_menu_active[:elements] + -qi_menu_active[:elements].each do |k,v| + -if !@dropdown_elements.include?(k) + %li.nav-item{class: ("active" if @qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)} + =link_to v[:name], v[:link], :class => "nav-link" + -intersect = @dropdown_elements.&(qi_menu_active[:elements].keys) + -if intersect.any? + %li.nav-item.dropdown + =link_to @dropdown_title, '#', class: "nav-link dropdown-toggle", id: "navbarDropdown", "role" => "button", "data-toggle" => "dropdown", "aria-haspopup" => "true", "aria-expanded" => "false" + %ul.dropdown-menu{"aria-labelledby" => "navbarDropdown"} + -qi_menu_active[:elements].each do |k,v| + -if @dropdown_elements.include?(k) + %li=link_to v[:name], v[:link], :class => "dropdown-item"+(" active" if (@qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)).to_s + + + + + / =qi_menu_active[:elements].each do |k,v| + / %li.dropdown-item=link_to v[:name], v[:link], :class => "nav-link "+("active" if (@qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)).to_s + / %li.nav-item= link_to v[:name], v[:link], :class => "nav-link "+("active" if (@qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)).to_s + + + + %ul.nav.navbar-nav.navbar-right.ml-auto + %li.nav-item.qi_help_remove{:style => ("display:none" if !session[:qi_helps] )} + + =link_to ic(:"question-circle"), admin_qi_helps_path(), :onclick => '$(".qi_help").hide();$(".qi_help_add").show();$(".qi_help_remove").hide();', :remote => true, :class => "nav-link" + + + %li.nav-item.qi_help_add{:style => ("display:none" if session[:qi_helps] )} + =link_to ic(:"question-circle-o"), admin_qi_helps_path(:enabled => true), :onclick => '$(".qi_help").show();$(".qi_help_add").hide();$(".qi_help_remove").show();', :remote => true, :class => "nav-link" + + + + -if session[:qi_helps] + :scss + .qi_help{ + display:inherit; + + } + -else + :scss + .qi_help{ + display:none; + + } + + + %li.nav-item.dropdown + %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"} + =current_admin.firstname + =current_admin.name + + + .dropdown-menu{"aria-labelledby" => "navbarDropdown"} + = link_to "Gestion des admins", admin_admins_path, :class => "dropdown-item" if current_admin.super_admin + .dropdown-divider + =link_to "Se déconnecter", admin_admin_auth_path(1), method: :delete, :class => "dropdown-item" + + + + + %li.nav-item + =link_to ic(:refresh), "#", :onclick => "location.reload();", :class => "nav-link" + + + + = yield :header diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 3096c58..dc31319 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -86,104 +86,9 @@ - #qi_header_wrapper.fh-fixedHeader - %nav#admin_nav.navbar.navbar-expand-lg.navbar-dark.bg-light - %button.navbar-toggler{"aria-controls" => "navbarSupportedContent", "aria-expanded" => "false", "aria-label" => "Toggle navigation", "data-target" => "#navbarSupportedContent", "data-toggle" => "collapse", :type => "button"} - %span.navbar-toggler-icon - -if current_admin - #navbarSupportedContent.collapse.navbar-collapse - %ul.navbar-nav.mr-auto - -if @qi_menu_active - -qi_menu_active = @qi_menus[@qi_menu_active] - - -if qi_menu_active[:elements] - -qi_menu_active[:elements].each do |k,v| - %li.nav-item= link_to v[:name], v[:link], :class => "nav-link "+("active" if (@qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)).to_s - - %script - =raw '$("#big_cat_'+@qi_menu_active.to_s+'").addClass("active");' - - - - %form.form-inline.my-2.my-lg-0 - %ul.nav.navbar-nav.navbar-right - %li.nav-item.qi_help_remove{:style => ("display:none" if !session[:qi_helps] )} - - =link_to ic(:"question-circle"), admin_qi_helps_path(), :onclick => '$(".qi_help").hide();$(".qi_help_add").show();$(".qi_help_remove").hide();', :remote => true, :class => "nav-link" - - - %li.nav-item.qi_help_add{:style => ("display:none" if session[:qi_helps] )} - =link_to ic(:"question-circle-o"), admin_qi_helps_path(:enabled => true), :onclick => '$(".qi_help").show();$(".qi_help_add").hide();$(".qi_help_remove").show();', :remote => true, :class => "nav-link" - + =render partial: "layouts/navbar" - - -if session[:qi_helps] - :scss - .qi_help{ - display:inherit; - - } - -else - :scss - .qi_help{ - display:none; - - } - - - - - %li.nav-item.qi_stat_remove{:style => ("display:none" if !session[:qi_stats] )} - - =link_to raw(""+ic(:"pie-chart")+""), admin_qi_stats_path(), :onclick => '$(".qi_stat, .qi_kpi").show();$(".qi_stat_add").show();$(".qi_stat_remove").hide();', :remote => true, :class => "nav-link" - - - %li.nav-item.qi_stat_add{:style => ("display:none" if session[:qi_stats] )} - =link_to ic(:"pie-chart"), admin_qi_stats_path(:enabled => true), :onclick => '$(".qi_stat, .qi_kpi").hide();$(".qi_stat_add").hide();$(".qi_stat_remove").show();', :remote => true, :class => "nav-link" - - - - -if session[:qi_stats] - :scss - .qi_stat, .qi_kpi{ - display:none; - - } - - -else - :scss - .qi_stat, .qi_kpi{ - display:inherit; - - } - - - - %li.nav-item.dropdown - %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"} - =current_admin.firstname - =current_admin.name - - - .dropdown-menu{"aria-labelledby" => "navbarDropdown"} - = link_to "Gestion des admins", admin_admins_path, :class => "dropdown-item" if current_admin.super_admin - .dropdown-divider - =link_to "Se déconnecter", admin_admin_auth_path(1), method: :delete, :class => "dropdown-item" - - -if super_current_admin - %li.nav-item - =link_to ic(:"user-secret"), admin_admins_path, :class => "nav-link" - - - %li.nav-item - =link_to ic(:refresh), "#", :onclick => "location.reload();", :class => "nav-link" - - - - - - = yield :header From a334469ac0469b45db4d649df0d1d69a322e0ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 3 Sep 2021 17:30:40 +0200 Subject: [PATCH 042/121] Upgrade UX for new customersheet --- app/helpers/document_line_helper.rb | 2 +- .../admin/p_customer_sheets/_form.html.haml | 31 ++-- .../admin/price_line_blocks/_form.html.haml | 151 +++++++++--------- app/views/admin/price_lines/_form.html.haml | 11 +- 4 files changed, 96 insertions(+), 99 deletions(-) diff --git a/app/helpers/document_line_helper.rb b/app/helpers/document_line_helper.rb index 6dbbc93..8066e11 100644 --- a/app/helpers/document_line_helper.rb +++ b/app/helpers/document_line_helper.rb @@ -34,7 +34,7 @@ module DocumentLineHelper end end - link_to name,"#", :onclick => "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\");return false;", :class => (options[:class]) + link_to name,"#", :onclick => "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\");return false;", :class => (options[:class]), tabindex: options[:tabindex], style: options[:style] end end diff --git a/app/views/admin/p_customer_sheets/_form.html.haml b/app/views/admin/p_customer_sheets/_form.html.haml index c8c82b9..56f16a6 100755 --- a/app/views/admin/p_customer_sheets/_form.html.haml +++ b/app/views/admin/p_customer_sheets/_form.html.haml @@ -1,22 +1,25 @@ =semantic_form_for [:admin, @p_customer_sheet], :html => {:class => "qi_price_form"}, :remote => false do |form| - + =form.semantic_fields_for :price_line_block do |f| + =render :partial => "admin/price_line_blocks/form", :locals => {:f => f} + .content .qi_row - .qi_pannel.qi_plain.padding - -if @p_customer_sheet and @p_customer_sheet.state != "commande" - =#form.input :demande_type, :collection => ["Brouillon", "Demande de bon de commande","Demande de devis"], :as => :select, :include_blank => false, :label => "Type de demande :" - - =form.input :state, :collection => ["AV BPA", "PAS BPA","BPA", "Traitée"], :as => :select, :include_blank => false, :label => "Statut :" - - =form.input :past_id, :label => "N° système actuel" - - .price_line_block_form - =form.semantic_fields_for :price_line_block do |f| - =render :partial => "admin/price_line_blocks/form", :locals => {:f => f} + .qi_pannel.qi_plain.padding.row + .col-2 + -if @p_customer_sheet and @p_customer_sheet.state != "commande" + =#form.input :demande_type, :collection => ["Brouillon", "Demande de bon de commande","Demande de devis"], :as => :select, :include_blank => false, :label => "Type de demande :" + + =form.input :state, :collection => ["AV BPA", "PAS BPA","BPA", "Traitée"], :as => :select, :include_blank => false, :label => "Statut :" + + =form.input :past_id, :label => "N° système actuel" + =yield :discount + .col-2 + =yield :shipping_date + .col-8 + =yield :particular - - + =yield :price_lines .right.actions =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" diff --git a/app/views/admin/price_line_blocks/_form.html.haml b/app/views/admin/price_line_blocks/_form.html.haml index e945168..20b07b9 100644 --- a/app/views/admin/price_line_blocks/_form.html.haml +++ b/app/views/admin/price_line_blocks/_form.html.haml @@ -1,104 +1,97 @@ -.qi_row - =f.inputs do +=f.inputs do + + + -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") + + = f.hidden_field :p_customer_id, :class => "p_customer_id" + =content_for :particular do + .row + .p_customer_sheet_customer.col-12.mb-4 - -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") - .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} - - = f.hidden_field :p_customer_id, :class => "p_customer_id" - - .p_customer_sheet_customer - - -if f.object.p_customer and f.object.p_customer.particular =render :partial => "admin/p_customers/apercu", :locals => {:particular => f.object.p_customer.particular} - .padding{:style => "padding:0 10px;"} + .col-6 .addresses.row .columns.span_6 - %h3 Adresse de facturation - + %h4 Adresse de facturation + -if f.object.p_customer =f.inputs do = f.input :particular_bill_id, :collection => f.object.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de facturation" -else =f.inputs do = f.input :particular_bill_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation" - + .col-6 + .addresses.row .columns.span_6 - %h3 Adresse de livraison - + %h4 Adresse de livraison + -if f.object.p_customer =f.inputs do = f.input :particular_send_id, :collection => f.object.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de livraison" -else =f.inputs do = f.input :particular_send_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation" - + .clear - - - %table{:style => "width:100%;"} - %tr - %td{:style => "width:33%;"} - = f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date - - %td{:style => "width:33%;"} - = f.input :ct_creation_date, :label => "Date de commande (si différente de la date de création) :", :as => :date - - %td{:style => "width:33%;"} - = f.input :validation_date, :label => "Date de validation :", :as => :date - - - = f.input :customer_ref, :label => "Référence commande client :" - -if current_admin.has_permission?("customer-sheets-bl") - =# f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"} - - -if @p_customer_sheet and @p_customer_sheet.p_customer and @p_customer_sheet.p_customer.p_customer_sheet_note? - %div - %strong Notes pour les demandes de commandes pour ce client : - =simple_format @p_customer_sheet.p_customer.p_customer_sheet_note - %br - - - - - .price_lines_form - =f.semantic_fields_for :price_lines do |f| - =render :partial => "admin/price_lines/form", :locals => {:form => f} - - %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary"} - - - -if current_admin.has_permission?("payments") - .qi_pannel.qi_plain.padding.price_line_block_footer{:style => "margin:20px 0;"} - - -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") - -if !@avoir - = f.input :ct_tot_discount_percent, :label => "Réduction pied de page (%) :", :input_html => {:class => "input_price_line_block_ct_tot_discount_percent"} - = f.input :ct_tot_fdp_ht, :label => "Frais de port personnalisés :" - - - -if current_admin.has_permission?("payments") + =content_for :shipping_date do + = f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date + = f.input :ct_creation_date, :label => "Date de commande (si différente de la date de création) :", :as => :date + = f.input :validation_date, :label => "Date de validation :", :as => :date + + + + = f.input :customer_ref, :label => "Référence commande client :" + -if current_admin.has_permission?("customer-sheets-bl") + =# f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"} + + -if @p_customer_sheet and @p_customer_sheet.p_customer and @p_customer_sheet.p_customer.p_customer_sheet_note? + %div + %strong Notes pour les demandes de commandes pour ce client : + =simple_format @p_customer_sheet.p_customer.p_customer_sheet_note + %br + + + + =content_for :price_lines do + .row + .price_lines_form.col-11.row + =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"} + + + -if current_admin.has_permission?("payments") + =content_for :discount do -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") - - if f.object.id - .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} - %h4 Paiements - - = f.input :p_payment_type_id, :label => "Type de paiement :", :include_blank => false, :collection => PPaymentType.order(:name).all, :as => :select, :input_html => {:id => "payment_type_id_select"} - + -if !@avoir + = f.input :ct_tot_discount_percent, :label => "Réduction pied de page (%) :", :input_html => {:class => "input_price_line_block_ct_tot_discount_percent"} + = f.input :ct_tot_fdp_ht, :label => "Frais de port personnalisés :" + + + -if current_admin.has_permission?("payments") + -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") + - if f.object.id + .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} + %h4 Paiements + + = f.input :p_payment_type_id, :label => "Type de paiement :", :include_blank => false, :collection => PPaymentType.order(:name).all, :as => :select, :input_html => {:id => "payment_type_id_select"} + + + = f.input :ct_payment_comptant, :label => "Paiement comptant nécessaire ?" + + -if false + = f.input :ct_acompte, :label => "Acompte nécessaire ?" + = f.input :ct_acompte_percent, :label => "Pourcentage d'acompte :" + + = f.input :ct_payment_delais, :label => "Délais jour de paiement :" + + -if false + = f.input :ct_payment_month_end, :label => "Fin de mois ?" + - = f.input :ct_payment_comptant, :label => "Paiement comptant nécessaire ?" - -if false - = f.input :ct_acompte, :label => "Acompte nécessaire ?" - = f.input :ct_acompte_percent, :label => "Pourcentage d'acompte :" - = f.input :ct_payment_delais, :label => "Délais jour de paiement :" - - -if false - = f.input :ct_payment_month_end, :label => "Fin de mois ?" - - - - \ No newline at end of file diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index ed95396..7ad0661 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -1,5 +1,5 @@ -.qi_pannel.qi_plain.padding.price_line_form.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"} +.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%;"} %tr %td{:style => "width:30px;"} @@ -10,12 +10,13 @@ = 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", :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref)} + %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({ @@ -102,7 +103,7 @@ .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"} + = form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte", tabindex: 1} @@ -118,13 +119,13 @@ -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" #, :disabled => true + =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.input :comment, :label => "Commentaire" From bebd0c0ff956a5e405f8c83d40ca5b896a76eac9 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Sat, 4 Sep 2021 11:59:07 +0200 Subject: [PATCH 043/121] Update menu function for sub menus --- app/controllers/application_controller.rb | 54 ++++++++++++++++++----- app/views/layouts/_navbar.haml | 17 ++++--- 2 files changed, 51 insertions(+), 20 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f0ed23e..ef397dc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -22,10 +22,27 @@ class ApplicationController < ActionController::Base @qi_menu_active = sym.to_sym else @qi_menus.each do |k, v| + + + if v[:elements] and v[:elements][sym.to_sym] @qi_menu_active = k @qi_menu_sub_menu_active = sym.to_sym break + + elsif v[:elements] + + v[:elements].each do |a,b| + puts "TEST" + puts b[0] + puts "B" + if b[:sub_elements] and b[:sub_elements][sym.to_sym] + @qi_menu_active = k + @qi_menu_sub_menu_active = sym.to_sym + end + end + + end @@ -65,11 +82,14 @@ class ApplicationController < ActionController::Base if current_admin.has_permission?("products") set_sub_menu :stocks, :p_products, "Produits", admin_p_products_path + set_sub_menu :stocks, :p_product_refs, "Références", admin_p_product_refs_path set_sub_menu :stocks, :p_articles, "Articles", admin_p_articles_path # set_sub_menu :stocks, :promos_p_products, "Offres spots", promos_admin_p_products_path end + + if current_admin.has_permission?("product-cats") set_sub_menu :stocks, :p_product_cats, "Catégories produits", admin_p_product_cats_path @@ -77,35 +97,37 @@ class ApplicationController < ActionController::Base end + + set_sub_menu :stocks, :p_preferences_products_menu, "Préférences", admin_p_products_path if current_admin.has_permission?("brands") - set_sub_menu :stocks, :s_brands, "Marques", admin_s_brands_path + set_sub_sub_menu :stocks, :p_preferences_products_menu, :s_brands, "Marques", admin_s_brands_path end if current_admin.has_permission?("fournisseurs") - set_sub_menu :stocks, :p_fournisseurs, "Fournisseurs", admin_p_fournisseurs_path + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_fournisseurs, "Fournisseurs", admin_p_fournisseurs_path end if current_admin.has_permission?("stocks") - set_sub_menu :stocks, :stock_alias, "Stocks", admin_line_stocks_path + set_sub_sub_menu :stocks, :p_preferences_products_menu, :stock_alias, "Stocks", admin_line_stocks_path end if current_admin.has_permission?("boutique") - set_sub_menu :stocks, :p_product_colors, "Couleurs" - set_sub_menu :stocks, :p_article_serial_nums, "Numeros série" - set_sub_menu :stocks, :p_serial_num_types, "Types de Numero série" - set_sub_menu :stocks, :p_product_ref_specs, "Specs" - set_sub_menu :stocks, :p_spec_values, "Valeur de specs" - set_sub_menu :stocks, :p_grades, "Grades" if PGrade::ACTIVATED - set_sub_menu :stocks, :p_product_powers, "Types de chargeurs" - set_sub_menu :stocks, :p_product_zones, "Zones produits" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_colors, "Couleurs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_article_serial_nums, "Numeros série" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_serial_num_types, "Types de Numero série" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_ref_specs, "Specs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_spec_values, "Valeur de specs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_grades, "Grades" if PGrade::ACTIVATED + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_powers, "Types de chargeurs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_zones, "Zones produits" end @@ -196,6 +218,16 @@ class ApplicationController < ActionController::Base @qi_menus[big_menu.to_sym][:elements][sub_menu.to_sym] = {:name => name, :link => link} end + + + def set_sub_sub_menu(big_menu, sub_menu, sub_sub_menu, name, link=nil) + + link = eval("admin_#{sub_sub_menu}_path") if !link + @qi_menus[big_menu.to_sym][:elements][sub_menu.to_sym][:sub_elements] = @qi_menus[big_menu.to_sym][:elements][sub_menu.to_sym][:sub_elements] || {} + + @qi_menus[big_menu.to_sym][:elements][sub_menu.to_sym][:sub_elements][sub_sub_menu.to_sym] = {:name => name, :link => link} + + end before_action :set_product_display diff --git a/app/views/layouts/_navbar.haml b/app/views/layouts/_navbar.haml index 1ca0db6..8bbc47c 100644 --- a/app/views/layouts/_navbar.haml +++ b/app/views/layouts/_navbar.haml @@ -9,18 +9,17 @@ -if qi_menu_active[:elements] -qi_menu_active[:elements].each do |k,v| - -if !@dropdown_elements.include?(k) + -if !v[:sub_elements] %li.nav-item{class: ("active" if @qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)} =link_to v[:name], v[:link], :class => "nav-link" - -intersect = @dropdown_elements.&(qi_menu_active[:elements].keys) - -if intersect.any? - %li.nav-item.dropdown - =link_to @dropdown_title, '#', class: "nav-link dropdown-toggle", id: "navbarDropdown", "role" => "button", "data-toggle" => "dropdown", "aria-haspopup" => "true", "aria-expanded" => "false" - %ul.dropdown-menu{"aria-labelledby" => "navbarDropdown"} - -qi_menu_active[:elements].each do |k,v| - -if @dropdown_elements.include?(k) + + -else + %li.nav-item.dropdown + =link_to v[:name], v[:link], class: "nav-link dropdown-toggle "+("active" if (@qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k) or (v[:sub_elements] and v[:sub_elements][@qi_menu_sub_menu_active])).to_s , id: "navbarDropdown", "role" => "button", "data-toggle" => "dropdown", "aria-haspopup" => "true", "aria-expanded" => "false" + %ul.dropdown-menu{"aria-labelledby" => "navbarDropdown"} + -v[:sub_elements].each do |k,v| %li=link_to v[:name], v[:link], :class => "dropdown-item"+(" active" if (@qi_menu_sub_menu_active and @qi_menu_sub_menu_active == k)).to_s - + From 9133786e8047c51796bb58d79f1478e485115e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 6 Sep 2021 09:56:23 +0200 Subject: [PATCH 044/121] direct link to analyse --- app/views/admin/price_documents/_price_document.html.haml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index fc12909..1422646 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -135,6 +135,8 @@ -tr[:actions] = capture do %td.actions + -if price_document.price_document_type_id == 1 + =link_to i("bar-chart"), analyse_reponses_admin_price_document_path(price_document) -if !price_document.imported -if current_admin.has_permission?("payments") -if !price_document.d_number? From 0d1c7d1b3f907c6ebe8f6bd6b9c4262dc8a42bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 6 Sep 2021 12:55:05 +0200 Subject: [PATCH 045/121] add radio form + tooltips + reset --- .../analyse_reponses.html.haml | 147 ++++++++++++++---- 1 file changed, 116 insertions(+), 31 deletions(-) diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 1d8c066..1da2baa 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -8,7 +8,7 @@ = @price_document.list_designaton - +=form_tag '/' .qi_pannel.padding.new_table_container .table-slider .inner @@ -24,6 +24,8 @@ Consultation %th{colspan: nb_resp} Fournisseurs + .btn.btn-light.ml-4#reset-radio + reset %tr %th @@ -81,10 +83,10 @@ %tr %td =# ATTENTION ! On a plus accès direct aux commandes qui on engendré cette demande de prix. donc plus accès aux délais différent entre les différentes commades pour une ref donée - ∑ - =price_line.qte.to_i - %br - - if price_line.cc_wish_date.present? && price_line.cc_wish_date < Date.today + 10.days + / ∑ + / =price_line.qte.to_i + / %br + - if price_line.cc_wish_date.present? && price_line.cc_wish_date < Date.today + 20.days %span.red =ic(:fire) =price_line.qte.to_i @@ -115,33 +117,51 @@ / Fournisseurs de référence %td / Date du px de référence - %td + %td.limit / spec - - @price_document_responses.each do |resp| - -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first - -cell = [] - - - if line.qte_available.to_i > 0 - -if line.qte_available >= price_line.qte.to_i - - cell << "Qté dispo : #{line.qte_available.to_i}" - -else - - cell << "#{ic(:warning, class: "orange")} Qté dispo : #{line.qte_available.to_i} (#{line.qte_available.to_i - price_line.qte.to_i})" - - cell << "PA: #{line.ct_u_price_ht} €" - - # mp = calcul de la marge prévisionelle TODO - - line.id.odd? ? mp = 0.17 : mp = 0.11 - -cell << line.id.odd? - - if mp.present? - -if mp > 0.15 - - cell << "#{ic(:check)} MP: #{mp * 100} %" - -else - - cell << "#{ic(:times, class: "red")} MP: #{mp * 100} %" - -else - - cell << "pas dispo" - -if line.comment.present? - - cell << "#{ic('info-circle')} #{line.comment}" + - form = false + - if form %td - =sanitize(cell.join('
')) + = radio_button_tag "price_selected_#{}", price_line.id + = label_tag "price line i = #{price_line.id}" + - if false + - form_with do |form| + %td + = debug form + =form.collection_radio_buttons :selected_price, price_lines, :id, :cc_title + - else + - @price_document_responses.each do |resp| + -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first + -cell = [] + - if line.qte_available.to_i > 0 + -if line.qte_available >= price_line.qte.to_i + - cell << "Qté dispo : #{line.qte_available.to_i}" + -else + - cell << "#{ic(:warning, class: "orange")} Qté dispo : #{line.qte_available.to_i} (#{line.qte_available.to_i - price_line.qte.to_i})" + - cell << "PA: #{line.ct_u_price_ht} €" + - # mp = calcul de la marge prévisionelle TODO + - line.id.odd? ? mp = 0.17 : mp = 0.11 + - if mp.present? + -if mp > 0.15 + - cell << "#{ic(:check)} MP: #{mp * 100} %" + -else + - cell << "#{ic(:times, class: "red")} MP: #{mp * 100} %" + -else + - cell << "pas dispo" + -if line.comment.present? + - display_comment = "" + - if line.comment.length > 10 + - display_comment = "#{line.comment[0..10]} (..)" + - else + - display_comment = line.comment + - cell << "#{ic('info-circle')} #{display_comment}#{line.comment}" + -# cell << "#{ic('info-circle')} #{display_comment}" + + %td.p-0 + = radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "category-selector" + = label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('
')), class: "p-2 m-auto" + =submit_tag 'valider la selection', class: "btn btn-primary" @@ -150,6 +170,24 @@ :scss + .category-selector { + position: absolute; + transform: scale(0); + } + + .category-selector + label { + display: block; + min-height: 105px; + cursor: pointer; + box-sizing: border-box; + width: 100%; + text-align: left; + } + + .category-selector:checked + label { + background-color: #b4f99e !important; + } + .limit { border-right:3px solid green !important; } @@ -163,8 +201,50 @@ .orange { color: orange; } - .darkgrey { - color: #darkgrey; + .info { + color: #009bbf; + position: relative; + display: inline-block; + text-overflow: ellipsis; + + .info-text { + visibility: hidden; + background-color: #555; + color: #fff; + text-align: center; + padding: 5px; + border-radius: 6px; + max-width: 500px; + min-width: fit-content; + white-space: normal; + + /* Position the tooltip text */ + position: absolute; + z-index: 1; + bottom: 125%; + left: 50%; + margin-left: -60px; + + /* Fade in tooltip */ + opacity: 0; + transition: opacity 0.3s; + } + .info-text::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: #555 transparent transparent transparent; + } + } + .info:hover { + .info-text { + visibility: visible; + opacity: 1; + } } .darkblue { color: darkblue; @@ -173,3 +253,8 @@ .small-input { max-width: 100px; } + +:javascript + $( "#reset-radio" ).click(function(event){ + $( ":radio" ).prop('checked',false); + }) From 4b1ee6972daf746a0e63ae8ebf4cacae30187074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 6 Sep 2021 12:55:26 +0200 Subject: [PATCH 046/121] bugfix asap --- app/models/price_line.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/price_line.rb b/app/models/price_line.rb index 1d56221..1dabff0 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -604,7 +604,7 @@ class PriceLine < ApplicationRecord def self.asap_triage(limit) total = self.sum(:qte).to_i - asap = self.where('cc_wish_date > ?', Date.today + limit).sum(:qte).to_i + asap = self.where('cc_wish_date < ?', Date.today + limit).sum(:qte).to_i non_asap = total - asap return [asap, non_asap] end From 0dada54f66881eae30499bcb0f721ad9483a1fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 6 Sep 2021 12:55:53 +0200 Subject: [PATCH 047/121] change alert limit --- app/views/admin/buy_lists/index.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index bc45103..8741a43 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -159,11 +159,11 @@ %br %span.asap =ic(:fire) - =ppr_lines.asap_triage(10).first + =ppr_lines.asap_triage(20).first %br %span.non-asap =ic(:hourglass) - =ppr_lines.asap_triage(10).last + =ppr_lines.asap_triage(20).last %td.mask = LineStock.where(p_product_ref_id: plr.p_product_ref.id).sum(:qte_available).to_i From 2c1c768c6451f002a060695717e3c0ba95e0daf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 6 Sep 2021 16:55:17 +0200 Subject: [PATCH 048/121] bugfix show/hide details --- app/views/admin/buy_lists/index.html.haml | 44 +++++++++++++++++++---- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 8741a43..37beefd 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -273,17 +273,47 @@ :javascript $('.detail').hide() $('.col-detail').hide() + let state = 0 $('.plus').click(function(event){ - $('.col-detail').toggle() - console.log(event.currentTarget); - $(event.currentTarget).parent().parent().next('tbody.detail').toggle(); + if( event.currentTarget.className == "plus") { + $(event.currentTarget).removeClass('plus').addClass('minus') + state += 1 + $('.col-detail').show() + $(event.currentTarget).parent().parent().next('tbody.detail').toggle(); + }else{ + $(event.currentTarget).removeClass('minus').addClass('plus') + state -= 1 + $(event.currentTarget).parent().parent().next('tbody.detail').toggle(); + } $(event.currentTarget).find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o') + if(state == 0){ + $('.col-detail').hide() + }else{ + $('.col-detail').show() + } }); $('.plus-all').click(function(event){ - $('.col-detail').toggle() - $('tbody.detail').toggle(); - $(event.currentTarget).find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o') - $('.plus').find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o') + if( event.currentTarget.className == "mask plus-all") { + state += $('.plus').length + $(event.currentTarget).removeClass('plus-all').addClass('minus-all') + $('tbody.detail').show(); + $('.plus').find('i').toggleClass('fa fa-plus-square-o').toggleClass('fa fa-minus-square-o') + $('.plus').removeClass('plus').addClass('minus') + $(event.currentTarget).find('i').removeClass('fa fa-plus-square-o').addClass('fa fa-minus-square-o') + }else{ + state -= $('.minus').length + $(event.currentTarget).removeClass('minus-all').addClass('plus-all') + $('.minus').find('i').removeClass('fa fa-minus-square-o').addClass('fa fa-plus-square-o') + $('.minus').removeClass('minus').addClass('plus') + + $('tbody.detail').hide(); + $(event.currentTarget).find('i').removeClass('fa fa-minus-square-o').addClass('fa fa-plus-square-o') + } + if(state == 0){ + $('.col-detail').hide() + }else{ + $('.col-detail').show() + } }); From 7dfe920e992468e45e02c07d1d64f9dac8b53e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 6 Sep 2021 17:31:32 +0200 Subject: [PATCH 049/121] add p_spec_type menu --- app/controllers/application_controller.rb | 3 ++- app/models/p_spec_type.rb | 7 ++++++- app/views/admin/p_spec_types/_form.html.haml | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ef397dc..c9fffcc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -124,7 +124,8 @@ class ApplicationController < ActionController::Base set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_article_serial_nums, "Numeros série" set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_serial_num_types, "Types de Numero série" set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_ref_specs, "Specs" - set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_spec_values, "Valeur de specs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_spec_types, "Types de specs" + set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_spec_values, "Valeurs de specs" set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_grades, "Grades" if PGrade::ACTIVATED set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_powers, "Types de chargeurs" set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_zones, "Zones produits" diff --git a/app/models/p_spec_type.rb b/app/models/p_spec_type.rb index a656aa6..42875d3 100644 --- a/app/models/p_spec_type.rb +++ b/app/models/p_spec_type.rb @@ -1,5 +1,10 @@ class PSpecType < ApplicationRecord has_many :p_product_ref_specs - TYPES = ["Ram", "Stockage"] + + acts_as_sorting :fields => { + :id => {:name => "ID"}, + :name => {:name => "Type", :reorder => true}, + :actions => {:name => "Actions", :reorder => true} + } end diff --git a/app/views/admin/p_spec_types/_form.html.haml b/app/views/admin/p_spec_types/_form.html.haml index ab615d2..2b94b28 100644 --- a/app/views/admin/p_spec_types/_form.html.haml +++ b/app/views/admin/p_spec_types/_form.html.haml @@ -1,2 +1,13 @@ -=f.inputs do - = f.input :name, :label => "Type", as: :select, collection: PSpecType::TYPES +- if params[:controller] == "admin/p_spec_types" + =semantic_form_for [:admin, @p_spec_type], :remote => true do |f| + + .content + =f.inputs do + %td + = f.input :name, :label => "Type" + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + +- else + =f.inputs do + = f.input :name, :label => "Type", as: :select, collection: PSpecType.pluck(:name).uniq From 05963478a4809c01e4ede75c98f25108c7d7697a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 6 Sep 2021 17:31:46 +0200 Subject: [PATCH 050/121] grade bugfix --- app/views/admin/p_articles/_p_article.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/admin/p_articles/_p_article.html.haml b/app/views/admin/p_articles/_p_article.html.haml index 8d4a1ed..32497fc 100644 --- a/app/views/admin/p_articles/_p_article.html.haml +++ b/app/views/admin/p_articles/_p_article.html.haml @@ -7,7 +7,8 @@ -tr[:p_grade] = capture do %td - = p_article.p_grade.grade + -if p_article.p_grade + = p_article.p_grade.grade -tr[:color] = capture do %td From 9d24db217852732006ec037f6f65ac5220cd0355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 6 Sep 2021 18:04:45 +0200 Subject: [PATCH 051/121] WIP analyse --- .../analyse_reponses.html.haml | 67 ++++++++----------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 1da2baa..489baa2 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -119,48 +119,37 @@ / Date du px de référence %td.limit / spec - - form = false - - if form - %td - = radio_button_tag "price_selected_#{}", price_line.id - = label_tag "price line i = #{price_line.id}" - - if false - - form_with do |form| - %td - = debug form - =form.collection_radio_buttons :selected_price, price_lines, :id, :cc_title - - else - - @price_document_responses.each do |resp| - -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first - -cell = [] - - if line.qte_available.to_i > 0 - -if line.qte_available >= price_line.qte.to_i - - cell << "Qté dispo : #{line.qte_available.to_i}" - -else - - cell << "#{ic(:warning, class: "orange")} Qté dispo : #{line.qte_available.to_i} (#{line.qte_available.to_i - price_line.qte.to_i})" - - cell << "PA: #{line.ct_u_price_ht} €" - - # mp = calcul de la marge prévisionelle TODO - - line.id.odd? ? mp = 0.17 : mp = 0.11 - - if mp.present? - -if mp > 0.15 - - cell << "#{ic(:check)} MP: #{mp * 100} %" - -else - - cell << "#{ic(:times, class: "red")} MP: #{mp * 100} %" + - @price_document_responses.each do |resp| + -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first + -cell = [] + + - if line.qte_available.to_i > 0 + -if line.qte_available >= price_line.qte.to_i + - cell << "Qté dispo : #{line.qte_available.to_i}" -else - - cell << "pas dispo" - -if line.comment.present? - - display_comment = "" - - if line.comment.length > 10 - - display_comment = "#{line.comment[0..10]} (..)" - - else - - display_comment = line.comment - - cell << "#{ic('info-circle')} #{display_comment}#{line.comment}" - -# cell << "#{ic('info-circle')} #{display_comment}" + - cell << "#{ic(:warning, class: "orange")} Qté dispo : #{line.qte_available.to_i} (#{line.qte_available.to_i - price_line.qte.to_i})" + - cell << "PA: #{line.ct_u_price_ht} €" + - # mp = calcul de la marge prévisionelle TODO + - line.id.odd? ? mp = 0.17 : mp = 0.11 + - if mp.present? + -if mp > 0.15 + - cell << "#{ic(:check)} MP: #{mp * 100} %" + -else + - cell << "#{ic(:times, class: "red")} MP: #{mp * 100} %" + -else + - cell << "pas dispo" + -if line.comment.present? + - display_comment = "" + - if line.comment.length > 10 + - display_comment = "#{line.comment[0..10]} (..)" + - else + - display_comment = line.comment + - cell << "#{ic('info-circle')} #{display_comment}#{line.comment}" - %td.p-0 - = radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "category-selector" - = label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('
')), class: "p-2 m-auto" + %td.p-0 + = radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "category-selector" + = label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('
')), class: "p-2 m-auto" =submit_tag 'valider la selection', class: "btn btn-primary" From 8e1cc4b0a15c75f4f5d050756682598623368888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 7 Sep 2021 12:35:52 +0200 Subject: [PATCH 052/121] WIP analyse --- .../analyse_reponses.html.haml | 282 +++++++++--------- ...add_selected_price_offer_to_price_lines.rb | 5 + db/schema.rb | 3 +- 3 files changed, 154 insertions(+), 136 deletions(-) create mode 100644 db/migrate/20210907083709_add_selected_price_offer_to_price_lines.rb diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 489baa2..96050ca 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -8,148 +8,160 @@ = @price_document.list_designaton -=form_tag '/' -.qi_pannel.padding.new_table_container - .table-slider - .inner +=semantic_form_for [:admin, @price_document], :html => {:class => "qi_price_form"}, :remote => false do |form| + =form.semantic_fields_for :price_line_block do |f| + - price_line_block = f.object + .qi_pannel.padding.new_table_container + .table-slider + .inner - .table-area{:style => "overflow:auto;"} - .table-area-inner - .freezeTable - %table.table.table-striped.table-hover.table-bordered.data_table - %thead.header - %tr - -nb_resp = @price_document_responses.count - %th{colspan: 12} - Consultation - %th{colspan: nb_resp} - Fournisseurs - .btn.btn-light.ml-4#reset-radio - reset - - %tr - %th - Qté à - %br - satisfaire - %th - Qté consultée - %th - Produit - %th - Référence - %th - Couleur - %th - Type - %br - chargeur - %th - Target hors - %br - Sorecop - %th - Px d'achat - %br - référence - %th - Marge - %br - théorique - %br - référence - %br - par zone - %th - Fours. - %br - de référence - %th - Date - %br - px référence - %th.limit - Spec - - -@price_document_responses.each do |resp| - %th - =resp.p_fournisseur.name - - - %tbody - -price_lines = @price_document.price_line_block.price_lines - -consult_price_lines = @price_document.price_line_block.price_lines - -price_lines.each do |price_line| + .table-area{:style => "overflow:auto;"} + .table-area-inner + .freezeTable + %table.table.table-striped.table-hover.table-bordered.data_table + %thead.header %tr - %td - =# ATTENTION ! On a plus accès direct aux commandes qui on engendré cette demande de prix. donc plus accès aux délais différent entre les différentes commades pour une ref donée - / ∑ - / =price_line.qte.to_i - / %br - - if price_line.cc_wish_date.present? && price_line.cc_wish_date < Date.today + 20.days - %span.red - =ic(:fire) - =price_line.qte.to_i - - else - %span.darkblue - =ic(:hourglass) - =price_line.qte.to_i - %td.ref_tr - Qté en comm - %td - = price_line.p_product_ref.p_product.name - %td - =link_to [:admin, price_line.p_product_ref] do - = price_line.p_product_ref.ct_sub_name - = price_line.p_product_ref.p_product_color.name + -nb_resp = @price_document_responses.count + %th{colspan: 12} + Consultation + %th{colspan: nb_resp} + Fournisseurs + .btn.btn-light.ml-4#reset-radio + reset - %td - = price_line.p_product_ref.p_product_color.color if price_line.p_product_ref and price_line.p_product_ref.p_product_color - %td - = price_line.p_product_power.name if price_line.p_product_power - %td - / Target hors Sorecop - %td - / Px d'achat de référence - %td - / Marge théorique de référence par zone - %td - / Fournisseurs de référence - %td - / Date du px de référence - %td.limit - / spec + %tr + %th + Qté à + %br + satisfaire + %th + Qté consultée + %th + Produit + %th + Référence + %th + Couleur + %th + Type + %br + chargeur + %th + Target hors + %br + Sorecop + %th + Px d'achat + %br + référence + %th + Marge + %br + théorique + %br + référence + %br + par zone + %th + Fours. + %br + de référence + %th + Date + %br + px référence + %th.limit + Spec - - @price_document_responses.each do |resp| - -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first - -cell = [] + -@price_document_responses.each do |resp| + %th + -if resp.p_fournisseur + =resp.p_fournisseur.name - - if line.qte_available.to_i > 0 - -if line.qte_available >= price_line.qte.to_i - - cell << "Qté dispo : #{line.qte_available.to_i}" - -else - - cell << "#{ic(:warning, class: "orange")} Qté dispo : #{line.qte_available.to_i} (#{line.qte_available.to_i - price_line.qte.to_i})" - - cell << "PA: #{line.ct_u_price_ht} €" - - # mp = calcul de la marge prévisionelle TODO - - line.id.odd? ? mp = 0.17 : mp = 0.11 - - if mp.present? - -if mp > 0.15 - - cell << "#{ic(:check)} MP: #{mp * 100} %" + + %tbody + -# price_lines = f.object.price_lines + + -consult_price_lines = @price_document.price_line_block.price_lines + =f.semantic_fields_for :price_lines do |form| + - price_line = form.object + -#price_lines = @price_document.price_line_block.price_lines + -#price_lines.each do |price_line| + + %tr + %td + =# ATTENTION ! On a plus accès direct aux commandes qui on engendré cette demande de prix. donc plus accès aux délais différent entre les différentes commades pour une ref donée + / ∑ + / =price_line.qte.to_i + / %br + - if price_line.cc_wish_date.present? && price_line.cc_wish_date < Date.today + 20.days + %span.red + =ic(:fire) + =price_line.qte.to_i + - else + %span.darkblue + =ic(:hourglass) + =price_line.qte.to_i + %td.ref_tr + Qté en comm + %td + = price_line.p_product_ref.p_product.name + %td + =link_to [:admin, price_line.p_product_ref] do + = price_line.p_product_ref.ct_sub_name + = price_line.p_product_ref.p_product_color.name + + %td + = price_line.p_product_ref.p_product_color.color if price_line.p_product_ref and price_line.p_product_ref.p_product_color + %td + = price_line.p_product_power.name if price_line.p_product_power + %td + / Target hors Sorecop + %td + / Px d'achat de référence + %td + / Marge théorique de référence par zone + %td + / Fournisseurs de référence + %td + / Date du px de référence + %td.limit + / spec + + =form.input :selected_price_line_id, collection: PriceLine.where(:price_line_ref_id => form.object.id).all, as: :radio, :member_label => :id + =debug form.object.id + - @price_document_responses.each do |resp| + -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first + -cell = [] + + - if line.qte_available.to_i > 0 + -if line.qte_available >= price_line.qte.to_i + - cell << "Qté dispo : #{line.qte_available.to_i}" + -else + - cell << "#{ic(:warning, class: "orange")} Qté dispo : #{line.qte_available.to_i} (#{line.qte_available.to_i - price_line.qte.to_i})" + - cell << "PA: #{line.ct_u_price_ht} €" + - # mp = calcul de la marge prévisionelle TODO + - line.id.odd? ? mp = 0.17 : mp = 0.11 + - if mp.present? + -if mp > 0.15 + - cell << "#{ic(:check)} MP: #{mp * 100} %" + -else + - cell << "#{ic(:times, class: "red")} MP: #{mp * 100} %" -else - - cell << "#{ic(:times, class: "red")} MP: #{mp * 100} %" - -else - - cell << "pas dispo" - -if line.comment.present? - - display_comment = "" - - if line.comment.length > 10 - - display_comment = "#{line.comment[0..10]} (..)" - - else - - display_comment = line.comment - - cell << "#{ic('info-circle')} #{display_comment}#{line.comment}" + - cell << "pas dispo" + -if line.comment.present? + - display_comment = "" + - if line.comment.length > 10 + - display_comment = "#{line.comment[0..10]} (..)" + - else + - display_comment = line.comment + - cell << "#{ic('info-circle')} #{display_comment}#{line.comment}" - %td.p-0 - = radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "category-selector" - = label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('
')), class: "p-2 m-auto" + %td.p-0 + = "reponse price_line ID : #{line.id}" + =#form.input :selected_price_offer, as: :radio + = radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "category-selector" + = label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('
')), class: "p-2 m-auto" =submit_tag 'valider la selection', class: "btn btn-primary" diff --git a/db/migrate/20210907083709_add_selected_price_offer_to_price_lines.rb b/db/migrate/20210907083709_add_selected_price_offer_to_price_lines.rb new file mode 100644 index 0000000..0654371 --- /dev/null +++ b/db/migrate/20210907083709_add_selected_price_offer_to_price_lines.rb @@ -0,0 +1,5 @@ +class AddSelectedPriceOfferToPriceLines < ActiveRecord::Migration[6.0] + def change + add_column :price_lines, :selected_price_line_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index e1898e3..3107c6a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_30_091804) do +ActiveRecord::Schema.define(version: 2021_09_07_083709) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -2544,6 +2544,7 @@ ActiveRecord::Schema.define(version: 2021_08_30_091804) do t.boolean "eu" t.boolean "fullkit" t.boolean "lang_start" + t.integer "selected_price_line_id" end create_table "quote_contents", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| From 3bcadb801d1dd32dc6c5c81651453904b16acdde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 7 Sep 2021 12:37:07 +0200 Subject: [PATCH 053/121] bugfix consult --- app/views/layouts/_navbar.haml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/views/layouts/_navbar.haml b/app/views/layouts/_navbar.haml index 8bbc47c..03f02be 100644 --- a/app/views/layouts/_navbar.haml +++ b/app/views/layouts/_navbar.haml @@ -55,15 +55,16 @@ %li.nav-item.dropdown - %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"} - =current_admin.firstname - =current_admin.name + -if current_admin + %a#navbarDropdown.nav-link.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :href => "#", :role => "button"} + =current_admin.firstname + =current_admin.name - .dropdown-menu{"aria-labelledby" => "navbarDropdown"} - = link_to "Gestion des admins", admin_admins_path, :class => "dropdown-item" if current_admin.super_admin - .dropdown-divider - =link_to "Se déconnecter", admin_admin_auth_path(1), method: :delete, :class => "dropdown-item" + .dropdown-menu{"aria-labelledby" => "navbarDropdown"} + = link_to "Gestion des admins", admin_admins_path, :class => "dropdown-item" if current_admin.super_admin + .dropdown-divider + =link_to "Se déconnecter", admin_admin_auth_path(1), method: :delete, :class => "dropdown-item" From a0b3612f126d0fefa8c0f314809c87fcf1479b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 7 Sep 2021 12:37:33 +0200 Subject: [PATCH 054/121] WIP p_product_ref_id form in consult --- app/views/admin/price_lines/_form_reponse_fournisseur.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml b/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml index bf511fa..9c97d68 100644 --- a/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml +++ b/app/views/admin/price_lines/_form_reponse_fournisseur.html.haml @@ -1,7 +1,7 @@ .qi_pannel.qi_plain.padding.price_line_form.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"} - + =form.text_field :price_line_ref_id %table.top_td{:style => "width:100%;"} %tr From 4b29b62e474a1135917de551322e1979543086d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 7 Sep 2021 19:09:39 +0200 Subject: [PATCH 055/121] add price_line_resp_select --- .../price_line_resp_selects_controller.rb | 76 +++++++++++++++++++ app/models/price_line_resp_select.rb | 4 + .../price_line_resp_selects/_form.html.haml | 13 ++++ .../_price_line_resp_select.html.haml | 16 ++++ .../price_line_resp_selects/create.js.erb | 2 + .../price_line_resp_selects/destroy.js.erb | 1 + .../admin/price_line_resp_selects/edit.js.erb | 1 + .../price_line_resp_selects/index.html.haml | 16 ++++ .../admin/price_line_resp_selects/new.js.erb | 1 + .../price_line_resp_selects/show.html.haml | 10 +++ .../price_line_resp_selects/update.js.erb | 2 + config/routes.rb | 11 +++ ...07161735_create_price_line_resp_selects.rb | 10 +++ db/schema.rb | 9 ++- 14 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 app/controllers/admin/price_line_resp_selects_controller.rb create mode 100644 app/models/price_line_resp_select.rb create mode 100644 app/views/admin/price_line_resp_selects/_form.html.haml create mode 100644 app/views/admin/price_line_resp_selects/_price_line_resp_select.html.haml create mode 100644 app/views/admin/price_line_resp_selects/create.js.erb create mode 100644 app/views/admin/price_line_resp_selects/destroy.js.erb create mode 100644 app/views/admin/price_line_resp_selects/edit.js.erb create mode 100644 app/views/admin/price_line_resp_selects/index.html.haml create mode 100644 app/views/admin/price_line_resp_selects/new.js.erb create mode 100644 app/views/admin/price_line_resp_selects/show.html.haml create mode 100644 app/views/admin/price_line_resp_selects/update.js.erb create mode 100644 db/migrate/20210907161735_create_price_line_resp_selects.rb diff --git a/app/controllers/admin/price_line_resp_selects_controller.rb b/app/controllers/admin/price_line_resp_selects_controller.rb new file mode 100644 index 0000000..24020fd --- /dev/null +++ b/app/controllers/admin/price_line_resp_selects_controller.rb @@ -0,0 +1,76 @@ +# -*- encoding : utf-8 -*- + +class Admin::PriceLineRespSelectsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "default" + end + + def index + @price_line_resp_selects = PriceLineRespSelect.all + + @price_line_resp_selects = sort_by_sorting(@price_line_resp_selects, "id DESC") + respond_to do |format| + format.html{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @price_line_resp_selects = @price_line_resp_selects.page(page).per(per_page) + + } + end + end + + def show + @price_line_resp_select = PriceLineRespSelect.find(params[:id]) + + end + + def new + @price_line_resp_select = PriceLineRespSelect.new + + end + + def edit + @price_line_resp_select = PriceLineRespSelect.find(params[:id]) + + end + + def create + @price_line_resp_select = PriceLineRespSelect.new(params.require(:price_line_resp_select).permit!) + + if @price_line_resp_select.save + + else + render action: "new" + + end + + end + + + def update + @price_line_resp_select = PriceLineRespSelect.find(params[:id]) + + + if @price_line_resp_select.update_attributes(params.require(:price_line_resp_select).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @price_line_resp_select = PriceLineRespSelect.find(params[:id]) + @price_line_resp_select.destroy + + end +end diff --git a/app/models/price_line_resp_select.rb b/app/models/price_line_resp_select.rb new file mode 100644 index 0000000..f656ff3 --- /dev/null +++ b/app/models/price_line_resp_select.rb @@ -0,0 +1,4 @@ +class PriceLineRespSelect < ApplicationRecord + belongs_to :price_line_demand, class_name: "PriceLine" + belongs_to :price_line_resp, class_name: "PriceLine" +end diff --git a/app/views/admin/price_line_resp_selects/_form.html.haml b/app/views/admin/price_line_resp_selects/_form.html.haml new file mode 100644 index 0000000..73156af --- /dev/null +++ b/app/views/admin/price_line_resp_selects/_form.html.haml @@ -0,0 +1,13 @@ +=semantic_form_for [:admin, @price_line_resp_select], :remote => true do |f| + + .content + =f.inputs do + = f.input :price_line_demand_id, :label => f.object.label_for(:price_line_demand_id) + = f.input :price_line_resp_id, :label => f.object.label_for(:price_line_resp_id) + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/price_line_resp_selects/_price_line_resp_select.html.haml b/app/views/admin/price_line_resp_selects/_price_line_resp_select.html.haml new file mode 100644 index 0000000..d174a07 --- /dev/null +++ b/app/views/admin/price_line_resp_selects/_price_line_resp_select.html.haml @@ -0,0 +1,16 @@ +%tr#price_line_resp_select_row{:id => price_line_resp_select.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, price_line_resp_select], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_price_line_resp_select_path(price_line_resp_select), :remote => true + = link_to i(:eye), admin_price_line_resp_select_path(price_line_resp_select), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => price_line_resp_select} + + + + \ No newline at end of file diff --git a/app/views/admin/price_line_resp_selects/create.js.erb b/app/views/admin/price_line_resp_selects/create.js.erb new file mode 100644 index 0000000..aadcb42 --- /dev/null +++ b/app/views/admin/price_line_resp_selects/create.js.erb @@ -0,0 +1,2 @@ +$('#price_line_resp_selects_rows').prepend("<%= escape_javascript(render(@price_line_resp_select))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/price_line_resp_selects/destroy.js.erb b/app/views/admin/price_line_resp_selects/destroy.js.erb new file mode 100644 index 0000000..9a7da6c --- /dev/null +++ b/app/views/admin/price_line_resp_selects/destroy.js.erb @@ -0,0 +1 @@ +$('#price_line_resp_select_row_<%= @price_line_resp_select.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/price_line_resp_selects/edit.js.erb b/app/views/admin/price_line_resp_selects/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/price_line_resp_selects/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/price_line_resp_selects/index.html.haml b/app/views/admin/price_line_resp_selects/index.html.haml new file mode 100644 index 0000000..b5afa77 --- /dev/null +++ b/app/views/admin/price_line_resp_selects/index.html.haml @@ -0,0 +1,16 @@ +.qi_header + .right= link_to ic(:plus)+' Ajouter', new_admin_price_line_resp_select_path(), :class => "btn btn-primary btn-ap-add", :remote => true + %h1 + =PriceLineRespSelect.human rescue "" + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @price_line_resp_selects} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_line_resp_selects} + + + diff --git a/app/views/admin/price_line_resp_selects/new.js.erb b/app/views/admin/price_line_resp_selects/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/price_line_resp_selects/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/price_line_resp_selects/show.html.haml b/app/views/admin/price_line_resp_selects/show.html.haml new file mode 100644 index 0000000..377ef51 --- /dev/null +++ b/app/views/admin/price_line_resp_selects/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @price_line_resp_select \ No newline at end of file diff --git a/app/views/admin/price_line_resp_selects/update.js.erb b/app/views/admin/price_line_resp_selects/update.js.erb new file mode 100644 index 0000000..d834a55 --- /dev/null +++ b/app/views/admin/price_line_resp_selects/update.js.erb @@ -0,0 +1,2 @@ +$('#price_line_resp_select_row_<%= @price_line_resp_select.id %>').replaceWith("<%= escape_javascript(render(@price_line_resp_select))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index a0c1e29..207c0f8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,16 @@ Rails.application.routes.draw do + namespace :admin do + resources :price_line_resp_selects do + member do + + end + collection do + + end + end + end + namespace :admin do resources :p_grades do member do diff --git a/db/migrate/20210907161735_create_price_line_resp_selects.rb b/db/migrate/20210907161735_create_price_line_resp_selects.rb new file mode 100644 index 0000000..bc401da --- /dev/null +++ b/db/migrate/20210907161735_create_price_line_resp_selects.rb @@ -0,0 +1,10 @@ +class CreatePriceLineRespSelects < ActiveRecord::Migration[6.0] + def change + create_table :price_line_resp_selects do |t| + t.integer :price_line_demand_id + t.integer :price_line_resp_id + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 3107c6a..934a8fe 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_07_083709) do +ActiveRecord::Schema.define(version: 2021_09_07_161735) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -2403,6 +2403,13 @@ ActiveRecord::Schema.define(version: 2021_09_07_083709) do t.index ["p_customer_id"], name: "index_price_line_blocks_on_p_customer_id" end + create_table "price_line_resp_selects", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.integer "price_line_demand_id" + t.integer "price_line_resp_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "price_lines", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.boolean "archived" t.integer "price_line_block_id" From 8f120baa3fc7458cfa0f45a9ccef23c73c9c0b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 7 Sep 2021 19:10:21 +0200 Subject: [PATCH 056/121] price_line_resp_select relations --- app/models/price_line.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/price_line.rb b/app/models/price_line.rb index 1dabff0..0eba34d 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -3,6 +3,12 @@ class PriceLine < ApplicationRecord belongs_to :p_product belongs_to :p_product_ref belongs_to :p_product_power + has_many :price_line_resp_selects, :foreign_key => :price_line_demand + has_many :price_line_resps, through: :price_line_resp_selects, :source => :price_line_resp + + + #has_many :price_line_demands, through: :price_line_resp_selects + default_scope { order('position ASC') } validates :p_product_ref_id, :presence => true, :if => :p_product_ref_needed? From 4d8e99aef96524d7a61704f91ee856c85ba3f3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 7 Sep 2021 19:26:36 +0200 Subject: [PATCH 057/121] wip analyse --- .../admin/price_documents_controller.rb | 2 +- .../analyse_reponses.html.haml | 40 ++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index b480168..8d69bb2 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -279,7 +279,7 @@ class Admin::PriceDocumentsController < ApplicationController @ref_price_lines = @demande.price_line_block.price_lines @ref_price_lines.group(:p_product_ref_id).each do |plr| - @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) + @price_document.price_line_block.price_lines << PriceLine.new(:price_line_ref_id => plr.id, :p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) end diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 96050ca..7528f80 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -7,7 +7,7 @@ \- = @price_document.list_designaton - +-unmatched_fournisseur = 0 =semantic_form_for [:admin, @price_document], :html => {:class => "qi_price_form"}, :remote => false do |form| =form.semantic_fields_for :price_line_block do |f| - price_line_block = f.object @@ -77,6 +77,13 @@ %th -if resp.p_fournisseur =resp.p_fournisseur.name + -else + -unmatched_fournisseur += 1 + nom renseigné par le fournisseur : + %br + ="(#{resp.public_fournisseur_name})" + %br + =link_to ic('pencil') + " rapprocher le fournisseur", match_p_fournisseur_admin_price_document_path(resp), remote: true %tbody @@ -127,9 +134,10 @@ / Date du px de référence %td.limit / spec - - =form.input :selected_price_line_id, collection: PriceLine.where(:price_line_ref_id => form.object.id).all, as: :radio, :member_label => :id - =debug form.object.id + =#form.object.price_line_resp_ids + =#form.text_field :price_line_demand_id + =#form.input :price_line_resp_id, collection: PriceLine.where(:price_line_demand_id => form.object.id).all, as: :check_boxes, :member_label => :id + =form.input :price_line_resp_ids, collection: PriceLine.where(:price_line_ref_id => form.object.id).all, as: :check_boxes , :member_label => :id - @price_document_responses.each do |resp| -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first -cell = [] @@ -162,7 +170,29 @@ =#form.input :selected_price_offer, as: :radio = radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "category-selector" = label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('
')), class: "p-2 m-auto" - =submit_tag 'valider la selection', class: "btn btn-primary" + + - if unmatched_fournisseur == 0 + =submit_tag 'valider la selection', class: "btn btn-primary ml-4" + - else + %button.btn.btn-primary.ml-4{"type" => "button", "data-toggle" => "modal", "data-target" => "#unmatched-fournisseur"} + Valider la selection + .modal.fade#unmatched-fournisseur{"tab-index" => "-1", "role" => "dialog", "aria-labelledby" => "Raprochement Fournisseur", "aria-hidden" => "true"} + .modal-dialog{role: "dialog"} + .modal-content + .modal-header + %h5.modal-title + Rapprochement du fournisseur + %button.close{"data-dismiss" => "modal", "aria-label" => "Close"} + %span{"aria-hidden" => "true"} + × + .modal-body + Il reste des fournisseurs à prapprocher avant de pouvoir valider. + .modal-footer + %button.btn.btn-light{"data-dismiss" => "modal"} + Close + + + From 8be2ad4ce914c552381a026da278d20bd1a75501 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Tue, 7 Sep 2021 23:00:31 +0200 Subject: [PATCH 058/121] Ajout des checkboxes dans les bonnes colonnes. Voir les commentaires #Nico pour l'explication --- .../analyse_reponses.html.haml | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 7528f80..32b719d 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -88,7 +88,7 @@ %tbody -# price_lines = f.object.price_lines - + -price_lines_child_index = {} -consult_price_lines = @price_document.price_line_block.price_lines =f.semantic_fields_for :price_lines do |form| - price_line = form.object @@ -134,10 +134,19 @@ / Date du px de référence %td.limit / spec - =#form.object.price_line_resp_ids - =#form.text_field :price_line_demand_id - =#form.input :price_line_resp_id, collection: PriceLine.where(:price_line_demand_id => form.object.id).all, as: :check_boxes, :member_label => :id - =form.input :price_line_resp_ids, collection: PriceLine.where(:price_line_ref_id => form.object.id).all, as: :check_boxes , :member_label => :id + + =#form.input :price_line_resp_ids, collection: PriceLine.where(:price_line_ref_id => form.object.id).all, as: :check_boxes , :member_label => :id + + -#NICO : j'ai commenté l'input qu'on a fait ensemble, par contre, pour toute la suite, j'ai en fait fait un copié collé du rendu de cet inpu ou j'ai remis les champs dynamics en correspondance. + + + -#NICO : j'ai créé un hash plus haut, vide, qui va me permettre de faire correspondre à chaque ID de price_line leur index dans le nested form (qui est différent, une itération, de l'ID de l'élement... Là c'est la magie de rails.) + - price_lines_child_index[form.object.id.to_s] = form.options[:child_index] + + + -#Nico : je commence, pour chaque price line, par faire une checkbox vide. J'aurais pu faire un checkbox tag mais par facilité j'ai copé l'HTML dans HTML2HAML et je suis partid du résultat. Les checkboxes sont ensuite dans ta boucle + %input{:autocomplete => "off", :id => "price_document[price_line_block_attributes][price_lines_attributes][#{form.options[:child_index] }]_price_line_resp_ids_none", :name => "price_document[price_line_block_attributes][price_lines_attributes][#{form.options[:child_index] }][price_line_resp_ids][]", :type => "hidden", :value => ""}/ + - @price_document_responses.each do |resp| -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first -cell = [] @@ -167,7 +176,16 @@ %td.p-0 = "reponse price_line ID : #{line.id}" - =#form.input :selected_price_offer, as: :radio + = "price line origine : #{line.price_line_ref_id}" #NICO : simple contrôle, je récupère facilement par là l'ID de la price Line concernée. + + -#NICO : si on a un price_line_ref_id, j'ajoute la case à cocher. Je récupère l'index de nested form dans mon hash, et je passe en value le line.id + -if line.price_line_ref_id.to_s != "" + %br + %label{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"} + %input{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/ + =line.id + + = radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "category-selector" = label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('
')), class: "p-2 m-auto" From 0c128507181b39f2ced719b34ebd7053d3dc31bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 8 Sep 2021 09:48:16 +0200 Subject: [PATCH 059/121] Skip default redirect after matching p_fournisseur --- app/controllers/admin/price_documents_controller.rb | 10 ++++++++++ .../price_documents/_form_p_fournisseur.html.haml | 2 +- .../price_documents/match_p_fournisseur_save.js.erb | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 app/views/admin/price_documents/match_p_fournisseur_save.js.erb diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 8d69bb2..f8cfc68 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -599,6 +599,16 @@ class Admin::PriceDocumentsController < ApplicationController @price_document = PriceDocument.find(params[:id]) end + def match_p_fournisseur_save + @price_document = PriceDocument.find(params[:id]) + + if @price_document.update_attributes(params.require(:price_document).permit!) + # redirect_back(fallback_location: price_documents_ptath) + else + render action: "edit" + end + end + def analyse_reponses @price_document = PriceDocument.find(params[:id]) @price_document_responses = PriceDocument.where(:doc_ref_id => @price_document.id ) diff --git a/app/views/admin/price_documents/_form_p_fournisseur.html.haml b/app/views/admin/price_documents/_form_p_fournisseur.html.haml index 3514749..a860e68 100644 --- a/app/views/admin/price_documents/_form_p_fournisseur.html.haml +++ b/app/views/admin/price_documents/_form_p_fournisseur.html.haml @@ -1,4 +1,4 @@ -=semantic_form_for [:admin, @price_document], :html => {:class => "qi_price_form"}, :remote => false do |f| +=semantic_form_for [:admin, @price_document], url: match_p_fournisseur_save_admin_price_document_path, :html => {:class => "qi_price_form"}, :remote => true do |f| =diag do =f.object.errors.messages diff --git a/app/views/admin/price_documents/match_p_fournisseur_save.js.erb b/app/views/admin/price_documents/match_p_fournisseur_save.js.erb new file mode 100644 index 0000000..0d5cc58 --- /dev/null +++ b/app/views/admin/price_documents/match_p_fournisseur_save.js.erb @@ -0,0 +1,2 @@ +location.reload(); +close_pane_hover(); From eed90a2d33e917ac6d1d39c56d05d0c000d3fbd3 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Wed, 8 Sep 2021 10:18:48 +0200 Subject: [PATCH 060/121] =?UTF-8?q?D=C3=A9but=20popup=20produits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/manager.js | 21 ++++++++++++++++++- app/assets/stylesheets/manager.scss | 3 ++- .../admin/p_product_refs_controller.rb | 5 +++++ .../admin/p_customer_sheets/_form.html.haml | 10 ++++----- .../p_product_refs/_p_product_ref.html.haml | 10 +++++++-- app/views/admin/price_lines/_form.html.haml | 11 ++++++---- 6 files changed, 47 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/manager.js b/app/assets/javascripts/manager.js index 10623e4..b6b2393 100644 --- a/app/assets/javascripts/manager.js +++ b/app/assets/javascripts/manager.js @@ -42,7 +42,7 @@ function manager_show(url){ function manager_hide(){ $("#manager_box_place").removeClass("manager_box_place_active"); - + $('#manager_box').html(""); $("body").css("overflow", "auto"); slider_enabled = null; @@ -239,3 +239,22 @@ function select_video_from_manager(input_id){ } +function select_product_from_manager(input_id){ + + + manager_prompt("/admin/p_product_refs.html?manager=true",function(m_return){ + + $('.p_product_ref_id_'+input_id).val(m_return.id); + $('.p_product_ref_name_'+input_id).val(m_return.name); + + }); + +} + +function send_manager_product(product_id, product_name){ + + manager_send_response({id : product_id, name : product_name}); +} + + + diff --git a/app/assets/stylesheets/manager.scss b/app/assets/stylesheets/manager.scss index eb296d2..f03e584 100644 --- a/app/assets/stylesheets/manager.scss +++ b/app/assets/stylesheets/manager.scss @@ -2,7 +2,8 @@ #manager_box_place{ position:fixed; height:0; - width:100%; + left:100px; + right:30px; z-index:1500; top:0px; margin:0px; diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 5648846..fbf5675 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -57,6 +57,11 @@ class Admin::PProductRefsController < ApplicationController } end + + if params[:manager].to_s == "true" + @manager = true + render :layout => false + end end diff --git a/app/views/admin/p_customer_sheets/_form.html.haml b/app/views/admin/p_customer_sheets/_form.html.haml index c8c82b9..14bc8a5 100755 --- a/app/views/admin/p_customer_sheets/_form.html.haml +++ b/app/views/admin/p_customer_sheets/_form.html.haml @@ -17,8 +17,8 @@ - .right.actions - =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" - =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" - .clear - + .large_actions + .actions + =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" + =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" + diff --git a/app/views/admin/p_product_refs/_p_product_ref.html.haml b/app/views/admin/p_product_refs/_p_product_ref.html.haml index 33e3f52..ca09295 100644 --- a/app/views/admin/p_product_refs/_p_product_ref.html.haml +++ b/app/views/admin/p_product_refs/_p_product_ref.html.haml @@ -31,8 +31,14 @@ %td.actions =# link_to i(:"trash-o"), [:admin, p_product_ref], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer ce produit ? ' } , :remote => true if !PriceLine.where(:p_product_ref_id => p_product_ref).first =#debug PriceLine.where(:p_product_ref_id => p_product_ref.id).first - = link_to i(:pencil), edit_admin_p_product_path(p_product_ref.p_product), :remote => false - = link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false + + -if @manager + = link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false, :target => "_blank" + = link_to i(:"check"), "#",:onclick => "send_manager_product('"+p_product_ref.id.to_s+"', '"+escape_javascript(p_product_ref.member_label.to_s)+"');return false;" + + -else + = link_to i(:pencil), edit_admin_p_product_path(p_product_ref.p_product), :remote => false + = link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_product_ref} diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index ed95396..f16140b 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -9,12 +9,15 @@ = 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)} + %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}"} - - = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id" - + + = 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() { From fa8ebf207f8cd046275e38215a3a352079ce3253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 8 Sep 2021 15:11:29 +0200 Subject: [PATCH 061/121] update price_documents_types --- app/controllers/application_controller.rb | 2 +- app/models/price_document.rb | 2 +- app/views/admin/price_documents/_price_document.html.haml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c9fffcc..0d72570 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -168,7 +168,7 @@ class ApplicationController < ActionController::Base end - set_sub_menu :documents, :"p_document_type_reponse_fournisseur", "Réponses fournisseurs", admin_price_documents_path(:price_document_type_id => 2) + set_sub_menu :documents, :"p_document_type_reponse_fournisseur", "Réponses fournisseurs", admin_price_documents_path(:price_document_type_id => 9) diff --git a/app/models/price_document.rb b/app/models/price_document.rb index 07c348c..9b8b83d 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -25,7 +25,7 @@ class PriceDocument < ApplicationRecord has_many :avoir_p_payment_documents, :dependent => :destroy, :foreign_key => :avoir_id, :class_name => "PPaymentDocument" accepts_nested_attributes_for :avoir_p_payment_documents, allow_destroy: true - PURCHASES = ["Demande prix", "Commande achat", "Facture d'achat"] + PURCHASES = ["Demande de prix", "Commande achat", "Facture d'achat"] SALES = ["Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] # AVANCEMENT = ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"] AVANCEMENT = ["0%", "25%", "50%", "75%", "100"] diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index 1422646..21b2a88 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -22,7 +22,7 @@ -tr[:p_fournisseur] = capture do %td - - if price_document.price_document_type_id == 2 + - if price_document.price_document_type.label == "Réponse fournisseur" -if price_document.p_fournisseur.present? = price_document.p_fournisseur.name - else @@ -135,7 +135,7 @@ -tr[:actions] = capture do %td.actions - -if price_document.price_document_type_id == 1 + -if price_document.price_document_type.label == "Demande de prix" =link_to i("bar-chart"), analyse_reponses_admin_price_document_path(price_document) -if !price_document.imported -if current_admin.has_permission?("payments") From 55c3c371b2a9726687158e4948d51826c9293425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 8 Sep 2021 15:12:10 +0200 Subject: [PATCH 062/121] WIP final consult --- .../admin/price_documents_controller.rb | 17 +++++++++++++++++ .../price_documents/final_consult.html.haml | 4 ++++ config/routes.rb | 2 ++ 3 files changed, 23 insertions(+) create mode 100644 app/views/admin/price_documents/final_consult.html.haml diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index f8cfc68..7cb043d 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -614,4 +614,21 @@ class Admin::PriceDocumentsController < ApplicationController @price_document_responses = PriceDocument.where(:doc_ref_id => @price_document.id ) end + + def final_consult + @params = params + @demande_prix = PriceDocument.find(params[:id]) + @final_consult = PriceDocument.new(price_document_type_id: 10) + # @final_consult.price_line_block.new(params.require[:price_document][:price_line_block_attributes].permit!) + # @price_document = PriceDocument.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) + # @price_document.price_document_type = PriceDocumentType.where(:label => "Réponse fournisseur").first + # @price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) + # @price_document.doc_ref_id = @demande.id + + # @ref_price_lines = @demande.price_line_block.price_lines + + # @ref_price_lines.group(:p_product_ref_id).each do |plr| + # @price_document.price_line_block.price_lines << PriceLine.new(:price_line_ref_id => plr.id, :p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) + # end + end end diff --git a/app/views/admin/price_documents/final_consult.html.haml b/app/views/admin/price_documents/final_consult.html.haml new file mode 100644 index 0000000..cb99cd5 --- /dev/null +++ b/app/views/admin/price_documents/final_consult.html.haml @@ -0,0 +1,4 @@ +%h1 Hello +=debug @final_consult +%h1 Params +=debug @params diff --git a/config/routes.rb b/config/routes.rb index 207c0f8..ff939f3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -627,7 +627,9 @@ Rails.application.routes.draw do get :consult_edit put :consult_update get :match_p_fournisseur + patch :match_p_fournisseur_save get :analyse_reponses + post :final_consult end collection do get :search_to_affect From 7f2208576d95e11d9c0d051c3a8222a9fafcf7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 8 Sep 2021 15:12:32 +0200 Subject: [PATCH 063/121] Update analyse --- .../analyse_reponses.html.haml | 59 +++++++++++++------ 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 32b719d..35139c9 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -8,7 +8,7 @@ = @price_document.list_designaton -unmatched_fournisseur = 0 -=semantic_form_for [:admin, @price_document], :html => {:class => "qi_price_form"}, :remote => false do |form| +=semantic_form_for [:admin, @price_document],url: final_consult_admin_price_document_path, method: :post, :html => {:class => "qi_price_form"}, :remote => false do |form| =form.semantic_fields_for :price_line_block do |f| - price_line_block = f.object .qi_pannel.padding.new_table_container @@ -26,9 +26,23 @@ Consultation %th{colspan: nb_resp} Fournisseurs - .btn.btn-light.ml-4#reset-radio + .btn.btn-light.mx-4#reset-radio reset - + .legend.d-flex + légende : + .inlie-block.d-flex.flex-wrap.justify-content-end + .mx-2.red + = ic("diamond") + " Spot detecté !" + .mx-2.green + = ic("money") + " Meilleur prix" + .mx-2.red + = ic(:times) + " Alerte marge basse" + .mx-2.green + = ic(:check) + " Marge ok" + .mx-2.orange + = ic(:warning) + " Alerte Qté" + .mx-2.info + = ic('info-circle') + " Commentaire fournisseur" %tr %th Qté à @@ -75,6 +89,7 @@ -@price_document_responses.each do |resp| %th + =resp.id -if resp.p_fournisseur =resp.p_fournisseur.name -else @@ -94,7 +109,6 @@ - price_line = form.object -#price_lines = @price_document.price_line_block.price_lines -#price_lines.each do |price_line| - %tr %td =# ATTENTION ! On a plus accès direct aux commandes qui on engendré cette demande de prix. donc plus accès aux délais différent entre les différentes commades pour une ref donée @@ -142,19 +156,22 @@ -#NICO : j'ai créé un hash plus haut, vide, qui va me permettre de faire correspondre à chaque ID de price_line leur index dans le nested form (qui est différent, une itération, de l'ID de l'élement... Là c'est la magie de rails.) - price_lines_child_index[form.object.id.to_s] = form.options[:child_index] - - + -best_price = PriceLine.where(price_line_ref_id: price_line.id).where("ct_u_price_ht > 0").order(:ct_u_price_ht).ids -#Nico : je commence, pour chaque price line, par faire une checkbox vide. J'aurais pu faire un checkbox tag mais par facilité j'ai copé l'HTML dans HTML2HAML et je suis partid du résultat. Les checkboxes sont ensuite dans ta boucle %input{:autocomplete => "off", :id => "price_document[price_line_block_attributes][price_lines_attributes][#{form.options[:child_index] }]_price_line_resp_ids_none", :name => "price_document[price_line_block_attributes][price_lines_attributes][#{form.options[:child_index] }][price_line_resp_ids][]", :type => "hidden", :value => ""}/ + =#{}"price doc id : #{@price_document_responses.ids}" + - @price_document_responses.each do |resp| -line = resp.price_line_block.price_lines.where(p_product_ref: price_line.p_product_ref).first -cell = [] - if line.qte_available.to_i > 0 - -if line.qte_available >= price_line.qte.to_i + - if line.id == best_price[0] + -cell << "#{ic(:money)} Meilleur prix" + - if line.qte_available >= price_line.qte.to_i - cell << "Qté dispo : #{line.qte_available.to_i}" - -else + - else - cell << "#{ic(:warning, class: "orange")} Qté dispo : #{line.qte_available.to_i} (#{line.qte_available.to_i - price_line.qte.to_i})" - cell << "PA: #{line.ct_u_price_ht} €" - # mp = calcul de la marge prévisionelle TODO @@ -174,20 +191,19 @@ - display_comment = line.comment - cell << "#{ic('info-circle')} #{display_comment}#{line.comment}" - %td.p-0 - = "reponse price_line ID : #{line.id}" - = "price line origine : #{line.price_line_ref_id}" #NICO : simple contrôle, je récupère facilement par là l'ID de la price Line concernée. + %td.p-0{class: ("best-price" if line.id == best_price[0])} + =# "reponse price_line ID : #{line.id}" + =# "price line origine : #{line.price_line_ref_id}" #NICO : simple contrôle, je récupère facilement par là l'ID de la price Line concernée. -#NICO : si on a un price_line_ref_id, j'ajoute la case à cocher. Je récupère l'index de nested form dans mon hash, et je passe en value le line.id -if line.price_line_ref_id.to_s != "" - %br - %label{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"} - %input{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/ - =line.id + %input.category-selector{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/ + %label.p-2.m-auto{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"} + =sanitize(cell.join('
')) - = radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "category-selector" - = label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('
')), class: "p-2 m-auto" + =# radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "category-selector" + =# label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('
')), class: "p-2 m-auto" - if unmatched_fournisseur == 0 =submit_tag 'valider la selection', class: "btn btn-primary ml-4" @@ -235,6 +251,12 @@ .category-selector:checked + label { background-color: #b4f99e !important; + border-radius: 1em; + border: green solid 0.2em; + } + + .best-price{ + background-color: #f8fdab !important; } .limit { @@ -250,6 +272,7 @@ .orange { color: orange; } + .info { color: #009bbf; position: relative; @@ -305,5 +328,5 @@ :javascript $( "#reset-radio" ).click(function(event){ - $( ":radio" ).prop('checked',false); + $('input:checkbox').prop('checked',false); }) From 3bf1514bcc62ddb481eb094a2567e5a910333d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 8 Sep 2021 16:20:58 +0200 Subject: [PATCH 064/121] Replace price_line form --- app/views/admin/price_lines/_form.html.haml | 225 ++++++++---------- .../admin/price_lines/_form_old.html.haml | 133 +++++++++++ 2 files changed, 236 insertions(+), 122 deletions(-) create mode 100644 app/views/admin/price_lines/_form_old.html.haml diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 7ad0661..42c6235 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -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"} - - %td - = form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte", tabindex: 1} + .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 - =#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-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 + .mx-4 + %span.destroy=link_to_remove_fields ic(:"trash-o"), form - = form.hidden_field :position, :class => "price_line_position_input" - + + + =qi_js_field(form, :price_line, :tva_account_value, :hidden => true) + + = 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); + + + + } + + + } ); + + + + + //return false + } + }); + + + + } ); diff --git a/app/views/admin/price_lines/_form_old.html.haml b/app/views/admin/price_lines/_form_old.html.haml new file mode 100644 index 0000000..60e70c1 --- /dev/null +++ b/app/views/admin/price_lines/_form_old.html.haml @@ -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" + From 455dc38ad8885e8a2b261c56d1b90fe28333c917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 8 Sep 2021 19:40:11 +0200 Subject: [PATCH 065/121] WIP Final consult --- .../admin/price_documents_controller.rb | 33 ++++++++++++++++--- .../analyse_reponses.html.haml | 2 +- .../price_documents/consult_index.html.haml | 2 ++ .../price_documents/final_consult.html.haml | 4 --- config/routes.rb | 1 + 5 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 app/views/admin/price_documents/consult_index.html.haml delete mode 100644 app/views/admin/price_documents/final_consult.html.haml diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 7cb043d..b2458c6 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -615,11 +615,26 @@ class Admin::PriceDocumentsController < ApplicationController end - def final_consult - @params = params - @demande_prix = PriceDocument.find(params[:id]) - @final_consult = PriceDocument.new(price_document_type_id: 10) - # @final_consult.price_line_block.new(params.require[:price_document][:price_line_block_attributes].permit!) + def generate_final_consult + # price_line_to_add ={id_fournisseur {price_line_resp_id: id, ||||| id priceline resp => id price line selectionné, prix} } + + price_lines_to_add = {p_fournisseur_id: 0} + + @price_document_demand = PriceDocument.find(params[:id]) + @price_document_responses = PriceDocument.where(doc_ref_id: price_document_demand) + @result = [] + + @price_document_demand.price_line_block.price_lines.each do |pl_demand| + pl_response = pl_demand.price_line_resps.first + @p_fournisseur = PFournisseur.find(pl_response) + @final_consult.price_line_block.new(params.require[:price_document][:price_line_block_attributes].permit!) + @price_document = PriceDocument.new(:p_fournisseur_id => params[:p_fournisseur_id]) + + PriceDocument.new() + @result << pl_demand + render :consult_index + + # @price_document = PriceDocument.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) # @price_document.price_document_type = PriceDocumentType.where(:label => "Réponse fournisseur").first # @price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) @@ -631,4 +646,12 @@ class Admin::PriceDocumentsController < ApplicationController # @price_document.price_line_block.price_lines << PriceLine.new(:price_line_ref_id => plr.id, :p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) # end end + + def final_consult + @price_document = PriceDocument.find(params[:id]) + if @price_document.update_attributes(params.require(:price_document).permit!) + else + render :edit + end + end end diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 35139c9..2e027e3 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -224,7 +224,7 @@ .modal-footer %button.btn.btn-light{"data-dismiss" => "modal"} Close - +=link_to "Generer les consultations", generate_final_consult_admin_price_document_path, class: "btn btn-primary ml-4 mt-4" diff --git a/app/views/admin/price_documents/consult_index.html.haml b/app/views/admin/price_documents/consult_index.html.haml new file mode 100644 index 0000000..4ffa515 --- /dev/null +++ b/app/views/admin/price_documents/consult_index.html.haml @@ -0,0 +1,2 @@ +%h1 Hello +=debug @result diff --git a/app/views/admin/price_documents/final_consult.html.haml b/app/views/admin/price_documents/final_consult.html.haml deleted file mode 100644 index cb99cd5..0000000 --- a/app/views/admin/price_documents/final_consult.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -%h1 Hello -=debug @final_consult -%h1 Params -=debug @params diff --git a/config/routes.rb b/config/routes.rb index ff939f3..dbbb448 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -630,6 +630,7 @@ Rails.application.routes.draw do patch :match_p_fournisseur_save get :analyse_reponses post :final_consult + get :generate_final_consult end collection do get :search_to_affect From 26e36e8c3814e0f8d952df26f92dc291310243c8 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Wed, 8 Sep 2021 22:23:06 +0200 Subject: [PATCH 066/121] Suite consultation fournisseurs --- .../admin/price_documents_controller.rb | 55 ++++++-- app/models/price_document.rb | 2 +- app/models/price_line.rb | 2 + app/models/price_line_block.rb | 2 +- .../price_documents/_price_document.html.haml | 17 ++- .../analyse_reponses.html.haml | 4 +- .../admin/price_documents/show.html.haml | 131 ++++++++++-------- 7 files changed, 138 insertions(+), 75 deletions(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index b2458c6..542942d 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -611,27 +611,60 @@ class Admin::PriceDocumentsController < ApplicationController def analyse_reponses @price_document = PriceDocument.find(params[:id]) - @price_document_responses = PriceDocument.where(:doc_ref_id => @price_document.id ) + @price_document_responses = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Réponse fournisseur").id ) end def generate_final_consult # price_line_to_add ={id_fournisseur {price_line_resp_id: id, ||||| id priceline resp => id price line selectionné, prix} } - - price_lines_to_add = {p_fournisseur_id: 0} + + price_lines_to_add = {} @price_document_demand = PriceDocument.find(params[:id]) - @price_document_responses = PriceDocument.where(doc_ref_id: price_document_demand) - @result = [] + #@price_document_responses = PriceDocument.where(doc_ref_id: price_document_demand) + #@result = [] @price_document_demand.price_line_block.price_lines.each do |pl_demand| - pl_response = pl_demand.price_line_resps.first - @p_fournisseur = PFournisseur.find(pl_response) - @final_consult.price_line_block.new(params.require[:price_document][:price_line_block_attributes].permit!) - @price_document = PriceDocument.new(:p_fournisseur_id => params[:p_fournisseur_id]) + + pl_demand.price_line_resps.all.each do |price_line_resp| + + price_lines_to_add[price_line_resp.p_fournisseur.id] = price_lines_to_add[price_line_resp.p_fournisseur.id] || {:p_fournisseur => price_line_resp.p_fournisseur, :price_lines => [] } + + + price_lines_to_add[price_line_resp.p_fournisseur.id][:price_lines] << price_line_resp + + + end + + end + + + + + price_lines_to_add.each do |k,v| + new_final_consult = PriceDocument.new(:doc_ref_id => @price_document_demand.id,:date => Date.today, :price_document_type => PriceDocumentType.find_by_label("Consultation fournisseur")) + new_final_consult.price_line_block = PriceLineBlock.new(:p_fournisseur => v[:p_fournisseur]) + + v[:price_lines].each do |price_line_resp| + new_final_consult.price_line_block.price_lines << PriceLine.new(:p_product_ref => price_line_resp.p_product_ref, :qte => price_line_resp.qte_available, :ct_u_price_ht => price_line_resp.price_u_ht ) + end + + new_final_consult.save + + end + + + #pl_response = pl_demand.price_line_resps.first + #@p_fournisseur = PFournisseur.find(pl_response) + #@final_consult.price_line_block.new(params.require[:price_document][:price_line_block_attributes].permit!) + #@price_document = PriceDocument.new(:p_fournisseur_id => params[:p_fournisseur_id]) - PriceDocument.new() - @result << pl_demand + #PriceDocument.new() + #@result << pl_demand + + #end + + render :consult_index diff --git a/app/models/price_document.rb b/app/models/price_document.rb index 9b8b83d..8ed50a1 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -25,7 +25,7 @@ class PriceDocument < ApplicationRecord has_many :avoir_p_payment_documents, :dependent => :destroy, :foreign_key => :avoir_id, :class_name => "PPaymentDocument" accepts_nested_attributes_for :avoir_p_payment_documents, allow_destroy: true - PURCHASES = ["Demande de prix", "Commande achat", "Facture d'achat"] + PURCHASES = ["Demande prix", "Réponse fournisseur", "Commande achat", "Facture d'achat", "Consultation fournisseur"] SALES = ["Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] # AVANCEMENT = ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"] AVANCEMENT = ["0%", "25%", "50%", "75%", "100"] diff --git a/app/models/price_line.rb b/app/models/price_line.rb index 0eba34d..f156d9b 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -7,6 +7,8 @@ class PriceLine < ApplicationRecord has_many :price_line_resps, through: :price_line_resp_selects, :source => :price_line_resp + has_one :p_fournisseur, :through => :price_line_block + #has_many :price_line_demands, through: :price_line_resp_selects default_scope { order('position ASC') } diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index 14b7469..7e9ea94 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -23,7 +23,7 @@ class PriceLineBlock < ApplicationRecord belongs_to :p_payment_type - PURCHASE_BLOCKS = ["Facture d'achat", "Commande achat"] + PURCHASE_BLOCKS = ["Demande prix", "Réponse fournisseur", "Commande achat", "Facture d'achat", "Consultation fournisseur"] SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] belongs_to :p_fournisseur diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index 21b2a88..29b43ac 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -69,12 +69,15 @@ %td - if price_document.avancement = price_document.avancement.to_s + " %" - - elsif parent_doc.avancement + - elsif parent_doc and parent_doc.avancement = parent_doc.avancement.to_s + " %" -tr[:list_designaton] = capture do %td - = price_document.list_designaton || parent_doc.list_designaton + -if price_document.list_designaton + = price_document.list_designaton + -elsif parent_doc + =parent_doc.list_designaton -tr[:end_date] = capture do %td @@ -87,11 +90,17 @@ -tr[:dp_comment] = capture do %td - = price_document.dp_comment || parent_doc.dp_comment + -if price_document.dp_comment + = price_document.dp_comment + -elsif parent_doc + =parent_doc.dp_comment -tr[:acheteur_text] = capture do %td - = price_document.acheteur_text || parent_doc.acheteur_text + -if price_document.acheteur_text + = price_document.acheteur_text + -elsif parent_doc + =parent_doc.acheteur_text -tr[:customer_ref] = capture do %td diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 2e027e3..67ae51e 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -197,8 +197,8 @@ -#NICO : si on a un price_line_ref_id, j'ajoute la case à cocher. Je récupère l'index de nested form dans mon hash, et je passe en value le line.id -if line.price_line_ref_id.to_s != "" - %input.category-selector{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/ - %label.p-2.m-auto{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"} + %input.category-selectornico{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/ + %label.p-2.m-autonico{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"} =sanitize(cell.join('
')) diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index c1be467..2ce92e1 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -25,62 +25,61 @@ =@price_document.d_number --if @price_document.label == "Réponse fournisseur" - .qi_row - .qi_pannel.padding - - %table.table.table-striped - %tr - %td - Nom fournisseur saisi - %td - =@price_document.public_fournisseur_name - %tr - %td - Fournisseur - %td - =link_to @price_document.p_fournisseur.name, [:admin, @price_document.p_fournisseur] if @price_document.p_fournisseur - +.qi_row + %table.table.table-striped + -if @price_document.label == "Réponse fournisseur" + + %tr + %td + Nom fournisseur saisi + %td + =@price_document.public_fournisseur_name + + -if @price_document.p_fournisseur + %tr + %td + Fournisseur + %td + =link_to @price_document.p_fournisseur.name, [:admin, @price_document.p_fournisseur] if @price_document.p_fournisseur + --if @price_document.label == "Demande prix" - .qi_row - .qi_pannel.padding - %table.table.table-striped - %tr - %td - Avancement (%) - %td - =@price_document.avancement.to_s + " %" - %tr - %td - Désignation - %td - =@price_document.list_designaton - - %tr - %td Date de fin de consultation : - %td - =l @price_document.end_date if @price_document.end_date - - %tr - %td Commentaire - %td - =simple_format @price_document.dp_comment - - %tr - %td - Envoyé à - %td - =simple_format @price_document.acheteur_text - - %tr - %td - Lien pour consultation - %td - =link_to consult_admin_price_document_url(:id => @price_document.f_token, :lang => nil), consult_admin_price_document_url(:id => @price_document.f_token, :lang => nil) + + -if @price_document.label == "Demande prix" + %tr + %td + Avancement (%) + %td + =@price_document.avancement.to_s + " %" + %tr + %td + Désignation + %td + =@price_document.list_designaton + + %tr + %td Date de fin de consultation : + %td + =l @price_document.end_date if @price_document.end_date + %tr + %td Commentaire + %td + =simple_format @price_document.dp_comment + + %tr + %td + Envoyé à + %td + =simple_format @price_document.acheteur_text + + %tr + %td + Lien pour consultation + %td + =link_to consult_admin_price_document_url(:id => @price_document.f_token, :lang => nil), consult_admin_price_document_url(:id => @price_document.f_token, :lang => nil) + .qi_row @@ -90,12 +89,12 @@ - -if false + -if true -price_line_block = @price_document.price_line_block - =render price_line_block + =#render price_line_block -else -params[:search][:per_page] = params[:search][:per_page] || 5000 @@ -321,14 +320,34 @@ -if @price_document.label == "Demande prix" - %h3 Réponses fournisseur #bills -params[:search][:per_page] = params[:search][:per_page] || 5000 -per_page = params[:search][:per_page] -page = (params[:page] and params[:page] != "") ? params[:page] : 1 - -@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id ) + -@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Réponse fournisseur").id) + + + + + -@price_documents = sort_by_sorting(@price_documents, "created_at DESC") + -@price_documents = @price_documents.page(page).per(per_page) + %br + + + + .clear + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"} + + + %h3 Consultations fournisseur + #bills + -params[:search][:per_page] = params[:search][:per_page] || 5000 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + + -@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Consultation fournisseur").id) From 9abd0b87cf101eb02e3ddb1cc5f36afd734432ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 9 Sep 2021 12:51:15 +0200 Subject: [PATCH 067/121] remove final consult --- .../admin/price_documents_controller.rb | 64 +++++-------------- .../analyse_reponses.html.haml | 2 +- .../price_documents/consult_index.html.haml | 2 - config/routes.rb | 2 +- 4 files changed, 17 insertions(+), 53 deletions(-) delete mode 100644 app/views/admin/price_documents/consult_index.html.haml diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 542942d..6fa1ad2 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -612,35 +612,32 @@ class Admin::PriceDocumentsController < ApplicationController def analyse_reponses @price_document = PriceDocument.find(params[:id]) @price_document_responses = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Réponse fournisseur").id ) - end + def analyse_reponses_save + @price_document = PriceDocument.find(params[:id]) + if @price_document.update_attributes(params.require(:price_document).permit!) + redirect_to :analyse_reponses_admin_price_document + else + render :edit + end + end + + def generate_final_consult - # price_line_to_add ={id_fournisseur {price_line_resp_id: id, ||||| id priceline resp => id price line selectionné, prix} } - price_lines_to_add = {} @price_document_demand = PriceDocument.find(params[:id]) - #@price_document_responses = PriceDocument.where(doc_ref_id: price_document_demand) - #@result = [] @price_document_demand.price_line_block.price_lines.each do |pl_demand| pl_demand.price_line_resps.all.each do |price_line_resp| - price_lines_to_add[price_line_resp.p_fournisseur.id] = price_lines_to_add[price_line_resp.p_fournisseur.id] || {:p_fournisseur => price_line_resp.p_fournisseur, :price_lines => [] } - - price_lines_to_add[price_line_resp.p_fournisseur.id][:price_lines] << price_line_resp - - end - + end - - - price_lines_to_add.each do |k,v| new_final_consult = PriceDocument.new(:doc_ref_id => @price_document_demand.id,:date => Date.today, :price_document_type => PriceDocumentType.find_by_label("Consultation fournisseur")) new_final_consult.price_line_block = PriceLineBlock.new(:p_fournisseur => v[:p_fournisseur]) @@ -648,43 +645,12 @@ class Admin::PriceDocumentsController < ApplicationController v[:price_lines].each do |price_line_resp| new_final_consult.price_line_block.price_lines << PriceLine.new(:p_product_ref => price_line_resp.p_product_ref, :qte => price_line_resp.qte_available, :ct_u_price_ht => price_line_resp.price_u_ht ) end - + new_final_consult.save - + end - - - #pl_response = pl_demand.price_line_resps.first - #@p_fournisseur = PFournisseur.find(pl_response) - #@final_consult.price_line_block.new(params.require[:price_document][:price_line_block_attributes].permit!) - #@price_document = PriceDocument.new(:p_fournisseur_id => params[:p_fournisseur_id]) - #PriceDocument.new() - #@result << pl_demand - - #end - - - render :consult_index - - - # @price_document = PriceDocument.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) - # @price_document.price_document_type = PriceDocumentType.where(:label => "Réponse fournisseur").first - # @price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) - # @price_document.doc_ref_id = @demande.id - - # @ref_price_lines = @demande.price_line_block.price_lines - - # @ref_price_lines.group(:p_product_ref_id).each do |plr| - # @price_document.price_line_block.price_lines << PriceLine.new(:price_line_ref_id => plr.id, :p_product_ref_id => plr.p_product_ref_id, :qte => @ref_price_lines.where(:p_product_ref_id => plr.p_product_ref_id).sum(:qte)) - # end - end - - def final_consult - @price_document = PriceDocument.find(params[:id]) - if @price_document.update_attributes(params.require(:price_document).permit!) - else - render :edit - end + @final_consult = PriceDocument.where(price_document_type: PriceDocumentType.find_by_label("Consultation fournisseur")).last + redirect_to :analyse_reponses_admin_price_document end end diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 67ae51e..f0adeb4 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -8,7 +8,7 @@ = @price_document.list_designaton -unmatched_fournisseur = 0 -=semantic_form_for [:admin, @price_document],url: final_consult_admin_price_document_path, method: :post, :html => {:class => "qi_price_form"}, :remote => false do |form| +=semantic_form_for [:admin, @price_document],url: analyse_reponses_save_admin_price_document_path, method: :post, :html => {:class => "qi_price_form"}, :remote => false do |form| =form.semantic_fields_for :price_line_block do |f| - price_line_block = f.object .qi_pannel.padding.new_table_container diff --git a/app/views/admin/price_documents/consult_index.html.haml b/app/views/admin/price_documents/consult_index.html.haml deleted file mode 100644 index 4ffa515..0000000 --- a/app/views/admin/price_documents/consult_index.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -%h1 Hello -=debug @result diff --git a/config/routes.rb b/config/routes.rb index dbbb448..83c02a0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -629,7 +629,7 @@ Rails.application.routes.draw do get :match_p_fournisseur patch :match_p_fournisseur_save get :analyse_reponses - post :final_consult + post :analyse_reponses_save get :generate_final_consult end collection do From aca25bb1cb8547f621906c04ba60e1c4d71fecfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 9 Sep 2021 12:52:14 +0200 Subject: [PATCH 068/121] bugfix doc type name --- app/controllers/application_controller.rb | 2 +- app/views/admin/price_documents/_price_document.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0d72570..0e10c2f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -168,7 +168,7 @@ class ApplicationController < ActionController::Base end - set_sub_menu :documents, :"p_document_type_reponse_fournisseur", "Réponses fournisseurs", admin_price_documents_path(:price_document_type_id => 9) + # set_sub_menu :documents, :"p_document_type_reponse_fournisseur", "Réponses fournisseurs", admin_price_documents_path(:price_document_type_id => PriceDocumentType.find_by(label: "Réponse fournisseur").id) diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index 29b43ac..68fe2c3 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -144,7 +144,7 @@ -tr[:actions] = capture do %td.actions - -if price_document.price_document_type.label == "Demande de prix" + -if price_document.price_document_type.label == "Demande prix" =link_to i("bar-chart"), analyse_reponses_admin_price_document_path(price_document) -if !price_document.imported -if current_admin.has_permission?("payments") From 6771c8050fb6f8d5f64a0943f181504484ab1f49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 9 Sep 2021 12:54:08 +0200 Subject: [PATCH 069/121] Remove jaune pisse --- .../analyse_reponses.html.haml | 50 +++++++++++++++---- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index f0adeb4..1a9df9d 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -197,12 +197,12 @@ -#NICO : si on a un price_line_ref_id, j'ajoute la case à cocher. Je récupère l'index de nested form dans mon hash, et je passe en value le line.id -if line.price_line_ref_id.to_s != "" - %input.category-selectornico{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/ - %label.p-2.m-autonico{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"} + %input.seletable_price{:id => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}" , :autocomplete => "off", :checked => ("checked" if PriceLine.find(line.price_line_ref_id).price_line_resp_ids.include?(line.id) ), :name => "price_document[price_line_block_attributes][price_lines_attributes][#{price_lines_child_index[line.price_line_ref_id.to_s]}][price_line_resp_ids][]", :type => "checkbox", :value => line.id}>/ + %label.p-2.m-auto{:for => "price_document_price_line_block_attributes_price_lines_attributes_#{price_lines_child_index[line.price_line_ref_id.to_s]}_price_line_resp_ids_#{line.id}"} =sanitize(cell.join('
')) - =# radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "category-selector" + =# radio_button_tag "ref_price_selected_#{price_line.p_product_ref.id}", line.id, false, class: "seletable_price" =# label_tag "ref_price_selected_#{price_line.p_product_ref.id}_#{line.id}", sanitize(cell.join('
')), class: "p-2 m-auto" - if unmatched_fournisseur == 0 @@ -234,29 +234,61 @@ + :scss - .category-selector { + .seletable_price { position: absolute; transform: scale(0); } - .category-selector + label { + .seletable_price + label { display: block; min-height: 105px; cursor: pointer; box-sizing: border-box; width: 100%; text-align: left; + + &:hover{ + background:linear-gradient(to top, #efefef 5%, #fdfdfd 100%); + background-color:#5cb811; + } + &:active{ + position:relative; + top:1px; + } } - .category-selector:checked + label { - background-color: #b4f99e !important; + .seletable_priceOLD:checked + label { + background-color: green !important; border-radius: 1em; - border: green solid 0.2em; + border: darkgreen solid 0.2em; + mix-blend-mode: difference; + } + .seletable_price:checked + label{ + box-shadow:inset 0px 1px 0px 0px #caefab; + background:linear-gradient(to bottom, #77d42a 5%, #5cb811 100%); + background-color:#77d42a; + border-radius:6px; + border:1px solid #268a16; + display:inline-block; + cursor:pointer; + color:#306108; + font-family:Arial; + font-size:15px; + font-weight:bold; + padding:6px 24px; + text-decoration:none; + text-shadow:0px 1px 0px #aade7c; + + &:hover{ + background:linear-gradient(to bottom, #5cb811 5%, #77d42a 100%); + background-color:#5cb811; + } } .best-price{ - background-color: #f8fdab !important; + background-color: #b4f99e !important; } .limit { From de98227be7668e33a8a169b82cfc8eb148b7340c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 9 Sep 2021 12:54:31 +0200 Subject: [PATCH 070/121] add button to consult --- .../price_documents/analyse_reponses.html.haml | 1 + app/views/admin/price_documents/show.html.haml | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 1a9df9d..f4c2572 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -226,6 +226,7 @@ Close =link_to "Generer les consultations", generate_final_consult_admin_price_document_path, class: "btn btn-primary ml-4 mt-4" +=link_to "Acceder aux consultations", admin_price_document_path(@price_document, anchor: "consult"), class: "btn btn-primary ml-4 mt-4" diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 2ce92e1..98256c1 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -342,7 +342,7 @@ %h3 Consultations fournisseur - #bills + #consult -params[:search][:per_page] = params[:search][:per_page] || 5000 -per_page = params[:search][:per_page] -page = (params[:page] and params[:page] != "") ? params[:page] : 1 @@ -360,4 +360,16 @@ .clear =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"} - + -if @price_documents.empty? + .qi_pannel.qi_plain.padding + Pas de consultation générée. + %br + 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| + %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} From de726629982a669af89f48518468be047172afa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 9 Sep 2021 13:05:31 +0200 Subject: [PATCH 071/121] inlie Qte --- app/views/admin/price_lines/_form.html.haml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 42c6235..9eb6281 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -15,11 +15,13 @@ -if form.object.forced_price and form.object.p_product_ref %td .mx-4 - =qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :", :value => form.object.th_price_u_ht) + .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-4 - =qi_js_field(form, :price_line, :price_u_ht, :label => "Prix U HT :") + .mx-3 + .form-inline + =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"} @@ -34,7 +36,7 @@ %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 - .mx-4 + .ml-4 %span.destroy=link_to_remove_fields ic(:"trash-o"), form From 00e390f50b5ed37b5ac3e50741cdfb6aa3100107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 9 Sep 2021 14:04:22 +0200 Subject: [PATCH 072/121] finx indent --- app/views/admin/p_customer_sheets/_form.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/p_customer_sheets/_form.html.haml b/app/views/admin/p_customer_sheets/_form.html.haml index 6b0e3c0..2c1194a 100755 --- a/app/views/admin/p_customer_sheets/_form.html.haml +++ b/app/views/admin/p_customer_sheets/_form.html.haml @@ -22,7 +22,7 @@ =yield :price_lines .large_actions .actions - =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" - =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" + =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" + =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" .clear From 1e5316a3bfba79c292634af981bb7a95c55b2d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 9 Sep 2021 18:53:57 +0200 Subject: [PATCH 073/121] Wip show consult --- app/helpers/application_helper.rb | 15 +- .../admin/price_documents/show.html.haml | 27 +- app/views/admin/price_lines/_form.html.haml | 238 ++++++------------ .../admin/price_lines/_form_consult.html.haml | 27 ++ 4 files changed, 134 insertions(+), 173 deletions(-) create mode 100644 app/views/admin/price_lines/_form_consult.html.haml diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9e30dd0..31e8de0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 ('
') diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 98256c1..2059688 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -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") + } + + diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 3cc5a9b..77c4f79 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -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 + } + }); + }); diff --git a/app/views/admin/price_lines/_form_consult.html.haml b/app/views/admin/price_lines/_form_consult.html.haml new file mode 100644 index 0000000..61f9872 --- /dev/null +++ b/app/views/admin/price_lines/_form_consult.html.haml @@ -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" + From 6f00816efc1d438df0ea39c5bc343d1b21608154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 10 Sep 2021 10:48:24 +0200 Subject: [PATCH 074/121] Copy to clipboard --- .../admin/price_documents/show.html.haml | 60 ++++++++++++++----- .../admin/price_lines/_form_consult.html.haml | 21 ++++--- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 2059688..07b10c7 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -320,7 +320,7 @@ -if @price_document.label == "Demande prix" - %h3 Réponses fournisseur + %h3.ml-2 Réponses fournisseur #bills -params[:search][:per_page] = params[:search][:per_page] || 5000 -per_page = params[:search][:per_page] @@ -341,7 +341,7 @@ =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"} - %h3 Consultations fournisseur + %h3.ml-2 Consultations fournisseur #consult -params[:search][:per_page] = params[:search][:per_page] || 5000 -per_page = params[:search][:per_page] @@ -370,25 +370,55 @@ -@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 + %h4.ml-2= price_document_consult.p_fournisseur.name = 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" + = form.button "Valider modifications)", type: :submit, class: "btn btn-primary m-2" + =link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)' .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} + .mx-2 + =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") + let priceDocumentId = event.target.dataset.document + let names = $(`.p_product_ref_cc_name_${priceDocumentId}`) + let qtes = $(`.input_price_line_qte_${priceDocumentId}`) + let prices = $(`.price_line_price_u_ht_${priceDocumentId}`) + + let table = [] + names.each(function( i ) { + let row = [] + row.push(qtes[i].valueAsNumber) + row.push(" X ") + row.push(names[i].innerText) + row.push(" @ ") + row.push(prices[i].innerText) + table.push(row.join(' ')) + }) + copyStringToClipboard(table.join('\r\n')) } - + function copyStringToClipboard (str) { + // Create new element + var el = document.createElement('textarea'); + // Set value (string to be copied) + el.value = str; + // Set non-editable to avoid focus and move outside of view + el.setAttribute('readonly', ''); + el.style = {position: 'absolute', left: '-9999px'}; + document.body.appendChild(el); + // Select text inside element + el.select(); + // Copy text to clipboard + document.execCommand('copy'); + // Remove temporary element + document.body.removeChild(el); + } diff --git a/app/views/admin/price_lines/_form_consult.html.haml b/app/views/admin/price_lines/_form_consult.html.haml index 61f9872..64841df 100644 --- a/app/views/admin/price_lines/_form_consult.html.haml +++ b/app/views/admin/price_lines/_form_consult.html.haml @@ -1,20 +1,23 @@ - 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 + .col-6.d-flex + .take.mr-4 =ic :arrows - .col-6 - Produit : - =price_line.p_product_ref.cc_name + .mr-1 + ref : + %div{class: "p_product_ref_cc_name_#{price_line.price_line_block.price_lineable_id}"} + =price_line.p_product_ref.cc_name - .col-2 + + .col-3.d-flex Base de prix U HT : - = price_line.price_u_ht - € + %div{class: "mx-1 price_line_price_u_ht_#{price_line.price_line_block.price_lineable_id}"} + = 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} + = form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte_#{price_line.price_line_block.price_lineable_id} 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" From 2fe82678a5710d7365dd1e4e89ad3e0149525261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 10 Sep 2021 12:54:45 +0200 Subject: [PATCH 075/121] move tooltip to admin.scss --- app/assets/stylesheets/admin.scss | 86 ++++++++++++++++++- .../analyse_reponses.html.haml | 46 +--------- 2 files changed, 86 insertions(+), 46 deletions(-) diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index a53341c..cb1ee54 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -1782,4 +1782,88 @@ td{ } -// Fin \ No newline at end of file + +// Html5 Tooltip +.info { + color: #009bbf; + position: relative; + display: inline-block; + text-overflow: ellipsis; + + .info-text-top { + visibility: hidden; + background-color: #555; + color: #fff; + text-align: center; + padding: 5px; + border-radius: 6px; + max-width: 500px; + min-width: fit-content; + white-space: normal; + + /* Position the tooltip text */ + position: absolute; + z-index: 1; + bottom: 125%; + left: 50%; + margin-left: -60px; + + /* Fade in tooltip */ + opacity: 0; + transition: opacity 0.3s; + } + .info-text-top::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: #555 transparent transparent transparent; + } + .info-text-bottom { + visibility: hidden; + background-color: #555; + color: #fff; + text-align: center; + padding: 5px; + border-radius: 6px; + max-width: 500px; + min-width: fit-content; + white-space: normal; + + /* Position the tooltip text */ + position: absolute; + z-index: 1; + top: 125%; + left: 200%; + margin-left: -60px; + + /* Fade in tooltip */ + opacity: 0; + transition: opacity 0.3s; + } + .info-text-bottom::after { + content: ""; + position: absolute; + bottom: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: transparent transparent #555 transparent; + } +} +.info:hover { + .info-text-top { + visibility: visible; + opacity: 1; + } + .info-text-bottom { + visibility: visible; + opacity: 1; + } +} + +// Fin diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index f4c2572..b88eab3 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -189,7 +189,7 @@ - display_comment = "#{line.comment[0..10]} (..)" - else - display_comment = line.comment - - cell << "#{ic('info-circle')} #{display_comment}#{line.comment}" + - cell << "#{ic('info-circle')} #{display_comment}#{line.comment}" %td.p-0{class: ("best-price" if line.id == best_price[0])} =# "reponse price_line ID : #{line.id}" @@ -306,51 +306,7 @@ color: orange; } - .info { - color: #009bbf; - position: relative; - display: inline-block; - text-overflow: ellipsis; - .info-text { - visibility: hidden; - background-color: #555; - color: #fff; - text-align: center; - padding: 5px; - border-radius: 6px; - max-width: 500px; - min-width: fit-content; - white-space: normal; - - /* Position the tooltip text */ - position: absolute; - z-index: 1; - bottom: 125%; - left: 50%; - margin-left: -60px; - - /* Fade in tooltip */ - opacity: 0; - transition: opacity 0.3s; - } - .info-text::after { - content: ""; - position: absolute; - top: 100%; - left: 50%; - margin-left: -5px; - border-width: 5px; - border-style: solid; - border-color: #555 transparent transparent transparent; - } - } - .info:hover { - .info-text { - visibility: visible; - opacity: 1; - } - } .darkblue { color: darkblue; } From f20dda1f15218c05d4c0ec89d1683f752e470efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 10 Sep 2021 12:55:32 +0200 Subject: [PATCH 076/121] =?UTF-8?q?remove=200=20qt=C3=A9=20price=5Fline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin/price_documents_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 6fa1ad2..7a40418 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -239,7 +239,9 @@ class Admin::PriceDocumentsController < ApplicationController p_product_ref_qte = params[:qte].values p_product_ref_id.each_with_index do |key, i| - @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => key, :qte => p_product_ref_qte[i]) + if p_product_ref_qte[i].to_i > 0 + @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => key, :qte => p_product_ref_qte[i]) + end end # @ref_price_lines = PriceLine.where(:id => params[:price_line_ids]) From 9a752ac1a7c49a5efdc0229ba4ec3ff6b56ffccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 10 Sep 2021 12:56:12 +0200 Subject: [PATCH 077/121] =?UTF-8?q?pre-fill=20Qt=C3=A9=20+=20tooltip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/buy_lists/index.html.haml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 37beefd..cb6bed8 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -104,6 +104,9 @@ Qté en stock %th.mask Qté souhaité + %span.info + =ic("info-circle") + %span.info-text-bottom BPA - Qté en stock %th.mask BPA %th.mask AV BPA %th.mask PAS BPA @@ -131,6 +134,9 @@ -ppr_lines = @price_lines.where(:p_product_ref_id => plr.p_product_ref.id) %tr.ref_tr + - bpa_qte = ppr_lines.where(:cc_state => "BPA").sum(:qte).to_i + - qte_available = LineStock.where(p_product_ref_id: plr.p_product_ref.id).sum(:qte_available).to_i + -if checkbox %td @@ -165,13 +171,12 @@ =ic(:hourglass) =ppr_lines.asap_triage(20).last %td.mask - = LineStock.where(p_product_ref_id: plr.p_product_ref.id).sum(:qte_available).to_i + = qte_available + %td.mask + =number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: (bpa_qte - qte_available) %td.mask - =text_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input" - - %td.mask - =ppr_lines.where(:cc_state => "BPA").sum(:qte).to_i + = bpa_qte %td.mask =ppr_lines.where(:cc_state => "AV BPA").sum(:qte).to_i %td.mask From e8d66c91d7e83accc9a6b42e71bfa677c46bd375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 10 Sep 2021 17:21:28 +0200 Subject: [PATCH 078/121] Skip p_fournisseur validation for demande de prix --- app/models/price_line_block.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index 7e9ea94..3a048e0 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -23,9 +23,9 @@ class PriceLineBlock < ApplicationRecord belongs_to :p_payment_type - PURCHASE_BLOCKS = ["Demande prix", "Réponse fournisseur", "Commande achat", "Facture d'achat", "Consultation fournisseur"] + PURCHASE_BLOCKS = [ "Réponse fournisseur", "Commande achat", "Facture d'achat", "Consultation fournisseur"] SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] - + belongs_to :p_fournisseur accepts_nested_attributes_for :p_fournisseur From ce6a7a6c91f410fb65fbea3dfbc4f423f615a6bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 10 Sep 2021 17:21:41 +0200 Subject: [PATCH 079/121] Generate commande achat --- .../admin/price_documents_controller.rb | 15 ++++ .../admin/price_documents/show.html.haml | 74 ++++++++++--------- config/routes.rb | 1 + 3 files changed, 54 insertions(+), 36 deletions(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 7a40418..ccb68b1 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -655,4 +655,19 @@ class Admin::PriceDocumentsController < ApplicationController @final_consult = PriceDocument.where(price_document_type: PriceDocumentType.find_by_label("Consultation fournisseur")).last redirect_to :analyse_reponses_admin_price_document end + + def buy_order_create + + @final_consult = PriceDocument.find(params[:id]) + price_line_block = PriceLineBlock.new(p_fournisseur: @final_consult.price_line_block.p_fournisseur) + price_lines = PriceLine.where(price_line_block: @final_consult.price_line_block) + + @price_document = PriceDocument.new(date: Date.today, price_line_block: price_line_block, doc_ref_id: @final_consult.id, :price_document_type => PriceDocumentType.find_by_label("Commande achat")) + price_lines.each do |pl| + @price_document.price_line_block.price_lines << PriceLine.new(p_product_ref: pl.p_product_ref, qte: pl.qte, ct_u_price_ht: pl.price_u_ht) + end + if @price_document.save! + redirect_to admin_price_document_path(@price_document) + end + end end diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 07b10c7..838b25f 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -371,9 +371,11 @@ -@price_documents.each do |price_document_consult| %h4.ml-2= price_document_consult.p_fournisseur.name + = semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form| = form.button "Valider modifications)", type: :submit, class: "btn btn-primary m-2" - =link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)' + = link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)' + = link_to "Generer la commande", buy_order_create_admin_price_document_path(price_document_consult) .price-lines{"data-document" => price_document_consult.id} =form.semantic_fields_for :price_line_block do |f| .mx-2 @@ -385,40 +387,40 @@ -:javascript - const copyPriceLines = (event) => { - event.preventDefault() - let priceDocumentId = event.target.dataset.document - let names = $(`.p_product_ref_cc_name_${priceDocumentId}`) - let qtes = $(`.input_price_line_qte_${priceDocumentId}`) - let prices = $(`.price_line_price_u_ht_${priceDocumentId}`) + :javascript + const copyPriceLines = (event) => { + event.preventDefault() + let priceDocumentId = event.target.dataset.document + let names = $(`.p_product_ref_cc_name_${priceDocumentId}`) + let qtes = $(`.input_price_line_qte_${priceDocumentId}`) + let prices = $(`.price_line_price_u_ht_${priceDocumentId}`) - let table = [] - names.each(function( i ) { - let row = [] - row.push(qtes[i].valueAsNumber) - row.push(" X ") - row.push(names[i].innerText) - row.push(" @ ") - row.push(prices[i].innerText) - table.push(row.join(' ')) - }) - copyStringToClipboard(table.join('\r\n')) - } + let table = [] + names.each(function( i ) { + let row = [] + row.push(qtes[i].valueAsNumber) + row.push(" X ") + row.push(names[i].innerText) + row.push(" @ ") + row.push(prices[i].innerText) + table.push(row.join(' ')) + }) + copyStringToClipboard(table.join('\r\n')) + } - function copyStringToClipboard (str) { - // Create new element - var el = document.createElement('textarea'); - // Set value (string to be copied) - el.value = str; - // Set non-editable to avoid focus and move outside of view - el.setAttribute('readonly', ''); - el.style = {position: 'absolute', left: '-9999px'}; - document.body.appendChild(el); - // Select text inside element - el.select(); - // Copy text to clipboard - document.execCommand('copy'); - // Remove temporary element - document.body.removeChild(el); - } + function copyStringToClipboard (str) { + // Create new element + var el = document.createElement('textarea'); + // Set value (string to be copied) + el.value = str; + // Set non-editable to avoid focus and move outside of view + el.setAttribute('readonly', ''); + el.style = {position: 'absolute', left: '-9999px'}; + document.body.appendChild(el); + // Select text inside element + el.select(); + // Copy text to clipboard + document.execCommand('copy'); + // Remove temporary element + document.body.removeChild(el); + } diff --git a/config/routes.rb b/config/routes.rb index 83c02a0..d266eda 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -631,6 +631,7 @@ Rails.application.routes.draw do get :analyse_reponses post :analyse_reponses_save get :generate_final_consult + get :buy_order_create end collection do get :search_to_affect From 2f7a3a48a14798ac20fc9101ad5d41a88d0fe163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 13 Sep 2021 11:16:55 +0200 Subject: [PATCH 080/121] Add form slug option to add_fields --- app/helpers/document_line_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/helpers/document_line_helper.rb b/app/helpers/document_line_helper.rb index 8066e11..0e54205 100644 --- a/app/helpers/document_line_helper.rb +++ b/app/helpers/document_line_helper.rb @@ -28,6 +28,10 @@ module DocumentLineHelper fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render("admin/"+association.to_s + "/essentials_form", :form => builder) end + elsif options[:slug] + fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| + render("admin/"+association.to_s + "/form_#{options[:slug]}", :form => builder) + end else fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render("admin/"+association.to_s + "/form", :form => builder) From 2a540f292a947f7ee598e08b95e129917d873f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 13 Sep 2021 11:21:55 +0200 Subject: [PATCH 081/121] update price-line form demande de prix --- .../_form_demande_prix.html.haml | 4 +- .../price_lines/_form_demande_prix.html.haml | 118 ++++-------------- .../_form_demande_prix_OLD.html.haml | 98 +++++++++++++++ 3 files changed, 122 insertions(+), 98 deletions(-) create mode 100644 app/views/admin/price_lines/_form_demande_prix_OLD.html.haml diff --git a/app/views/admin/price_line_blocks/_form_demande_prix.html.haml b/app/views/admin/price_line_blocks/_form_demande_prix.html.haml index 28deefc..14a5e63 100644 --- a/app/views/admin/price_line_blocks/_form_demande_prix.html.haml +++ b/app/views/admin/price_line_blocks/_form_demande_prix.html.haml @@ -21,7 +21,7 @@ =f.semantic_fields_for :price_lines do |f| =render :partial => "admin/price_lines/form_#{f.object.block_type_slug}", :locals => {:form => f} - %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary"} + %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {slug: f.object.block_type_slug , :class => "btn btn-primary", tabindex: 2} - \ No newline at end of file + diff --git a/app/views/admin/price_lines/_form_demande_prix.html.haml b/app/views/admin/price_lines/_form_demande_prix.html.haml index 0661845..ed5a37a 100644 --- a/app/views/admin/price_lines/_form_demande_prix.html.haml +++ b/app/views/admin/price_lines/_form_demande_prix.html.haml @@ -1,98 +1,24 @@ - -.qi_pannel.qi_plain.padding.price_line_form.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"} - %table{:style => "width:100%;"} - %tr - %td{:style => "width:30px;"} - .take +.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"} + - price_line = form.object + .row + .col-6.row + .col-2.d-flex + .take.mx-3 =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{:disabled => true, :type => "text", :value => ("#{form.object.p_product_ref.member_label}" if form.object.p_product_ref)} - - - = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id" - - :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, - }, - 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 - - %td - = form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte"} - - + %label + ref : + %input.p_product_ref_autocomplete_input.form-control.col{: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)} + + .col-3.ml-4 + .form-inline + = form.input :qte, :label => "qte :", :input_html => { class: "mx-2", tabindex: 1} + .col-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" - = form.hidden_field :position, :class => "price_line_position_input" - diff --git a/app/views/admin/price_lines/_form_demande_prix_OLD.html.haml b/app/views/admin/price_lines/_form_demande_prix_OLD.html.haml new file mode 100644 index 0000000..0661845 --- /dev/null +++ b/app/views/admin/price_lines/_form_demande_prix_OLD.html.haml @@ -0,0 +1,98 @@ + +.qi_pannel.qi_plain.padding.price_line_form.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 : + %input.p_product_ref_autocomplete_input.form-control{:disabled => true, :type => "text", :value => ("#{form.object.p_product_ref.member_label}" if form.object.p_product_ref)} + + + = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id" + + :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, + }, + 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 + + %td + = form.input :qte, :label => "qte :", :input_html => {:class => "input_price_line_qte"} + + + + = form.hidden_field :position, :class => "price_line_position_input" + From 6751e34f29f33f6c1739922ad00019bf796f64d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 13 Sep 2021 18:36:21 +0200 Subject: [PATCH 082/121] Wip bon de livraison --- .../admin/price_documents_controller.rb | 80 ++++ .../admin/price_documents/show.html.haml | 397 +++++++++--------- config/routes.rb | 2 + 3 files changed, 283 insertions(+), 196 deletions(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index ccb68b1..62756c9 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -670,4 +670,84 @@ class Admin::PriceDocumentsController < ApplicationController redirect_to admin_price_document_path(@price_document) end end + + def bon_de_reception + @past_price_document = PriceDocument.find(params[:id]) + + @p_customer_sheet = @past_price_document.ref_element + + if @p_customer_sheet + price_document = @p_customer_sheet.price_documents.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :demande_de_prix_id => @past_price_document.id, :date => Date.today) + + else + price_document = PriceDocument.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :date => Date.today) + end + + price_document.doc_ref_id = @past_price_document.id + + price_document.p_fournisseur = @past_price_document.p_fournisseur + + + price_document.price_line_block = @past_price_document.price_line_block.dup + + if @past_price_document.cc_label == "Commande achat" + price_document.bon_de_commande_achat_id = @past_price_document.id + price_document.reliquat = true if PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type_id => [5]).count > 0 + + + + end + + + if @past_price_document.cc_label == "Facture achat" + price_document.facture_achat_id = @past_price_document.id + + + end + + + price_document.price_line_block.ac_bon_de_commande_id = nil + price_document.price_line_block.ac_bon_de_livraison_id = nil + price_document.price_line_block.ac_facture_id = nil + price_document.price_line_block.ac_block_type = nil + price_document.price_line_block.ac_reliquat = nil + + + + + @past_price_document.price_line_block.price_lines.each do |pl| + new_pl = pl.dup + new_pl.price_line_ref_id = pl.id + new_pl.ac_block_type = nil + + if price_document.reliquat and @p_customer_sheet + bls = PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type_id => [5]) + + qte_ok = PriceLine.where(:price_line_ref_id => new_pl.price_line_ref_id).where(:price_line_block_id => PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => bls.ids)).sum(:qte) + + new_pl.qte = new_pl.qte - qte_ok + + end + price_document.price_line_block.price_lines << new_pl + end + + if price_document.save + #price_document.reset_for_update + #price_document.archive_now + if @p_customer_sheet + @p_customer_sheet.state = "Bon de réception achat" + @p_customer_sheet.save + end + + if price_document.ref_element + redirect_to [:admin, price_document.ref_element] + else + redirect_to [:admin, price_document] + end + + + else + render :inline => price_document.errors.messages.to_s + end + end end diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 838b25f..9400fbe 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -5,25 +5,25 @@ -if @price_document.price_document_type_id == 6 and !@price_document.stock_ok = link_to i(:pencil), edit_admin_price_document_path(:id => @price_document.id, :public_edit => true) if !@price_document.stock_ok - - + + = diag do = link_to i(:pencil), edit_admin_price_document_path(@price_document) = link_to i(:eye), admin_price_document_path(@price_document.id), :remote => false, :target => "_blank" - + = link_to i(:download), print_admin_price_document_path(@price_document.token), :remote => false, :target => "_blank" if !PriceLineBlock::PURCHASE_BLOCKS.include?(@price_document.block_type) - + %h1 Documents - + %span =@price_document.price_document_type.label - + %span ="##{@price_document.id}" %span =@price_document.d_number - + .qi_row @@ -35,16 +35,21 @@ Nom fournisseur saisi %td =@price_document.public_fournisseur_name - + -if @price_document.p_fournisseur %tr %td Fournisseur %td =link_to @price_document.p_fournisseur.name, [:admin, @price_document.p_fournisseur] if @price_document.p_fournisseur - - + -if @price_document.d_number? + %tr + %td Numéro + %td=@price_document.d_number + %tr + %td Date + %td=l @price_document.date, :format => :date -if @price_document.label == "Demande prix" %tr @@ -57,23 +62,23 @@ Désignation %td =@price_document.list_designaton - + %tr %td Date de fin de consultation : %td =l @price_document.end_date if @price_document.end_date - + %tr %td Commentaire %td =simple_format @price_document.dp_comment - + %tr %td - Envoyé à + Envoyé à %td =simple_format @price_document.acheteur_text - + %tr %td Lien pour consultation @@ -86,20 +91,20 @@ .qi_pannel.qi_plain.padding -if false =debug @price_document - - - + + + -if true - + -price_line_block = @price_document.price_line_block - - + + =#render price_line_block - + -else -params[:search][:per_page] = params[:search][:per_page] || 5000 -per_page = params[:search][:per_page] - -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 -@price_lines = @price_document.price_line_block.price_lines @@ -112,85 +117,86 @@ - .clear + .clear =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_lines, :key => "reponses-prix-show"} - - - + + + -if @price_document.label != "Demande prix" and @price_document.label != "Réponse fournisseur" - - + -if current_admin and current_admin.id == 1 - %table.table - %tr - %th Archivé ? - %td - = diag do - -if @price_document.archived - Oui - =link_to "Désarchiver", unarchive_now_admin_price_document_path(@price_document.id) - -else - =link_to "Archiver", archive_now_admin_price_document_path(@price_document.id) - %tr - %th Id bloc - %td=price_line_block.id - - - %tr - %th Cout block - %td=price_line_block.cc_cost_ht - - - -params[:search][:per_page] = params[:search][:per_page] || 5000 - -per_page = params[:search][:per_page] - -page = (params[:page] and params[:page] != "") ? params[:page] : 1 - - -@stat_lines = @price_document.stat_lines.order("date DESC, created_at DESC") - -@stat_lines = sort_by_sorting(@stat_lines, "created_at DESC") - -@stat_lines = @stat_lines.page(page).per(per_page) - %br - - - =link_to "Générer les stats", generate_stat_lines_admin_price_document_path(@price_document), :class => "btn btn-primary" - - %table.table - %tr - %th - HT - %td - =number_to_currency @stat_lines.sum(:tot_amount_ht) - - %tr - %th - TTC - %td - =number_to_currency @stat_lines.sum(:tot_amount_ttc) - - - %tr - %th - Coût HT - %td - =number_to_currency @stat_lines.sum(:cost_ht) - + -enable_stat = false + -if enable_stat + %table.table + %tr + %th Archivé ? + %td + = diag do + -if @price_document.archived + Oui + =link_to "Désarchiver", unarchive_now_admin_price_document_path(@price_document.id) + -else + =link_to "Archiver", archive_now_admin_price_document_path(@price_document.id) + %tr + %th Id bloc + %td=price_line_block.id - .clear - =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @stat_lines} - - - - - - - - + %tr + %th Cout block + %td=price_line_block.cc_cost_ht + + + -params[:search][:per_page] = params[:search][:per_page] || 5000 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + + -@stat_lines = @price_document.stat_lines.order("date DESC, created_at DESC") + -@stat_lines = sort_by_sorting(@stat_lines, "created_at DESC") + -@stat_lines = @stat_lines.page(page).per(per_page) + %br + + + =link_to "Générer les stats", generate_stat_lines_admin_price_document_path(@price_document), :class => "btn btn-primary" + + %table.table + %tr + %th + HT + %td + =number_to_currency @stat_lines.sum(:tot_amount_ht) + + %tr + %th + TTC + %td + =number_to_currency @stat_lines.sum(:tot_amount_ttc) + + + %tr + %th + Coût HT + %td + =number_to_currency @stat_lines.sum(:cost_ht) + + + + .clear + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @stat_lines} + + + + + + + + %h3 Lignes de produits %table.table %thead %tr %th %th Référence - %th Produit + %th Marque %th Désignation %th Qté %th P.U. HT @@ -204,131 +210,130 @@ ="##{price_line.id}" %td =price_line.ref - - + + %td - =link_to price_line.p_product_ref.p_product.name, edit_admin_p_product_path(price_line.p_product_ref.p_product) if price_line.p_product_ref and price_line.p_product_ref.p_product - - + =price_line.p_product_ref.p_product.s_brand.name + %td - =price_line.title - + =link_to price_line.p_product_ref.cc_name, edit_admin_p_product_path(price_line.p_product_ref.p_product) if price_line.p_product_ref and price_line.p_product_ref.p_product + %td.numeraire =price_line.qte - + %td.numeraire =number_to_currency price_line.price_u_ht - - + + %td.numeraire =price_line.tva_account_value.to_s+"%" - - - - + + + + %td.numeraire =number_to_currency price_line.tot_amount_ht - - %td - = price_line.line_stocks.sum(:price_ht) - - -if current_admin.has_permission?("show-costs") - %br - %br - %p - -if @price_document.price_document_type_id == 6 - =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok - -elsif @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 - %p - Coût : - =number_to_currency @price_document.cost_ht - %p - Marge : - =number_to_currency @price_document.marge_ht - - -if !@price_document.cost_ok - =link_to "Mettre à jour les stocks, calculer la marge", update_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" - - -if false - - -if @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 and !@price_document.cost_ok - %table.table.table-striped.table-hover.table-bordered - %thead - %tr - %th Produit - %th Quantité dans cette pièce comptable - %th Quantité restante - %th - -@price_document.price_line_block.price_lines.all.each do |pl| - -if pl.p_product_ref - - -if pl.p_product_ref.assembled - -pl.p_product_ref.p_product_assembleds.all.each do |ppa| - %tr - %td - =ppa.p_product_ref.cc_name - %td - =@a = (pl.qte.to_f * ppa.qte.to_f).to_f - - %td - =link_to admin_line_stocks_path(:p_product_ref_id => ppa.p_product_ref.id) do - =@b = LineStock.where(:p_product_ref_id => ppa.p_product_ref_id).sum(:qte_available).to_f - - %td - -if @a > @b - .red=ic :warning - - -else + + / %td=# price_line.line_stocks.sum(:price_ht) + +.qi_row + -if current_admin.has_permission?("show-costs") + %p + -if @price_document.price_document_type_id == 6 + =link_to "Générer les stocks", generate_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" if !@price_document.stock_ok + -elsif @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 + %p + Coût : + =number_to_currency @price_document.cost_ht + %p + Marge : + =number_to_currency @price_document.marge_ht + + -if !@price_document.cost_ok + =link_to "Mettre à jour les stocks, calculer la marge", update_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" + -if @price_document.d_number + -if @price_document.cc_label == "Commande achat" + %p=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary" + + -if false + + -if @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 and !@price_document.cost_ok + %table.table.table-striped.table-hover.table-bordered + %thead + %tr + %th Produit + %th Quantité dans cette pièce comptable + %th Quantité restante + %th + -@price_document.price_line_block.price_lines.all.each do |pl| + -if pl.p_product_ref + + -if pl.p_product_ref.assembled + -pl.p_product_ref.p_product_assembleds.all.each do |ppa| %tr %td - =pl.p_product_ref.cc_name + =ppa.p_product_ref.cc_name %td - =@a = pl.qte.to_f - + =@a = (pl.qte.to_f * ppa.qte.to_f).to_f + %td - =link_to admin_line_stocks_path(:p_product_ref_id => pl.p_product_ref.id) do - =@b = LineStock.where(:p_product_ref_id => pl.p_product_ref_id).sum(:qte_available).to_f - + =link_to admin_line_stocks_path(:p_product_ref_id => ppa.p_product_ref.id) do + =@b = LineStock.where(:p_product_ref_id => ppa.p_product_ref_id).sum(:qte_available).to_f + %td - -if pl.p_product_ref.stocked and @a > @b + -if @a > @b .red=ic :warning - - - - - -if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 - %h3 Stocks générés - #bills - -params[:search][:per_page] = params[:search][:per_page] || 5000 - -per_page = params[:search][:per_page] - -page = (params[:page] and params[:page] != "") ? params[:page] : 1 - - -@line_stocks = @price_document.line_stocks.order("date DESC, created_at DESC") - -if params[:price_document_ids] - -@line_stocks = @line_stocks.where(:id => params[:price_document_ids]) - - -@line_stocks = sort_by_sorting(@line_stocks, "created_at DESC") - -@line_stocks = @line_stocks.page(page).per(per_page) - %br - + -else + %tr + %td + =pl.p_product_ref.cc_name + %td + =@a = pl.qte.to_f + + %td + =link_to admin_line_stocks_path(:p_product_ref_id => pl.p_product_ref.id) do + =@b = LineStock.where(:p_product_ref_id => pl.p_product_ref_id).sum(:qte_available).to_f + + %td + -if pl.p_product_ref.stocked and @a > @b + .red=ic :warning - .clear - =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @line_stocks} - + + -if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 + %h3 Stocks générés + #bills + -params[:search][:per_page] = params[:search][:per_page] || 5000 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + + -@line_stocks = @price_document.line_stocks.order("date DESC, created_at DESC") + -if params[:price_document_ids] + -@line_stocks = @line_stocks.where(:id => params[:price_document_ids]) + + + -@line_stocks = sort_by_sorting(@line_stocks, "created_at DESC") + -@line_stocks = @line_stocks.page(page).per(per_page) + %br + + + + .clear + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @line_stocks} + -if @price_document.label == "Demande prix" %h3.ml-2 Réponses fournisseur #bills -params[:search][:per_page] = params[:search][:per_page] || 5000 -per_page = params[:search][:per_page] - -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 -@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Réponse fournisseur").id) - - + + -@price_documents = sort_by_sorting(@price_documents, "created_at DESC") @@ -337,19 +342,19 @@ - .clear + .clear =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"} - - + + %h3.ml-2 Consultations fournisseur #consult -params[:search][:per_page] = params[:search][:per_page] || 5000 -per_page = params[:search][:per_page] - -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 -@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Consultation fournisseur").id) - - + + -@price_documents = sort_by_sorting(@price_documents, "created_at DESC") @@ -358,7 +363,7 @@ - .clear + .clear =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"} -if @price_documents.empty? .qi_pannel.qi_plain.padding diff --git a/config/routes.rb b/config/routes.rb index d266eda..faa9cc1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -632,6 +632,8 @@ Rails.application.routes.draw do post :analyse_reponses_save get :generate_final_consult get :buy_order_create + get :bon_de_reception + end collection do get :search_to_affect From bb8c841404f00b1aa98a10de5fc12434823ae05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 13 Sep 2021 18:36:38 +0200 Subject: [PATCH 083/121] show amount --- app/models/price_line.rb | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/app/models/price_line.rb b/app/models/price_line.rb index f156d9b..d33c571 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -546,38 +546,36 @@ class PriceLine < ApplicationRecord - - def ca_tot_amount_ht - if ct_tot_amount_ht + if self.ct_tot_amount_ht self.ct_tot_amount_ht else - (self.ca_price_u_kg_net_ht * self.weight_qte.to_f).round(2) + (self.ca_price_u_ht * self.qte.to_f).round(3) end end def ca_tot_amount_tva - (self.tot_amount_ht * (self.tva_account_value/100)).round(2) + (self.tot_amount_ht * (self.tva_account_value/100)).round(3) end def ca_tot_amount_ttc - (self.tot_amount_ht + self.tot_amount_tva).round(2) + (self.tot_amount_ht + self.tot_amount_tva).round(3) end - - - + + + def ca_tot_discount_ht - (self.ca_price_u_ht * self.qte.to_f).round(2) - self.ca_tot_amount_ht + (self.ca_price_u_ht * self.qte.to_f).round(3) - self.ca_tot_amount_ht end - - - + + + def ca_tot_discount_tva - (self.tot_discount_ht * (self.tva_account_value/100)).round(2) + (self.tot_discount_ht * (self.tva_account_value/100)).round(3) end def ca_tot_discount_ttc - (self.tot_discount_ht+self.tot_discount_tva).round(2) + (self.tot_discount_ht+self.tot_discount_tva).round(3) end From 5f7b79139c8ee2423410bd38a0ca674110470a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 14 Sep 2021 16:26:28 +0200 Subject: [PATCH 084/121] add price_doc history --- .../20210914071847_add_doc_hist_to_price_documents.rb | 9 +++++++++ db/schema.rb | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210914071847_add_doc_hist_to_price_documents.rb diff --git a/db/migrate/20210914071847_add_doc_hist_to_price_documents.rb b/db/migrate/20210914071847_add_doc_hist_to_price_documents.rb new file mode 100644 index 0000000..eebac6b --- /dev/null +++ b/db/migrate/20210914071847_add_doc_hist_to_price_documents.rb @@ -0,0 +1,9 @@ +class AddDocHistToPriceDocuments < ActiveRecord::Migration[6.0] + def change + add_column :price_documents, :bon_de_commande_achat_id, :integer + add_column :price_documents, :bon_de_reception_achat_id, :integer + add_column :price_documents, :demande_de_prix_id, :integer + add_column :price_documents, :avoir_achat_id, :integer + add_column :price_documents, :facture_achat_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 934a8fe..077818c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_07_161735) do +ActiveRecord::Schema.define(version: 2021_09_14_071847) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -2251,6 +2251,11 @@ ActiveRecord::Schema.define(version: 2021_09_07_161735) do t.string "f_token" t.text "acheteur_text" t.string "public_fournisseur_name" + t.integer "bon_de_commande_achat_id" + t.integer "bon_de_reception_achat_id" + t.integer "demande_de_prix_id" + t.integer "avoir_achat_id" + t.integer "facture_achat_id" t.index ["p_customer_id"], name: "index_price_documents_on_p_customer_id" end From 04d2bbd60acc954dcaa0803e3301957fdfeff44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 14 Sep 2021 16:27:55 +0200 Subject: [PATCH 085/121] Wip bon de reception achat --- .../admin/price_documents_controller.rb | 20 ++---- app/models/price_line_block.rb | 21 +++++-- .../admin/price_documents/_relicats.html.haml | 62 +++++++++++++++++++ .../admin/price_documents/show.html.haml | 11 +++- .../_form_bon_de_reception_achat.html.haml | 27 ++++++++ .../_form_bon_de_reception_achat.html.haml | 27 ++++++++ 6 files changed, 145 insertions(+), 23 deletions(-) create mode 100644 app/views/admin/price_documents/_relicats.html.haml create mode 100644 app/views/admin/price_line_blocks/_form_bon_de_reception_achat.html.haml create mode 100644 app/views/admin/price_lines/_form_bon_de_reception_achat.html.haml diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 62756c9..5b9d7d8 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -662,7 +662,7 @@ class Admin::PriceDocumentsController < ApplicationController price_line_block = PriceLineBlock.new(p_fournisseur: @final_consult.price_line_block.p_fournisseur) price_lines = PriceLine.where(price_line_block: @final_consult.price_line_block) - @price_document = PriceDocument.new(date: Date.today, price_line_block: price_line_block, doc_ref_id: @final_consult.id, :price_document_type => PriceDocumentType.find_by_label("Commande achat")) + @price_document = PriceDocument.new(date: Date.today, price_line_block: price_line_block, doc_ref_id: @final_consult.id, demande_de_prix_id: @final_consult.id ,:price_document_type => PriceDocumentType.find_by_label("Commande achat")) price_lines.each do |pl| @price_document.price_line_block.price_lines << PriceLine.new(p_product_ref: pl.p_product_ref, qte: pl.qte, ct_u_price_ht: pl.price_u_ht) end @@ -671,6 +671,7 @@ class Admin::PriceDocumentsController < ApplicationController end end + def bon_de_reception @past_price_document = PriceDocument.find(params[:id]) @@ -678,31 +679,22 @@ class Admin::PriceDocumentsController < ApplicationController if @p_customer_sheet price_document = @p_customer_sheet.price_documents.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :demande_de_prix_id => @past_price_document.id, :date => Date.today) - else price_document = PriceDocument.new(:price_document_type => PriceDocumentType.find_by_label("Bon de réception achat"), :date => Date.today) end price_document.doc_ref_id = @past_price_document.id - price_document.p_fournisseur = @past_price_document.p_fournisseur - - price_document.price_line_block = @past_price_document.price_line_block.dup if @past_price_document.cc_label == "Commande achat" price_document.bon_de_commande_achat_id = @past_price_document.id - price_document.reliquat = true if PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type_id => [5]).count > 0 - - - + price_document.reliquat = true if PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type => PriceDocumentType.find_by_label("Bon de réception achat")).count > 0 end if @past_price_document.cc_label == "Facture achat" price_document.facture_achat_id = @past_price_document.id - - end @@ -719,9 +711,9 @@ class Admin::PriceDocumentsController < ApplicationController new_pl = pl.dup new_pl.price_line_ref_id = pl.id new_pl.ac_block_type = nil - + raise if price_document.reliquat and @p_customer_sheet - bls = PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type_id => [5]) + bls = PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type => PriceDocumentType.find_by_label("Bon de réception achat")) qte_ok = PriceLine.where(:price_line_ref_id => new_pl.price_line_ref_id).where(:price_line_block_id => PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => bls.ids)).sum(:qte) @@ -744,8 +736,6 @@ class Admin::PriceDocumentsController < ApplicationController else redirect_to [:admin, price_document] end - - else render :inline => price_document.errors.messages.to_s end diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index 3a048e0..f4d44af 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -23,7 +23,8 @@ class PriceLineBlock < ApplicationRecord belongs_to :p_payment_type - PURCHASE_BLOCKS = [ "Réponse fournisseur", "Commande achat", "Facture d'achat", "Consultation fournisseur"] + PURCHASE_BLOCKS = ["Réponse fournisseur", "Consultation fournisseur", "Facture d'achat", "Commande achat", "Demande de prix", "Bon de commande achat", "Bon de réception achat", "Facture achat", "Avoir achat"] + SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] belongs_to :p_fournisseur @@ -261,7 +262,9 @@ class PriceLineBlock < ApplicationRecord end def wish_date_needed? - if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Réponse fournisseur" + if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) + false + elsif self.block_type == "Devis" false else true @@ -270,7 +273,9 @@ class PriceLineBlock < ApplicationRecord def particular_bill_needed? if !self.imported - if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Demande prix" or self.block_type == "Réponse fournisseur" + if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) + false + elsif self.block_type == "Devis" false else true @@ -280,7 +285,9 @@ class PriceLineBlock < ApplicationRecord def particular_send_needed? if !self.imported - if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Demande prix" or self.block_type == "Réponse fournisseur" + if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) + false + elsif self.block_type == "Devis" false else true @@ -297,9 +304,11 @@ class PriceLineBlock < ApplicationRecord end def p_customer_needed? - if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) or self.block_type == "Demande prix" or self.block_type == "Réponse fournisseur" + if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) false - elsif !self.imported + elsif self.block_type == "Devis" + false + else true end end diff --git a/app/views/admin/price_documents/_relicats.html.haml b/app/views/admin/price_documents/_relicats.html.haml new file mode 100644 index 0000000..035846f --- /dev/null +++ b/app/views/admin/price_documents/_relicats.html.haml @@ -0,0 +1,62 @@ + +#bills + + .qi_tab_header + %h3 Bons de réception associés + .right + + + -params[:search][:per_page] = params[:search][:per_page] || 50 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + + -@price_documents = PriceDocument.where(:bon_de_commande_achat_id => bca.id, :price_document_type_id => [5]).order("date DESC, created_at DESC") + + -@price_documents = sort_by_sorting(@price_documents, "created_at DESC") + -@all_price_documents = @price_documents + -@price_documents = @price_documents.page(page).per(per_page) + + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "projet-factures"} + + +%h3 Etat des réceptions par articles + +- bca_price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => bca.id) + +- bra_price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => @all_price_documents.ids) + +%table.table.table-striped.table-hover.table-bordered.data_table + %thead + %tr + %th + Code produit + %th + Produit + %th Quantité commandée + + %th Quantité réceptionnée + + %th Différence + %tbody + - PriceLine.where(:price_line_block_id => (bca_price_line_blocks.ids + bra_price_line_blocks.ids)).map {|pl| pl.p_product_ref_id}.uniq.each do |p_product_ref_id| + -if p_product_ref = PProductRef.where(:id => p_product_ref_id).first + %tr + %td + =link_to [:admin, p_product_ref] do + =p_product_ref.ref + %td + =link_to [:admin, p_product_ref] do + =p_product_ref.cc_name + + %td + =a = PriceLine.where(:p_product_ref_id => p_product_ref_id, :price_line_block_id => bca_price_line_blocks).sum(:qte) + + + %td + =b = PriceLine.where(:p_product_ref_id => p_product_ref_id, :price_line_block_id => bra_price_line_blocks).sum(:qte) + + %td + = a -b + + + diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 9400fbe..ef8c572 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -255,7 +255,8 @@ -if @price_document.d_number -if @price_document.cc_label == "Commande achat" %p=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary" - + -if @price_document.cc_label == "Commande achat" + =render :partial => "admin/price_documents/relicats", :locals => {:bca => @price_document} -if false -if @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 and !@price_document.cost_ok @@ -380,7 +381,13 @@ = semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form| = form.button "Valider modifications)", type: :submit, class: "btn btn-primary m-2" = link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)' - = link_to "Generer la commande", buy_order_create_admin_price_document_path(price_document_consult) + - existing_order = PriceDocument.where(doc_ref_id: price_document_consult.id) + - if existing_order.present? + = link_to ic(:eye) + " Afficher la commande", admin_price_document_path(existing_order.first), class: "btn btn-tertiary" + - else + = link_to "Generer la commande", buy_order_create_admin_price_document_path(price_document_consult), class: "btn btn-primary" + + .price-lines{"data-document" => price_document_consult.id} =form.semantic_fields_for :price_line_block do |f| .mx-2 diff --git a/app/views/admin/price_line_blocks/_form_bon_de_reception_achat.html.haml b/app/views/admin/price_line_blocks/_form_bon_de_reception_achat.html.haml new file mode 100644 index 0000000..c4c181a --- /dev/null +++ b/app/views/admin/price_line_blocks/_form_bon_de_reception_achat.html.haml @@ -0,0 +1,27 @@ + +=f.inputs do + + + -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") + .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} + + %table{:style => "width:100%;"} + %tr + %td{:style => "width:50%;"} + = f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date + + + -if @price_document.label != "Demande prix" + = f.input :customer_ref, :label => "Référence commande client :" + -if current_admin.has_permission?("customer-sheets-bl") + = f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"} + + + .price_lines_form + =f.semantic_fields_for :price_lines do |f| + =render :partial => "admin/price_lines/form_#{f.object.block_type_slug}", :locals => {:form => f} + + %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {slug: f.object.block_type_slug , :class => "btn btn-primary", tabindex: 2} + + + diff --git a/app/views/admin/price_lines/_form_bon_de_reception_achat.html.haml b/app/views/admin/price_lines/_form_bon_de_reception_achat.html.haml new file mode 100644 index 0000000..56ccde8 --- /dev/null +++ b/app/views/admin/price_lines/_form_bon_de_reception_achat.html.haml @@ -0,0 +1,27 @@ +.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"} + - price_line = form.object + .row + .col-6.row + .col-2.d-flex + .take.mx-3 + =ic :arrows + %label + ref : + %input.p_product_ref_autocomplete_input.form-control.col{: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)} + + .col-3.ml-2 + .form-inline + = form.input :qte, :label => "qte :", :input_html => { class: "mx-2", tabindex: 1} + .col-2 + .form-inline + = form.input :ct_u_price_ht, :label => "PU :", :input_html => { class: "mx-2"} + .col-1.ml-2 + %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" + From f0638e82ace1a6a26a14199c54adbadd79ed9b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 14 Sep 2021 16:30:39 +0200 Subject: [PATCH 086/121] remove raise --- app/controllers/admin/price_documents_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 5b9d7d8..7542407 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -711,7 +711,7 @@ class Admin::PriceDocumentsController < ApplicationController new_pl = pl.dup new_pl.price_line_ref_id = pl.id new_pl.ac_block_type = nil - raise + if price_document.reliquat and @p_customer_sheet bls = PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type => PriceDocumentType.find_by_label("Bon de réception achat")) From 28490c3e962f834c5f16026f03beb3722130b5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 14 Sep 2021 16:30:53 +0200 Subject: [PATCH 087/121] remove form commande --- .../_form_commande_achat.html.haml | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 app/views/admin/price_line_blocks/_form_commande_achat.html.haml diff --git a/app/views/admin/price_line_blocks/_form_commande_achat.html.haml b/app/views/admin/price_line_blocks/_form_commande_achat.html.haml deleted file mode 100644 index 77f22ec..0000000 --- a/app/views/admin/price_line_blocks/_form_commande_achat.html.haml +++ /dev/null @@ -1,41 +0,0 @@ - -=f.inputs do - - - -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") - .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} - - - - - - = f.input :p_fournisseur, :label => "Fournisseur :", :collection => PFournisseur.order(:name).all, :as => :select - - - - = f.input :customer_ref, :label => "Numéro de facture fournisseur :" - -if current_admin.has_permission?("customer-sheets-bl") - =# f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"} - - -if @p_customer_sheet and @p_customer_sheet.p_customer and @p_customer_sheet.p_customer.p_customer_sheet_note? - %div - %strong Notes pour les demandes de commandes pour ce client : - =simple_format @p_customer_sheet.p_customer.p_customer_sheet_note - %br - - - - = f.input :p_devise_id, :label => "Devise :", :collection => PDevise.order(:id).all, :as => :select, :include_blank => false - = f.input :local_amount_ttc, :label => "Montant TTC en € réglé pour cette facture :" - - - - .price_lines_form - =f.semantic_fields_for :price_lines do |f| - =render :partial => "admin/price_lines/form_facture_dachat", :locals => {:form => f} - - %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary", :partial => "admin/price_lines/form_facture_dachat"} - - - - \ No newline at end of file From d6e1986935959f21066c13662f6bc468a96615d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 15 Sep 2021 10:09:16 +0200 Subject: [PATCH 088/121] Reliquat bug-fix --- app/controllers/admin/price_documents_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 7542407..93139eb 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -712,7 +712,7 @@ class Admin::PriceDocumentsController < ApplicationController new_pl.price_line_ref_id = pl.id new_pl.ac_block_type = nil - if price_document.reliquat and @p_customer_sheet + if price_document.reliquat #and @p_customer_sheet bls = PriceDocument.where(:bon_de_commande_achat_id => @past_price_document.id, :price_document_type => PriceDocumentType.find_by_label("Bon de réception achat")) qte_ok = PriceLine.where(:price_line_ref_id => new_pl.price_line_ref_id).where(:price_line_block_id => PriceLineBlock.where(:price_lineable_type => "PriceDocument", :price_lineable_id => bls.ids)).sum(:qte) From d28ad68e99e0e9be491f7249c801774aafc4c3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 15 Sep 2021 11:35:51 +0200 Subject: [PATCH 089/121] add facture_achat route --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index faa9cc1..76ae891 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -633,7 +633,7 @@ Rails.application.routes.draw do get :generate_final_consult get :buy_order_create get :bon_de_reception - + get :facture_achat end collection do get :search_to_affect From 084e71905fadf6bbcca7698de921c40110eef0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 15 Sep 2021 18:37:59 +0200 Subject: [PATCH 090/121] facture achat --- .../admin/price_documents_controller.rb | 60 ++++++++++++++++++- app/models/price_line.rb | 2 + app/models/price_line_block.rb | 6 +- .../admin/price_documents/_form.html.haml | 4 +- .../price_documents/_price_document.html.haml | 4 +- .../admin/price_documents/show.html.haml | 33 +++++----- 6 files changed, 86 insertions(+), 23 deletions(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 93139eb..7ca73b2 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -731,8 +731,8 @@ class Admin::PriceDocumentsController < ApplicationController @p_customer_sheet.save end - if price_document.ref_element - redirect_to [:admin, price_document.ref_element] + if price_document.doc_ref_id + redirect_to [:admin, @past_price_document] else redirect_to [:admin, price_document] end @@ -740,4 +740,60 @@ class Admin::PriceDocumentsController < ApplicationController render :inline => price_document.errors.messages.to_s end end + + def facture_achat + @past_price_document = PriceDocument.find(params[:id]) + + @p_customer_sheet = @past_price_document.ref_element + + if @p_customer_sheet + price_document = @p_customer_sheet.price_documents.new(:price_document_type => PriceDocumentType.find_by_label("Facture achat"), :demande_de_prix_id => @past_price_document.id, :date => Date.today) + + else + price_document = PriceDocument.new(:price_document_type => PriceDocumentType.find_by_label("Facture achat"), :date => Date.today) + end + + price_document.doc_ref_id = @past_price_document.id + price_document.p_fournisseur = @past_price_document.p_fournisseur + + price_document.price_line_block = @past_price_document.price_line_block.dup + + price_document.price_line_block.ac_bon_de_commande_id = nil + price_document.price_line_block.ac_bon_de_livraison_id = nil + price_document.price_line_block.ac_facture_id = nil + price_document.price_line_block.ac_block_type = nil + price_document.price_line_block.ac_reliquat = nil + + @past_price_document.price_line_block.price_lines.each do |pl| + new_pl = pl.dup + new_pl.price_line_ref_id = pl.id + new_pl.ac_block_type = nil + + + price_document.price_line_block.price_lines << new_pl + end + + if price_document.save + #price_document.reset_for_update + #price_document.archive_now + if @p_customer_sheet + @p_customer_sheet.state = "Facture" + @p_customer_sheet.save + end + + if price_document.doc_ref_id + redirect_to [:admin, @past_price_document] + else + redirect_to [:admin, price_document] + end + else + render :inline => price_document.errors.messages.to_s + end + + + + + + end + end diff --git a/app/models/price_line.rb b/app/models/price_line.rb index d33c571..9be5aea 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -53,6 +53,8 @@ class PriceLine < ApplicationRecord BON_DE_LIVRAISON_TO_RESET = %w(block_type weight_tot tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc) FACTURE_DACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) + + BON_DE_RECEPTION_ACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) COMMANDE_ACHAT_TO_RESET = %w(block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index f4d44af..edfe0cb 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -325,6 +325,8 @@ class PriceLineBlock < ApplicationRecord BON_DE_LIVRAISON_TO_RESET = %w(weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) FACTURE_DACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) + + BON_DE_RECEPTION_ACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) COMMANDE_ACHAT_TO_RESET = %w(weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) @@ -346,12 +348,12 @@ class PriceLineBlock < ApplicationRecord eval("self.ac_#{qid} = nil") end - self.archive_now(:skip_personalised_archive => true) + self.archive_now() self.price_lines.each do |pl| - pl.archive_now(:skip_personalised_archive => true) + pl.archive_now() end diff --git a/app/views/admin/price_documents/_form.html.haml b/app/views/admin/price_documents/_form.html.haml index 1a74d5a..60a7314 100644 --- a/app/views/admin/price_documents/_form.html.haml +++ b/app/views/admin/price_documents/_form.html.haml @@ -20,8 +20,8 @@ =hidden_field_tag :public_edit, params[:public_edit] - - = @price_document.price_line_block.block_type + %h3 + = @price_document.price_line_block.block_type -if @price_document.label == "Demande prix" .row diff --git a/app/views/admin/price_documents/_price_document.html.haml b/app/views/admin/price_documents/_price_document.html.haml index 68fe2c3..a18ec45 100644 --- a/app/views/admin/price_documents/_price_document.html.haml +++ b/app/views/admin/price_documents/_price_document.html.haml @@ -186,7 +186,6 @@ =# link_to i(:eye), admin_price_document_path(price_document), :remote => true - = link_to i(:eye), admin_price_document_path(price_document.id), :remote => false -if PriceLineBlock::PURCHASE_BLOCKS.include?(price_document.block_type) =# link_to i(:eye), admin_price_document_path(price_document.id), :remote => false @@ -201,6 +200,9 @@ = link_to i(:pencil), edit_admin_price_document_path(price_document) = link_to i(:eye), admin_price_document_path(price_document.id), :remote => false, :target => "_blank" + -if price_document.cc_label == "Bon de réception achat" + %br + =link_to "Générer la facture", facture_achat_admin_price_document_path(price_document) =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => price_document} diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index ef8c572..2ef5d7b 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -251,7 +251,7 @@ =number_to_currency @price_document.marge_ht -if !@price_document.cost_ok - =link_to "Mettre à jour les stocks, calculer la marge", update_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" + =#link_to "Mettre à jour les stocks, calculer la marge", update_stocks_admin_price_document_path(@price_document), :class => "btn btn-primary" -if @price_document.d_number -if @price_document.cc_label == "Commande achat" %p=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary" @@ -304,25 +304,26 @@ -if @price_document.price_document_type_id == 6 or @price_document.price_document_type_id == 4 or @price_document.price_document_type_id == 5 - %h3 Stocks générés - #bills - -params[:search][:per_page] = params[:search][:per_page] || 5000 - -per_page = params[:search][:per_page] - -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + -if @price_document.price_line_block.stock_ok + %h3 Stocks générés + #bills + -params[:search][:per_page] = params[:search][:per_page] || 5000 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 - -@line_stocks = @price_document.line_stocks.order("date DESC, created_at DESC") - -if params[:price_document_ids] - -@line_stocks = @line_stocks.where(:id => params[:price_document_ids]) + -@line_stocks = @price_document.line_stocks.order("date DESC, created_at DESC") + -if params[:price_document_ids] + -@line_stocks = @line_stocks.where(:id => params[:price_document_ids]) - -@line_stocks = sort_by_sorting(@line_stocks, "created_at DESC") - -@line_stocks = @line_stocks.page(page).per(per_page) - %br + -@line_stocks = sort_by_sorting(@line_stocks, "created_at DESC") + -@line_stocks = @line_stocks.page(page).per(per_page) + %br - .clear - =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @line_stocks} + .clear + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @line_stocks} -if @price_document.label == "Demande prix" @@ -379,7 +380,7 @@ %h4.ml-2= price_document_consult.p_fournisseur.name = semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form| - = form.button "Valider modifications)", type: :submit, class: "btn btn-primary m-2" + = form.button "Valider modifications", type: :submit, class: "btn btn-primary m-2" = link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)' - existing_order = PriceDocument.where(doc_ref_id: price_document_consult.id) - if existing_order.present? @@ -398,7 +399,6 @@ - :javascript const copyPriceLines = (event) => { event.preventDefault() @@ -436,3 +436,4 @@ // Remove temporary element document.body.removeChild(el); } + From 74992c6607492e88b0c4fe1ed35b1b1b545bcb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Wed, 15 Sep 2021 18:39:16 +0200 Subject: [PATCH 091/121] small front upgrades --- app/models/price_document.rb | 2 +- .../analyse_reponses.html.haml | 3 ++- .../admin/price_documents/index.html.haml | 2 +- .../_form_bon_de_reception_achat.html.haml | 24 ++++--------------- .../_form_bon_de_reception_achat.html.haml | 4 ++-- 5 files changed, 10 insertions(+), 25 deletions(-) diff --git a/app/models/price_document.rb b/app/models/price_document.rb index 8ed50a1..24fcc09 100644 --- a/app/models/price_document.rb +++ b/app/models/price_document.rb @@ -25,7 +25,7 @@ class PriceDocument < ApplicationRecord has_many :avoir_p_payment_documents, :dependent => :destroy, :foreign_key => :avoir_id, :class_name => "PPaymentDocument" accepts_nested_attributes_for :avoir_p_payment_documents, allow_destroy: true - PURCHASES = ["Demande prix", "Réponse fournisseur", "Commande achat", "Facture d'achat", "Consultation fournisseur"] + PURCHASES = ["Demande prix", "Réponse fournisseur", "Commande achat", "Facture achat", "Consultation fournisseur"] SALES = ["Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] # AVANCEMENT = ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"] AVANCEMENT = ["0%", "25%", "50%", "75%", "100"] diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index b88eab3..7b68000 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -224,7 +224,8 @@ .modal-footer %button.btn.btn-light{"data-dismiss" => "modal"} Close -=link_to "Generer les consultations", generate_final_consult_admin_price_document_path, class: "btn btn-primary ml-4 mt-4" +- if PriceDocument.where(doc_ref_id: @price_document, price_document_type: PriceDocumentType.find_by_label("Consultation fournisseur")).empty? + =link_to "Generer les consultations", generate_final_consult_admin_price_document_path, class: "btn btn-primary ml-4 mt-4" =link_to "Acceder aux consultations", admin_price_document_path(@price_document, anchor: "consult"), class: "btn btn-primary ml-4 mt-4" diff --git a/app/views/admin/price_documents/index.html.haml b/app/views/admin/price_documents/index.html.haml index 8513399..014b9eb 100644 --- a/app/views/admin/price_documents/index.html.haml +++ b/app/views/admin/price_documents/index.html.haml @@ -65,7 +65,7 @@ Type de document : %td - -if [1,2,6,7].include?(params[:price_document_type_id].to_i)or (params[:price_document_type_ids] and (params[:price_document_type_ids].include?("6") or params[:price_document_type_ids].include?("7"))) + -if [3,4,5,6,7,9,10].include?(params[:price_document_type_id].to_i)or (params[:price_document_type_ids] and (params[:price_document_type_ids].include?("6") or params[:price_document_type_ids].include?("7"))) -PriceDocumentType.where(:label => PriceDocument::PURCHASES, :enabled => true).order("id DESC").each do |pdt| %p.d-inline-flex.ml-3 = check_box_tag :"price_document_type_ids[]", pdt.id, (true if params[:price_document_type_ids].include?(pdt.id.to_s)), {:id => "price_document_type_ids_#{pdt.id}", class: "my-auto"} diff --git a/app/views/admin/price_line_blocks/_form_bon_de_reception_achat.html.haml b/app/views/admin/price_line_blocks/_form_bon_de_reception_achat.html.haml index c4c181a..783139d 100644 --- a/app/views/admin/price_line_blocks/_form_bon_de_reception_achat.html.haml +++ b/app/views/admin/price_line_blocks/_form_bon_de_reception_achat.html.haml @@ -1,27 +1,11 @@ =f.inputs do + .price_lines_form + =f.semantic_fields_for :price_lines do |f| + =render :partial => "admin/price_lines/form_#{f.object.block_type_slug}", :locals => {:form => f} - -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") - .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} - - %table{:style => "width:100%;"} - %tr - %td{:style => "width:50%;"} - = f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date - - - -if @price_document.label != "Demande prix" - = f.input :customer_ref, :label => "Référence commande client :" - -if current_admin.has_permission?("customer-sheets-bl") - = f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"} - - - .price_lines_form - =f.semantic_fields_for :price_lines do |f| - =render :partial => "admin/price_lines/form_#{f.object.block_type_slug}", :locals => {:form => f} - - %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {slug: f.object.block_type_slug , :class => "btn btn-primary", tabindex: 2} + %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {slug: f.object.block_type_slug , :class => "btn btn-primary", tabindex: 2} diff --git a/app/views/admin/price_lines/_form_bon_de_reception_achat.html.haml b/app/views/admin/price_lines/_form_bon_de_reception_achat.html.haml index 56ccde8..a8d7aa0 100644 --- a/app/views/admin/price_lines/_form_bon_de_reception_achat.html.haml +++ b/app/views/admin/price_lines/_form_bon_de_reception_achat.html.haml @@ -7,11 +7,11 @@ =ic :arrows %label ref : - %input.p_product_ref_autocomplete_input.form-control.col{: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)} + %input.p_product_ref_autocomplete_input.form-control.col{:type => "text", :value => ("#{form.object.p_product_ref.ref} #{form.object.p_product_ref.cc_name}" if form.object.p_product_ref)} .col-3.ml-2 .form-inline - = form.input :qte, :label => "qte :", :input_html => { class: "mx-2", tabindex: 1} + = form.input :qte, :label => "qte :", :input_html => { class: "mx-2", autofocus: true, tabindex: 1} .col-2 .form-inline = form.input :ct_u_price_ht, :label => "PU :", :input_html => { class: "mx-2"} From 4faade463ca73263db0f7b7c9e63ea87ae902291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 16 Sep 2021 13:14:15 +0200 Subject: [PATCH 092/121] update consultation show --- .../admin/price_documents/show.html.haml | 95 +++++++++++-------- 1 file changed, 55 insertions(+), 40 deletions(-) diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 2ef5d7b..0e7a91f 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -191,6 +191,16 @@ %h3 Lignes de produits + .mb-3 + - if @price_document.cc_label == "Consultation fournisseur" + = link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => @price_document.id, onclick: 'copyPriceLines(event)' + - existing_order = PriceDocument.where(doc_ref_id: @price_document.id, cc_label: "Commande achat") + + - if existing_order.present? + = link_to ic(:eye) + " Afficher la commande", admin_price_document_path(existing_order.first), class: "btn btn-tertiary" + - else + = link_to "Generer la commande", buy_order_create_admin_price_document_path(@price_document), class: "btn btn-primary" + %table.table %thead %tr @@ -213,16 +223,17 @@ + %td =price_line.p_product_ref.p_product.s_brand.name - %td + %td{class: "p_product_ref_cc_name_#{@price_document.id}"} =link_to price_line.p_product_ref.cc_name, edit_admin_p_product_path(price_line.p_product_ref.p_product) if price_line.p_product_ref and price_line.p_product_ref.p_product - %td.numeraire + %td.numeraire{class: "price_line_qte_#{@price_document.id}"} =price_line.qte - %td.numeraire + %td.numeraire{class: "price_line_price_u_ht_#{@price_document.id}"} =number_to_currency price_line.price_u_ht @@ -382,7 +393,7 @@ = semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form| = form.button "Valider modifications", type: :submit, class: "btn btn-primary m-2" = link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)' - - existing_order = PriceDocument.where(doc_ref_id: price_document_consult.id) + - existing_order = PriceDocument.where(doc_ref_id: price_document_consult.id, cc_label: "Commande achat") - if existing_order.present? = link_to ic(:eye) + " Afficher la commande", admin_price_document_path(existing_order.first), class: "btn btn-tertiary" - else @@ -399,41 +410,45 @@ - :javascript - const copyPriceLines = (event) => { - event.preventDefault() - let priceDocumentId = event.target.dataset.document - let names = $(`.p_product_ref_cc_name_${priceDocumentId}`) - let qtes = $(`.input_price_line_qte_${priceDocumentId}`) - let prices = $(`.price_line_price_u_ht_${priceDocumentId}`) +:javascript + const copyPriceLines = (event) => { + event.preventDefault() + let priceDocumentId = event.target.dataset.document + let names = $(`.p_product_ref_cc_name_${priceDocumentId}`) + let qtes_input = $(`.input_price_line_qte_${priceDocumentId}`) + let qtes = $(`.price_line_qte_${priceDocumentId}`) + let prices = $(`.price_line_price_u_ht_${priceDocumentId}`) + let table = [] + names.each(function( i ) { + let row = [] + if(qtes_input.length > 0) { + row.push(qtes_input[i].valueAsNumber) + }else{ + row.push(qtes[i].innerText.slice(0, -2)) + } + row.push(" X ") + row.push(names[i].innerText) + row.push(" @ ") + row.push(prices[i].innerText) + table.push(row.join(' ')) + }) + copyStringToClipboard(table.join('\r\n')) + } - let table = [] - names.each(function( i ) { - let row = [] - row.push(qtes[i].valueAsNumber) - row.push(" X ") - row.push(names[i].innerText) - row.push(" @ ") - row.push(prices[i].innerText) - table.push(row.join(' ')) - }) - copyStringToClipboard(table.join('\r\n')) - } - - function copyStringToClipboard (str) { - // Create new element - var el = document.createElement('textarea'); - // Set value (string to be copied) - el.value = str; - // Set non-editable to avoid focus and move outside of view - el.setAttribute('readonly', ''); - el.style = {position: 'absolute', left: '-9999px'}; - document.body.appendChild(el); - // Select text inside element - el.select(); - // Copy text to clipboard - document.execCommand('copy'); - // Remove temporary element - document.body.removeChild(el); - } + function copyStringToClipboard (str) { + // Create new element + var el = document.createElement('textarea'); + // Set value (string to be copied) + el.value = str; + // Set non-editable to avoid focus and move outside of view + el.setAttribute('readonly', ''); + el.style = {position: 'absolute', left: '-9999px'}; + document.body.appendChild(el); + // Select text inside element + el.select(); + // Copy text to clipboard + document.execCommand('copy'); + // Remove temporary element + document.body.removeChild(el); + } From bfafa906ce243c4479c5d4875be363c861e7c4c7 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Thu, 16 Sep 2021 17:29:12 +0200 Subject: [PATCH 093/121] =?UTF-8?q?Cases=20=C3=A0=20cocher=20buy=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/price_documents_controller.rb | 10 ++++----- app/controllers/application_controller.rb | 21 ++++++++++--------- app/views/admin/buy_lists/index.html.haml | 5 ++++- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 7ca73b2..ce7b3f5 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -235,12 +235,12 @@ class Admin::PriceDocumentsController < ApplicationController @price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id]) if @price_document.price_document_type.label == "Demande prix" - p_product_ref_id = params[:qte].keys - p_product_ref_qte = params[:qte].values + p_product_ref_id = params[:p_product_ref_ids] - [""] + p_product_ref_qte = params[:qte].permit!.to_hash - p_product_ref_id.each_with_index do |key, i| - if p_product_ref_qte[i].to_i > 0 - @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => key, :qte => p_product_ref_qte[i]) + p_product_ref_id.each do |i| + if p_product_ref_qte[i.to_s].to_i > 0 + @price_document.price_line_block.price_lines << PriceLine.new(:p_product_ref_id => i, :qte => p_product_ref_qte[i.to_s]) end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0e10c2f..ce02913 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception - before_action :set_current_p_customer_sheet + #before_action :set_current_p_customer_sheet @@ -33,9 +33,6 @@ class ApplicationController < ActionController::Base elsif v[:elements] v[:elements].each do |a,b| - puts "TEST" - puts b[0] - puts "B" if b[:sub_elements] and b[:sub_elements][sym.to_sym] @qi_menu_active = k @qi_menu_sub_menu_active = sym.to_sym @@ -474,13 +471,17 @@ class ApplicationController < ActionController::Base def current_admin - if cookies[:admin_remember_token] - if @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token]) - @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token]) - else - cookies[:admin_remember_token] =nil - end + if @current_admin + return @current_admin + else + if cookies[:admin_remember_token] + if @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token]) + @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token]) + else + cookies[:admin_remember_token] =nil + end + end end diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index cb6bed8..59a005d 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -72,7 +72,8 @@ =form_tag new_admin_price_document_path(), :method => "get" do =hidden_field_tag :"document_type", "Demande prix" - =hidden_field_tag :"price_line_ids[]", "" + =hidden_field_tag :"p_product_ref_ids[]", "" + .freezeTable %table.table.table-striped.table-hover.table-bordered.data_table %thead.header @@ -173,6 +174,8 @@ %td.mask = qte_available %td.mask + =check_box_tag :"p_product_ref_ids[]", plr.p_product_ref.id + =number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: (bpa_qte - qte_available) %td.mask From 1609c92ab70ebca77ead1025879785d54a7b3453 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Thu, 16 Sep 2021 20:01:42 +0200 Subject: [PATCH 094/121] Popup produits --- app/assets/javascripts/manager.js | 5 ++-- .../admin/p_product_refs_controller.rb | 8 ++++++ .../admin/p_product_refs/index.html.haml | 25 +++++++++++-------- app/views/admin/p_product_refs/index.js.erb | 9 +++++++ app/views/admin/price_lines/_form.html.haml | 4 ++- app/views/qi/_qi_ordered_table.html.haml | 4 ++- 6 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 app/views/admin/p_product_refs/index.js.erb diff --git a/app/assets/javascripts/manager.js b/app/assets/javascripts/manager.js index b6b2393..861df04 100644 --- a/app/assets/javascripts/manager.js +++ b/app/assets/javascripts/manager.js @@ -240,9 +240,10 @@ function select_video_from_manager(input_id){ function select_product_from_manager(input_id){ - - manager_prompt("/admin/p_product_refs.html?manager=true",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_name_'+input_id).val(m_return.name); diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index fbf5675..1f2017e 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -47,6 +47,14 @@ class Admin::PProductRefsController < ApplicationController @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") respond_to do |format| + format.js{ + + params[:search][:per_page] = params[:search][:per_page] || 100 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @p_product_refs = @p_product_refs.page(page).per(per_page) + + } format.html{ params[:search][:per_page] = params[:search][:per_page] || 100 diff --git a/app/views/admin/p_product_refs/index.html.haml b/app/views/admin/p_product_refs/index.html.haml index 9e77e44..3a3aeaf 100644 --- a/app/views/admin/p_product_refs/index.html.haml +++ b/app/views/admin/p_product_refs/index.html.haml @@ -1,17 +1,19 @@ -.qi_header - .right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false - %h1 - Achats - %span - Produits +-if !@manager + .qi_header + .right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false + %h1 + Achats + %span + Références + .qi_search_row - =form_tag "", :method => "get", :onsubmit => "" do + =form_tag admin_p_product_refs_path, :method => "get", :onsubmit => "", :remote => true do =hidden_field_tag :column, params[:column] =hidden_field_tag :direction, params[:direction] - + =hidden_field_tag :manager, params[:manager] %table %tr %td @@ -42,7 +44,7 @@ -=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_refs} +#p_product_refs_index_wrapper=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_refs, :remote => true} @@ -52,4 +54,7 @@ }); - \ No newline at end of file + +:coffeescript + $(".qi_search_row form").on "submit", -> + $("#p_product_refs_index_wrapper").html('recherche en cours ...') \ No newline at end of file diff --git a/app/views/admin/p_product_refs/index.js.erb b/app/views/admin/p_product_refs/index.js.erb new file mode 100644 index 0000000..ab3b84a --- /dev/null +++ b/app/views/admin/p_product_refs/index.js.erb @@ -0,0 +1,9 @@ + +var p_product_refs_url = "<%= escape_javascript(request.url) %>"; + + +$('#p_product_refs_index_wrapper').html("<%= escape_javascript(render(:partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_product_refs, :remote => true}))%>"); + + + +$(".btn-qi-search").html(' Rechercher'); \ No newline at end of file diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 77c4f79..728e663 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -18,6 +18,9 @@ = form.hidden_field :p_product_ref_id, :class => "p_product_ref_id p_product_ref_id_#{key}" %td =link_to ic(:search), "#", class: "ml-2",:onclick => "select_product_from_manager('#{key}');return false;" + + :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 @@ -39,7 +42,6 @@ .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-2 Taux de TVA : diff --git a/app/views/qi/_qi_ordered_table.html.haml b/app/views/qi/_qi_ordered_table.html.haml index 79c9a48..b968bab 100644 --- a/app/views/qi/_qi_ordered_table.html.haml +++ b/app/views/qi/_qi_ordered_table.html.haml @@ -1,5 +1,7 @@ - "QI ActsAsCaching V0.6" +- remote = remote || false + -if true -masqued_columns = masqued_columns || nil @@ -183,7 +185,7 @@ .qi_pagination - = paginate qi_ordered_table_collection #, :remote => true + = paginate qi_ordered_table_collection, :remote => remote :scss From 57bac61ac9fd1bfc0f9f0fca199e52de9b59f6cc Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Fri, 17 Sep 2021 00:18:04 +0200 Subject: [PATCH 095/121] =?UTF-8?q?Bug=20recherche=20marques=20sur=20r?= =?UTF-8?q?=C3=A9f=C3=A9rences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin/p_product_refs_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 1f2017e..ecec7c3 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -42,7 +42,7 @@ class Admin::PProductRefsController < ApplicationController if params[:search][:s_brand_id].to_s != "" - @p_product_refs = @p_product_refs.where(:s_brand_id => params[:search][:s_brand_id]) + @p_product_refs = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}) end @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") From 390fe5d98df68e63df268b388c68f761e35cfea6 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Fri, 17 Sep 2021 00:18:29 +0200 Subject: [PATCH 096/121] Ergo + popup --- app/assets/javascripts/admin.coffee | 5 +- app/assets/javascripts/admin/random_hexa.js | 2 + app/assets/javascripts/manager.js | 4 +- app/assets/javascripts/nested_fields.coffee | 6 +- .../admin/price_line_blocks/_form.html.haml | 21 +- app/views/admin/price_lines/_form.html.haml | 201 ++++++++++-------- 6 files changed, 135 insertions(+), 104 deletions(-) create mode 100644 app/assets/javascripts/admin/random_hexa.js diff --git a/app/assets/javascripts/admin.coffee b/app/assets/javascripts/admin.coffee index 7a571ec..ea98f59 100644 --- a/app/assets/javascripts/admin.coffee +++ b/app/assets/javascripts/admin.coffee @@ -56,6 +56,7 @@ #= require freeze-table +#= require admin/random_hexa @@ -856,6 +857,4 @@ $(document).on 'click', '.datepicker', (e) -> $(this).next('.' + autocomplete_object + '_id').val ui.item.id return return - - - + \ No newline at end of file diff --git a/app/assets/javascripts/admin/random_hexa.js b/app/assets/javascripts/admin/random_hexa.js new file mode 100644 index 0000000..910cebf --- /dev/null +++ b/app/assets/javascripts/admin/random_hexa.js @@ -0,0 +1,2 @@ +const genRanHex = size => [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join(''); + \ No newline at end of file diff --git a/app/assets/javascripts/manager.js b/app/assets/javascripts/manager.js index 861df04..561153d 100644 --- a/app/assets/javascripts/manager.js +++ b/app/assets/javascripts/manager.js @@ -245,8 +245,8 @@ function select_product_from_manager(input_id){ manager_prompt(p_product_refs_url,function(m_return){ - $('.p_product_ref_id_'+input_id).val(m_return.id); - $('.p_product_ref_name_'+input_id).val(m_return.name); + $('#p_product_ref_id_'+input_id).val(m_return.id); + $('#p_product_ref_name_'+input_id).val(m_return.name); }); diff --git a/app/assets/javascripts/nested_fields.coffee b/app/assets/javascripts/nested_fields.coffee index c589739..c0a6ca7 100644 --- a/app/assets/javascripts/nested_fields.coffee +++ b/app/assets/javascripts/nested_fields.coffee @@ -10,9 +10,11 @@ if $(link).closest("p").next("." + association + "_form").length > 0 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") - + else + form_element = $(link).closest(".qi_field_wrapper").find("." + association + "_form") + form_element.append content_final $(".new_field").removeClass "new_field" diff --git a/app/views/admin/price_line_blocks/_form.html.haml b/app/views/admin/price_line_blocks/_form.html.haml index 20b07b9..8494cba 100644 --- a/app/views/admin/price_line_blocks/_form.html.haml +++ b/app/views/admin/price_line_blocks/_form.html.haml @@ -56,12 +56,23 @@ =content_for :price_lines do - .row - .price_lines_form.col-11.row - =f.semantic_fields_for :price_lines do |f| - =render :partial => "admin/price_lines/form", :locals => {:form => f} + %div{:style=>"padding:0 30px;"} + .row.qi_field_wrapper + %table{:style => "width:100%;border-collapse:separate;"} + %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") diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 728e663..48b670c 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -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 - =link_to ic(:search), "#", class: "ml-2",:onclick => "select_product_from_manager('#{key}');return false;" + + %td{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )} + .take.mr-1 + =ic :arrows + %td{:style => "white-space: nowrap;"} + + + + .input-group + %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"} + + + + + .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) - :javascript - var p_product_refs_url = "#{admin_p_product_refs_path(:manager => true)}" + + + + + = 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 + -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 - =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 + -if form.object.forced_price and form.object.p_product_ref + %td + .mx-2 .form-inline - %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 - %span.destroy=link_to_remove_fields ic(:"trash-o"), form + =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) + -else + %td + .mx-2 + .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" - :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 - } - }); +: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 + } }); + }); + + +:scss + .price_line_form{ + .form-group{ + margin-bottom:0;} + + } \ No newline at end of file From a9453ab5225a9c846f79d053c86972f860c0fdad Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Fri, 17 Sep 2021 00:22:01 +0200 Subject: [PATCH 097/121] Suite (le retour) --- app/views/admin/price_line_blocks/_form.html.haml | 3 ++- app/views/admin/price_lines/_form.html.haml | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/admin/price_line_blocks/_form.html.haml b/app/views/admin/price_line_blocks/_form.html.haml index 8494cba..f01c327 100644 --- a/app/views/admin/price_line_blocks/_form.html.haml +++ b/app/views/admin/price_line_blocks/_form.html.haml @@ -1,5 +1,6 @@ =f.inputs do - + :javascript + var p_product_refs_url = "#{admin_p_product_refs_path(:manager => true)}" -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index 48b670c..fab597d 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -27,8 +27,6 @@ - :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 From 2f2cfb344e85747fc57972c6aee16146f4b26966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 10:07:15 +0200 Subject: [PATCH 098/121] Focus after manager select --- app/assets/javascripts/manager.js | 2 +- app/views/admin/price_lines/_form.html.haml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/manager.js b/app/assets/javascripts/manager.js index 561153d..49a11fb 100644 --- a/app/assets/javascripts/manager.js +++ b/app/assets/javascripts/manager.js @@ -247,7 +247,7 @@ function select_product_from_manager(input_id){ $('#p_product_ref_id_'+input_id).val(m_return.id); $('#p_product_ref_name_'+input_id).val(m_return.name); - + $('#p_product_ref_qte_'+input_id).focus() }); } diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index fab597d..123ca49 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -15,7 +15,7 @@ .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 + =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);$(this).closest('tr').find('.p_product_ref_qte').attr('id', 'p_product_ref_qte_'+key);return false;" do =ic(:search) @@ -46,7 +46,7 @@ .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} + = form.input :qte, :label => false, :input_html => {:class => "input_price_line_qte form-control p_product_ref_qte", tabindex: 1} %td @@ -118,4 +118,4 @@ .form-group{ margin-bottom:0;} - } \ No newline at end of file + } From 0020ee07ec9249434c944f8a63a9ca4172634344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 10:09:22 +0200 Subject: [PATCH 099/121] ETA date search on buylist --- app/controllers/admin/buy_lists_controller.rb | 50 ++++++++++++++----- app/views/admin/buy_lists/index.html.haml | 42 +++++++++++++--- 2 files changed, 73 insertions(+), 19 deletions(-) diff --git a/app/controllers/admin/buy_lists_controller.rb b/app/controllers/admin/buy_lists_controller.rb index 662c25d..0fb842d 100644 --- a/app/controllers/admin/buy_lists_controller.rb +++ b/app/controllers/admin/buy_lists_controller.rb @@ -33,35 +33,61 @@ class Admin::BuyListsController < ApplicationController date_regex = /^(0[1-9]|[12][0-9]|3[01])[\/](0[1-9]|1[012])[\/](19|20)\d\d$/i - params[:start] = Date.today.beginning_of_month.strftime('%d/%m/%Y') if !params[:start] + params[:cc_creation_date_start] = Date.today.beginning_of_month.strftime('%d/%m/%Y') if !params[:cc_creation_date_start] - if params[:start] and params[:start] =~ date_regex + if params[:cc_creation_date_start] and params[:cc_creation_date_start] =~ date_regex #fsfds = sdfsfd - @start = Date.parse(params[:start]).beginning_of_day - params[:start]= @start.strftime('%d/%m/%Y') + @cc_creation_date_start = Date.parse(params[:cc_creation_date_start]).beginning_of_day + params[:cc_creation_date_start]= @cc_creation_date_start.strftime('%d/%m/%Y') else - @start = nil + @cc_creation_date_start = nil end if true - params[:stop] = Date.today.end_of_month.strftime('%d/%m/%Y') if !params[:stop] + params[:cc_creation_date_stop] = Date.today.end_of_month.strftime('%d/%m/%Y') if !params[:cc_creation_date_stop] - if params[:stop].to_s != "" # and params[:stop] =~ date_regex - @stop = Date.parse(params[:stop]).end_of_day + if params[:cc_creation_date_stop].to_s != "" # and params[:stop] =~ date_regex + @cc_creation_date_stop = Date.parse(params[:cc_creation_date_stop]).end_of_day - params[:stop]= @stop.strftime('%d/%m/%Y') + params[:cc_creation_date_stop]= @cc_creation_date_stop.strftime('%d/%m/%Y') else - @stop = nil + @cc_creation_date_stop = nil end end - @price_lines = @price_lines.where("price_lines.cc_creation_date >= ?", @start) if @start - @price_lines = @price_lines.where("price_lines.cc_creation_date <= ?", @stop.end_of_day) if @stop + @price_lines = @price_lines.where("price_lines.cc_creation_date >= ?", @cc_creation_date_start) if @cc_creation_date_start + @price_lines = @price_lines.where("price_lines.cc_creation_date <= ?", @cc_creation_date_stop.end_of_day) if @cc_creation_date_stop + + params[:wish_date_start] = Date.today.beginning_of_month.strftime('%d/%m/%Y') if !params[:wish_date_start] + + if params[:wish_date_start] and params[:wish_date_start] =~ date_regex + #fsfds = sdfsfd + @wish_date_start = Date.parse(params[:wish_date_start]).beginning_of_day + params[:wish_date_start]= @wish_date_start.strftime('%d/%m/%Y') + else + @wish_date_start = nil + end + + if true + params[:wish_date_stop] = Date.today.end_of_month.strftime('%d/%m/%Y') if !params[:wish_date_stop] + if params[:wish_date_stop].to_s != "" # and params[:stop] =~ date_regex + @wish_date_stop = Date.parse(params[:wish_date_stop]).end_of_day + + params[:wish_date_stop]= @wish_date_stop.strftime('%d/%m/%Y') + + + else + @wish_date_stop = nil + end + + end + @price_lines = @price_lines.joins(:price_line_block).where("price_line_blocks.wish_date >= ?", @wish_date_start) if @wish_date_start + @price_lines = @price_lines.joins(:price_line_block).where("price_line_blocks.wish_date <= ?", @wish_date_stop.end_of_day) if @wish_date_stop respond_to do |format| format.html{ diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 59a005d..ce0934c 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -11,20 +11,20 @@ =form_tag "", :method => "get", :onsubmit => "" do -params[:search] =params[:search] || {} - %p Date de consultation : %table %tr.form-inline %td + Date saisie commande : Début %td.input-group - =text_field_tag :start, params[:start],:class => "form-control datepicker", :placeholder => "Début" + =text_field_tag :cc_creation_date_start, params[:cc_creation_date_start],:class => "form-control datepicker", :placeholder => "Début" .input-group-append %span.input-group-text{:onclick => "$(this).prev('input').val('');"} =ic(:times) %td.pl-4 Fin %td.input-group - =text_field_tag :stop, params[:stop],:class => "form-control datepicker", :placeholder => "Fin" + =text_field_tag :cc_creation_date_stop, params[:cc_creation_date_stop],:class => "form-control datepicker", :placeholder => "Fin" .input-group-append %span.input-group-text{:onclick => "$(this).prev('input').val('');"} =ic(:times) @@ -39,17 +39,45 @@ Code client : =text_field_tag "search[p_customer_code]", params[:search][:p_customer_code],:class => "form-control" + %tr.form-inline + %td{width: "110px"} + + %td.right.mx-4 + -if @cc_creation_date_start and @cc_creation_date_stop + + =link_to "< Mois précédent",request.query_parameters.merge({cc_creation_date_start: ((@cc_creation_date_start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), cc_creation_date_stop: ((@cc_creation_date_stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + %td{width: "20px"} + %td.mr-auto + -if @cc_creation_date_start and @cc_creation_date_stop + =link_to "Mois suivant >",request.query_parameters.merge({cc_creation_date_start: ((@cc_creation_date_start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), cc_creation_date_stop: ((@cc_creation_date_stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + + %tr.form-inline + %td + Date ETA : + Début + %td.input-group + =text_field_tag :wish_date_start, params[:wish_date_start],:class => "form-control datepicker", :placeholder => "Début" + .input-group-append + %span.input-group-text{:onclick => "$(this).prev('input').val('');"} + =ic(:times) + %td.pl-4 + Fin + %td.input-group + =text_field_tag :wish_date_stop, params[:wish_date_stop],:class => "form-control datepicker", :placeholder => "Fin" + .input-group-append + %span.input-group-text{:onclick => "$(this).prev('input').val('');"} + =ic(:times) %tr.form-inline %td{width: "110px"} %td.right.mx-4 - -if @start and @stop + -if @wish_date_start and @wish_date_stop - =link_to "< Mois précédent",request.query_parameters.merge({start: ((@start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + =link_to "< Mois précédent",request.query_parameters.merge({wish_date_start: ((@wish_date_start - 1.month).beginning_of_month.strftime('%d/%m/%Y')), wish_date_stop: ((@wish_date_stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" %td{width: "20px"} %td.mr-auto - -if @start and @stop - =link_to "Mois suivant >",request.query_parameters.merge({start: ((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), stop: ((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" + -if @wish_date_start and @wish_date_stop + =link_to "Mois suivant >",request.query_parameters.merge({wish_date_start: ((@wish_date_start + 1.month).beginning_of_month.strftime('%d/%m/%Y')), wish_date_stop: ((@wish_date_stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}), :class => "btn btn-tertiary" =link_to ic(:search)+" Rechercher", "#", :class => "btn btn-default btn-qi-search", :onclick => "$(this).closest('form').submit();$(this).html('...');return false;" From 198cdbe89813cb2efb6787540b35380d69b34014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 10:09:46 +0200 Subject: [PATCH 100/121] typo --- app/views/admin/price_documents/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 0e7a91f..47c1885 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -193,7 +193,7 @@ %h3 Lignes de produits .mb-3 - if @price_document.cc_label == "Consultation fournisseur" - = link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => @price_document.id, onclick: 'copyPriceLines(event)' + = link_to ic(:clipboard) + " Copier le texte", "#", class: "btn btn-primary", "data-document" => @price_document.id, onclick: 'copyPriceLines(event)' - existing_order = PriceDocument.where(doc_ref_id: @price_document.id, cc_label: "Commande achat") - if existing_order.present? @@ -392,7 +392,7 @@ = semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form| = form.button "Valider modifications", type: :submit, class: "btn btn-primary m-2" - = link_to ic(:clipboard) + " Copier le text", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)' + = link_to ic(:clipboard) + " Copier le texte", "#", class: "btn btn-primary", "data-document" => price_document_consult.id, onclick: 'copyPriceLines(event)' - existing_order = PriceDocument.where(doc_ref_id: price_document_consult.id, cc_label: "Commande achat") - if existing_order.present? = link_to ic(:eye) + " Afficher la commande", admin_price_document_path(existing_order.first), class: "btn btn-tertiary" From f3246d020938aa27ae09f1894b923e1e7686e6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 10:11:16 +0200 Subject: [PATCH 101/121] Small fixes --- app/models/price_line_block.rb | 6 ++++-- app/views/admin/buy_lists/index.html.haml | 2 +- app/views/admin/price_documents/analyse_reponses.html.haml | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index edfe0cb..6efcba4 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -23,7 +23,7 @@ class PriceLineBlock < ApplicationRecord belongs_to :p_payment_type - PURCHASE_BLOCKS = ["Réponse fournisseur", "Consultation fournisseur", "Facture d'achat", "Commande achat", "Demande de prix", "Bon de commande achat", "Bon de réception achat", "Facture achat", "Avoir achat"] + PURCHASE_BLOCKS = ["Réponse fournisseur", "Consultation fournisseur", "Facture d'achat", "Commande achat", "Demande prix", "Bon de commande achat", "Bon de réception achat", "Facture achat", "Avoir achat"] SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"] @@ -296,7 +296,9 @@ class PriceLineBlock < ApplicationRecord end def p_fournisseur_needed? - if PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) + if ["Demande prix", "Consultation fournisseur", "Réponse fournisseur"].include?(self.block_type) + false + elsif PriceLineBlock::PURCHASE_BLOCKS.include?(self.block_type) true else false diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index ce0934c..1808240 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -204,7 +204,7 @@ %td.mask =check_box_tag :"p_product_ref_ids[]", plr.p_product_ref.id - =number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: (bpa_qte - qte_available) + =number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: ([bpa_qte - qte_available, 0].max) %td.mask = bpa_qte diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 7b68000..5801960 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -89,7 +89,6 @@ -@price_document_responses.each do |resp| %th - =resp.id -if resp.p_fournisseur =resp.p_fournisseur.name -else From d6640ded5a3458a4b8e371d11c32cde2c8b2a1d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 14:08:08 +0200 Subject: [PATCH 102/121] Add sorecop to p_product_ref --- app/models/p_product_ref.rb | 9 +++++++++ .../20210917115613_add_sorecop_to_p_product_refs.rb | 7 +++++++ db/schema.rb | 5 ++++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 07926e6..106fce6 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -48,6 +48,7 @@ class PProductRef < ApplicationRecord :actions => {:name => "Actions", :reorder => false} } + acts_as_caching :fields => [:sorecop] def not_imported? if !self.p_product or !self.p_product.imported @@ -150,4 +151,12 @@ class PProductRef < ApplicationRecord "#{self.ref} | #{self.p_product.name} - #{self.ct_sub_name} - #{self.p_product_color.name if self.p_product_color} | #{self.cat_name}" end + def ca_sorecop + if self.cc_sorecop + return self.cc_sorecop + else + "TODO Calcul sorecop" + end + end + end diff --git a/db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb b/db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb new file mode 100644 index 0000000..83162ee --- /dev/null +++ b/db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb @@ -0,0 +1,7 @@ +class AddSorecopToPProductRefs < ActiveRecord::Migration[6.0] + def change + add_column :p_product_refs, :ca_sorecop, :decimal + add_column :p_product_refs, :cc_sorecop, :decimal + add_column :p_product_refs, :ct_sorecop, :decimal + end +end diff --git a/db/schema.rb b/db/schema.rb index 077818c..b4d95e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_14_071847) do +ActiveRecord::Schema.define(version: 2021_09_17_115613) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1793,6 +1793,9 @@ ActiveRecord::Schema.define(version: 2021_09_14_071847) do t.boolean "stocked", default: true t.text "description" t.integer "p_product_color_id" + t.decimal "ca_sorecop", precision: 10 + t.decimal "cc_sorecop", precision: 10 + t.decimal "ct_sorecop", precision: 10 end create_table "p_product_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| From 210ac207185ee2f8e5c20ce60b327906e7cf2742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 14:12:23 +0200 Subject: [PATCH 103/121] add DEE to p_product_ref --- app/models/p_product_ref.rb | 10 +++++++++- db/migrate/20210917121011_add_dee_to_p_product_refs.rb | 7 +++++++ db/schema.rb | 5 ++++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20210917121011_add_dee_to_p_product_refs.rb diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 106fce6..d689bac 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -48,7 +48,7 @@ class PProductRef < ApplicationRecord :actions => {:name => "Actions", :reorder => false} } - acts_as_caching :fields => [:sorecop] + acts_as_caching :fields => [:sorecop, :dee] def not_imported? if !self.p_product or !self.p_product.imported @@ -159,4 +159,12 @@ class PProductRef < ApplicationRecord end end + def ca_dee + if self.cc_dee + return self.cc_dee + else + "TODO Calcul DEE" + end + end + end diff --git a/db/migrate/20210917121011_add_dee_to_p_product_refs.rb b/db/migrate/20210917121011_add_dee_to_p_product_refs.rb new file mode 100644 index 0000000..0984648 --- /dev/null +++ b/db/migrate/20210917121011_add_dee_to_p_product_refs.rb @@ -0,0 +1,7 @@ +class AddDeeToPProductRefs < ActiveRecord::Migration[6.0] + def change + add_column :p_product_refs, :ca_dee, :decimal + add_column :p_product_refs, :cc_dee, :decimal + add_column :p_product_refs, :ct_dee, :decimal + end +end diff --git a/db/schema.rb b/db/schema.rb index b4d95e9..c81bb6b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_17_115613) do +ActiveRecord::Schema.define(version: 2021_09_17_121011) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1796,6 +1796,9 @@ ActiveRecord::Schema.define(version: 2021_09_17_115613) do t.decimal "ca_sorecop", precision: 10 t.decimal "cc_sorecop", precision: 10 t.decimal "ct_sorecop", precision: 10 + t.decimal "ca_dee", precision: 10 + t.decimal "cc_dee", precision: 10 + t.decimal "ct_dee", precision: 10 end create_table "p_product_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| From 7dbed2374c67e59a0a69c95b61dc77f420f42da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 14:46:19 +0200 Subject: [PATCH 104/121] add sorecop_comment & ean --- db/migrate/20210917122153_add_ean_to_p_product_refs.rb | 5 +++++ .../20210917124338_add_sorecop_comment_to_p_product_refs.rb | 5 +++++ db/schema.rb | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210917122153_add_ean_to_p_product_refs.rb create mode 100644 db/migrate/20210917124338_add_sorecop_comment_to_p_product_refs.rb diff --git a/db/migrate/20210917122153_add_ean_to_p_product_refs.rb b/db/migrate/20210917122153_add_ean_to_p_product_refs.rb new file mode 100644 index 0000000..43bf5de --- /dev/null +++ b/db/migrate/20210917122153_add_ean_to_p_product_refs.rb @@ -0,0 +1,5 @@ +class AddEanToPProductRefs < ActiveRecord::Migration[6.0] + def change + add_column :p_product_refs, :ean, :integer + end +end diff --git a/db/migrate/20210917124338_add_sorecop_comment_to_p_product_refs.rb b/db/migrate/20210917124338_add_sorecop_comment_to_p_product_refs.rb new file mode 100644 index 0000000..3c239fb --- /dev/null +++ b/db/migrate/20210917124338_add_sorecop_comment_to_p_product_refs.rb @@ -0,0 +1,5 @@ +class AddSorecopCommentToPProductRefs < ActiveRecord::Migration[6.0] + def change + add_column :p_product_refs, :sorecop_comment, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index c81bb6b..490c94d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_17_121011) do +ActiveRecord::Schema.define(version: 2021_09_17_124338) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -1799,6 +1799,8 @@ ActiveRecord::Schema.define(version: 2021_09_17_121011) do t.decimal "ca_dee", precision: 10 t.decimal "cc_dee", precision: 10 t.decimal "ct_dee", precision: 10 + t.integer "ean" + t.string "sorecop_comment" end create_table "p_product_specs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| From 3720120124b08f760b6d25d4464b9f1693dbe73e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 16:16:24 +0200 Subject: [PATCH 105/121] EAN to string + integer validation --- app/models/p_product_ref.rb | 8 +++++++- db/migrate/20210917122153_add_ean_to_p_product_refs.rb | 2 +- db/schema.rb | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index d689bac..9ff80d1 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -18,7 +18,7 @@ class PProductRef < ApplicationRecord accepts_nested_attributes_for :p_product_ref_specs, allow_destroy: true #validates :ct_price_ht, :presence => true - + validate :ean, :is_integer has_many :p_customer_product_prices, :dependent => :destroy accepts_nested_attributes_for :p_customer_product_prices, allow_destroy: true @@ -167,4 +167,10 @@ class PProductRef < ApplicationRecord end end + def is_integer + if ean.present? && ean.match(/\A[+-]?\d+\z/).nil? + errors.add(:ean, "ne doit être composé que de chiffres") + end + end + end diff --git a/db/migrate/20210917122153_add_ean_to_p_product_refs.rb b/db/migrate/20210917122153_add_ean_to_p_product_refs.rb index 43bf5de..128e438 100644 --- a/db/migrate/20210917122153_add_ean_to_p_product_refs.rb +++ b/db/migrate/20210917122153_add_ean_to_p_product_refs.rb @@ -1,5 +1,5 @@ class AddEanToPProductRefs < ActiveRecord::Migration[6.0] def change - add_column :p_product_refs, :ean, :integer + add_column :p_product_refs, :ean, :string end end diff --git a/db/schema.rb b/db/schema.rb index 490c94d..bebdd70 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1799,7 +1799,7 @@ ActiveRecord::Schema.define(version: 2021_09_17_124338) do t.decimal "ca_dee", precision: 10 t.decimal "cc_dee", precision: 10 t.decimal "ct_dee", precision: 10 - t.integer "ean" + t.string "ean" t.string "sorecop_comment" end From 56dc686008a1e465e38ef33882471b394bb11567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 16:31:23 +0200 Subject: [PATCH 106/121] Decimal precision --- .../20210917115613_add_sorecop_to_p_product_refs.rb | 6 +++--- .../20210917121011_add_dee_to_p_product_refs.rb | 6 +++--- db/schema.rb | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb b/db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb index 83162ee..80e2940 100644 --- a/db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb +++ b/db/migrate/20210917115613_add_sorecop_to_p_product_refs.rb @@ -1,7 +1,7 @@ class AddSorecopToPProductRefs < ActiveRecord::Migration[6.0] def change - add_column :p_product_refs, :ca_sorecop, :decimal - add_column :p_product_refs, :cc_sorecop, :decimal - add_column :p_product_refs, :ct_sorecop, :decimal + add_column :p_product_refs, :ca_sorecop, :decimal, :precision => 10, :scale => 2 + add_column :p_product_refs, :cc_sorecop, :decimal, :precision => 10, :scale => 2 + add_column :p_product_refs, :ct_sorecop, :decimal, :precision => 10, :scale => 2 end end diff --git a/db/migrate/20210917121011_add_dee_to_p_product_refs.rb b/db/migrate/20210917121011_add_dee_to_p_product_refs.rb index 0984648..ddf1f70 100644 --- a/db/migrate/20210917121011_add_dee_to_p_product_refs.rb +++ b/db/migrate/20210917121011_add_dee_to_p_product_refs.rb @@ -1,7 +1,7 @@ class AddDeeToPProductRefs < ActiveRecord::Migration[6.0] def change - add_column :p_product_refs, :ca_dee, :decimal - add_column :p_product_refs, :cc_dee, :decimal - add_column :p_product_refs, :ct_dee, :decimal + add_column :p_product_refs, :ca_dee, :decimal, :precision => 10, :scale => 2 + add_column :p_product_refs, :cc_dee, :decimal, :precision => 10, :scale => 2 + add_column :p_product_refs, :ct_dee, :decimal, :precision => 10, :scale => 2 end end diff --git a/db/schema.rb b/db/schema.rb index bebdd70..81e123a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1793,12 +1793,12 @@ ActiveRecord::Schema.define(version: 2021_09_17_124338) do t.boolean "stocked", default: true t.text "description" t.integer "p_product_color_id" - t.decimal "ca_sorecop", precision: 10 - t.decimal "cc_sorecop", precision: 10 - t.decimal "ct_sorecop", precision: 10 - t.decimal "ca_dee", precision: 10 - t.decimal "cc_dee", precision: 10 - t.decimal "ct_dee", precision: 10 + t.decimal "ca_sorecop", precision: 10, scale: 2 + t.decimal "cc_sorecop", precision: 10, scale: 2 + t.decimal "ct_sorecop", precision: 10, scale: 2 + t.decimal "ca_dee", precision: 10, scale: 2 + t.decimal "cc_dee", precision: 10, scale: 2 + t.decimal "ct_dee", precision: 10, scale: 2 t.string "ean" t.string "sorecop_comment" end From 39fe54bdad4101043420c878e589e2344ae1d3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 16:48:14 +0200 Subject: [PATCH 107/121] missing e in DEEE --- app/models/p_product_ref.rb | 16 +++++++++------- app/views/admin/p_product_refs/_form.html.haml | 10 ++++++++++ .../20210917121011_add_dee_to_p_product_refs.rb | 7 ------- .../20210917121011_add_deee_to_p_product_refs.rb | 7 +++++++ db/schema.rb | 6 +++--- 5 files changed, 29 insertions(+), 17 deletions(-) delete mode 100644 db/migrate/20210917121011_add_dee_to_p_product_refs.rb create mode 100644 db/migrate/20210917121011_add_deee_to_p_product_refs.rb diff --git a/app/models/p_product_ref.rb b/app/models/p_product_ref.rb index 9ff80d1..9a7fccf 100644 --- a/app/models/p_product_ref.rb +++ b/app/models/p_product_ref.rb @@ -43,12 +43,14 @@ class PProductRef < ApplicationRecord :description => {:name => "Description"}, :ct_sub_name => {:name => "Nom référence"}, :ct_price_ht => {:name => "Prix de vente", :as => :currency}, - - + :ean => {:name => "EAN"}, + :ca_deee => {:name => "DEEE", :as => :currency}, + :ca_sorecop => {:name => "Sorecop", :as => :currency}, + :sorecop_comment => {:name => "Type de Sorecop"}, :actions => {:name => "Actions", :reorder => false} } - acts_as_caching :fields => [:sorecop, :dee] + acts_as_caching :fields => [:sorecop, :deee] def not_imported? if !self.p_product or !self.p_product.imported @@ -159,11 +161,11 @@ class PProductRef < ApplicationRecord end end - def ca_dee - if self.cc_dee - return self.cc_dee + def ca_deee + if self.cc_deee + return self.cc_deee else - "TODO Calcul DEE" + "TODO Calcul DEEE" end end diff --git a/app/views/admin/p_product_refs/_form.html.haml b/app/views/admin/p_product_refs/_form.html.haml index b7ff800..4b0b755 100644 --- a/app/views/admin/p_product_refs/_form.html.haml +++ b/app/views/admin/p_product_refs/_form.html.haml @@ -1,3 +1,4 @@ +=#debug form.object.errors.messages =# form.input :ref, :label => "Ref :" .qi_row.field .qi_pannel.qi_plain.padding @@ -19,6 +20,15 @@ %td =form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true + %td + =form.input :ct_sorecop, :label => "Sorecop personalisée :" + %td + =form.input :sorecop_comment, :label => "Type de Sorecop :" + %td + =form.input :ct_deee, :label => "DEEE personalisée :" + %td + =form.input :ean + diff --git a/db/migrate/20210917121011_add_dee_to_p_product_refs.rb b/db/migrate/20210917121011_add_dee_to_p_product_refs.rb deleted file mode 100644 index ddf1f70..0000000 --- a/db/migrate/20210917121011_add_dee_to_p_product_refs.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddDeeToPProductRefs < ActiveRecord::Migration[6.0] - def change - add_column :p_product_refs, :ca_dee, :decimal, :precision => 10, :scale => 2 - add_column :p_product_refs, :cc_dee, :decimal, :precision => 10, :scale => 2 - add_column :p_product_refs, :ct_dee, :decimal, :precision => 10, :scale => 2 - end -end diff --git a/db/migrate/20210917121011_add_deee_to_p_product_refs.rb b/db/migrate/20210917121011_add_deee_to_p_product_refs.rb new file mode 100644 index 0000000..9542490 --- /dev/null +++ b/db/migrate/20210917121011_add_deee_to_p_product_refs.rb @@ -0,0 +1,7 @@ +class AddDeeeToPProductRefs < ActiveRecord::Migration[6.0] + def change + add_column :p_product_refs, :ca_deee, :decimal, :precision => 10, :scale => 2 + add_column :p_product_refs, :cc_deee, :decimal, :precision => 10, :scale => 2 + add_column :p_product_refs, :ct_deee, :decimal, :precision => 10, :scale => 2 + end +end diff --git a/db/schema.rb b/db/schema.rb index 81e123a..5baae52 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1796,9 +1796,9 @@ ActiveRecord::Schema.define(version: 2021_09_17_124338) do t.decimal "ca_sorecop", precision: 10, scale: 2 t.decimal "cc_sorecop", precision: 10, scale: 2 t.decimal "ct_sorecop", precision: 10, scale: 2 - t.decimal "ca_dee", precision: 10, scale: 2 - t.decimal "cc_dee", precision: 10, scale: 2 - t.decimal "ct_dee", precision: 10, scale: 2 + t.decimal "ca_deee", precision: 10, scale: 2 + t.decimal "cc_deee", precision: 10, scale: 2 + t.decimal "ct_deee", precision: 10, scale: 2 t.string "ean" t.string "sorecop_comment" end From a96ab1e4b6fe073d72ac9e6ba21e2046af89e13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 17:05:50 +0200 Subject: [PATCH 108/121] WIP export excel p_customer_sheets --- .../admin/p_customer_sheets_controller.rb | 81 ++++++++++++++++++- .../admin/p_customer_sheets/index.html.haml | 2 +- config/routes.rb | 1 + 3 files changed, 82 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index 5729f1c..76d9edd 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -280,6 +280,85 @@ class Admin::PCustomerSheetsController < ApplicationController end - + def export_xls + @p_customer_sheets = PCustomerSheet.all + respond_to do |format| + format.csv { + @headers = ["BUID", "DATE", "NUMERO", "CLIENT", "REFERENCE", "EAN", "DESIGNATION", "QTE", "PRIX 1", "PRIX 2", "DEEE", "SORECOP", "FOURNISSEUR", "CODE ARTICLE MAG", "NomMarque", "Code Douanier", "Type SORECOP"] + @columns = [] + # PCustomerSheet.qi_table_order.each do |key, value| + # if value.instance_of? Hash + # name = value[:name] + # else + # name = value + # end + + # if name != "Actions" + # @headers << name.to_s + # @columns << key + # end + + # end + + xlsx_package = Axlsx::Package.new + wb = xlsx_package.workbook + wb.add_worksheet(name: "BASIC extract to Chronopost") do |sheet| + sheet.add_row @headers + + @p_customer_sheets.each do |p_customer_sheet| + p_customer_sheet.price_line_block.price_lines.each do |price_line| + line = [] + line << price_line.id + line << p_customer_sheet.created_at.strftime("%d/%d/%Y") + line << p_customer_sheet.id + line << p_customer_sheet.p_customer.code + " - " + p_customer_sheet.p_customer.particulars.first.organisation + line << price_line.p_product_ref.cc_name + # line << price_line.p_product_ref.cc_ean + line << price_line.p_product_ref.ean + line << price_line.p_product_ref.cc_name + + line << price_line.qte + line << price_line.cc_price_u_ht + line << price_line.ct_u_price_ht + line << price_line.p_product_ref.deee + line << price_line.p_product_ref.sorecop + # line << price_line.p_product_ref.referal_fournisseur + line << "Fournisseur" + line << "" + + line << price_line.p_product_ref.p_product.s_brand.name + line << "Code douanier" + line << price_line.p_product_ref.sorecop_comment + sheet.add_row line, types: line.map{|t| cell_type_from_value(t)} + # puts line + end + + + # @columns.each do |column| + + # if (p_customer_sheet.respond_to?("csv_"+column.to_s)) + # line << p_customer_sheet.send("csv_"+column.to_s) + # elsif (p_customer_sheet.respond_to?(column)) + # if p_customer_sheet.send(column.to_s).class.to_s == "BigDecimal" + # line << p_customer_sheet.send(column.to_s).to_s.gsub('.', ',') + # else + # line << p_customer_sheet.send(column.to_s) + # end + # else + # line << column.to_s + # end + # end + # sheet.add_row line, types: line.map{|t| cell_type_from_value(t)} + end + end + + @final_file = "#{Rails.root}/private_medias/export-inscrits-#{Time.now.to_s.to_slug}.xlsx" + + xlsx_package.serialize(@final_file) + send_file @final_file + } + end + end + end diff --git a/app/views/admin/p_customer_sheets/index.html.haml b/app/views/admin/p_customer_sheets/index.html.haml index 8657d2a..0819b93 100644 --- a/app/views/admin/p_customer_sheets/index.html.haml +++ b/app/views/admin/p_customer_sheets/index.html.haml @@ -1,7 +1,7 @@ .qi_header .right =link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add" - + =link_to "Export xls", export_xls_admin_p_customer_sheets_path(format: :csv) %h1 Ventes %span diff --git a/config/routes.rb b/config/routes.rb index 76ae891..a5835ca 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1053,6 +1053,7 @@ Rails.application.routes.draw do collection do get :affects get :update_stocks + get :export_xls end end From c42a3909ee7141f2dfdfed75078938b3bf471ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 17:50:40 +0200 Subject: [PATCH 109/121] Check if qte change + min qte = 0 --- app/views/admin/buy_lists/index.html.haml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 1808240..862b4f4 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -204,7 +204,7 @@ %td.mask =check_box_tag :"p_product_ref_ids[]", plr.p_product_ref.id - =number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: ([bpa_qte - qte_available, 0].max) + =number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: ([bpa_qte - qte_available, 0].max), min: 0 %td.mask = bpa_qte @@ -307,9 +307,11 @@ } :javascript + // TOOGLE ORDERS DETAILS - set to hidden $('.detail').hide() $('.col-detail').hide() let state = 0 + // TOGGLE ORDER LINE DETAILS $('.plus').click(function(event){ if( event.currentTarget.className == "plus") { $(event.currentTarget).removeClass('plus').addClass('minus') @@ -328,6 +330,7 @@ $('.col-detail').show() } }); + // TOOGLE ALL ORDERS DETAILS $('.plus-all').click(function(event){ if( event.currentTarget.className == "mask plus-all") { state += $('.plus').length @@ -351,6 +354,15 @@ $('.col-detail').show() } }); + // CHECK QTE IF QTE CHANGE + $('.small-input').change(function(){ + let checkbox = $(this).closest('td').find("input[type=checkbox]") + if (this.value > 0) { + checkbox.prop("checked", true) + } else { + checkbox.prop("checked", false) + } + }) From 2bf2efc6a630b3605622414b05fa683f2ab1423c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 19:11:37 +0200 Subject: [PATCH 110/121] Redirect on price_documents --- .../admin/p_product_refs_controller.rb | 4 +- .../admin/price_documents_controller.rb | 16 ++- app/models/price_line.rb | 2 +- app/models/price_line_block.rb | 2 +- .../_form_commande_achat.html.haml | 106 ++++++++++++++++++ .../_form_facture_achat.html.haml | 106 ++++++++++++++++++ 6 files changed, 229 insertions(+), 7 deletions(-) create mode 100644 app/views/admin/price_line_blocks/_form_commande_achat.html.haml create mode 100644 app/views/admin/price_line_blocks/_form_facture_achat.html.haml diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index ecec7c3..736d823 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -106,9 +106,11 @@ class Admin::PProductRefsController < ApplicationController if @p_product_ref.update_attributes(params.require(:p_product_ref).permit!) + else - render action: "edit" + + render action: "edit" end diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index ce7b3f5..6966596 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -224,7 +224,7 @@ class Admin::PriceDocumentsController < ApplicationController def show @price_document = PriceDocument.find(params[:id]) - + @facture_achat_childrens = PriceDocument.where(doc_ref_id: @price_document.id, price_document_type: PriceDocumentType.find_by_label("Facture achat")) end def new @@ -322,7 +322,11 @@ class Admin::PriceDocumentsController < ApplicationController @price_document.date = Date.today @avoir = true if @price_document.label == "Avoir" if @price_document.save - redirect_to admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id) + if @price_document.cc_label == "Demande prix" + render action: :show + else + redirect_to admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id) + end else render action: "new" @@ -343,7 +347,11 @@ class Admin::PriceDocumentsController < ApplicationController #@price_document.unarchive_now #@price_document.archive_now - if @price_document.ref_element + if @price_document.cc_label = "Facture achat" + redirect_to [:admin, @price_document] + elsif @price_document.doc_ref_id + redirect_to [:admin, PriceDocument.find(@price_document.doc_ref_id)] + elsif @price_document.ref_element redirect_to [:admin, @price_document.ref_element] else redirect_to [:admin, @price_document] @@ -653,7 +661,7 @@ class Admin::PriceDocumentsController < ApplicationController end @final_consult = PriceDocument.where(price_document_type: PriceDocumentType.find_by_label("Consultation fournisseur")).last - redirect_to :analyse_reponses_admin_price_document + redirect_to admin_price_document_path(@price_document_demand, anchor: "consult") end def buy_order_create diff --git a/app/models/price_line.rb b/app/models/price_line.rb index 9be5aea..32e2d5b 100644 --- a/app/models/price_line.rb +++ b/app/models/price_line.rb @@ -52,7 +52,7 @@ class PriceLine < ApplicationRecord BON_DE_LIVRAISON_TO_RESET = %w(block_type weight_tot tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc) - FACTURE_DACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) + FACTURE_ACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) BON_DE_RECEPTION_ACHAT_TO_RESET = %w(devise_rate local_tot_amount_ht block_type product_no_remise price_calc weight_u weight_tot tva_account_id tva_account_value ref title description price_u_ht price_u_tva price_u_ttc tot_line_ht tot_line_tva tot_line_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc discount_market_percent discount_qte_percent discount_delay_percent discount_enrobage_percent discount_ecole_percent discount_comptant_percent product_remise_enrobage_ok uv p_product_specific_customer_id) diff --git a/app/models/price_line_block.rb b/app/models/price_line_block.rb index 6efcba4..942a0ea 100644 --- a/app/models/price_line_block.rb +++ b/app/models/price_line_block.rb @@ -326,7 +326,7 @@ class PriceLineBlock < ApplicationRecord BON_DE_LIVRAISON_TO_RESET = %w(weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) - FACTURE_DACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) + FACTURE_ACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) BON_DE_RECEPTION_ACHAT_TO_RESET = %w(devise_rate weight_tot tot_lines_ht tot_lines_tva tot_lines_ttc tot_fdp_ht tot_fdp_tva tot_fdp_ttc tot_discount_ht tot_discount_tva tot_discount_ttc tot_amount_af_discount_ht tot_amount_af_discount_tva tot_amount_af_discount_ttc gen_discount_percent tot_gen_discount_ht tot_gen_discount_tva tot_gen_discount_ttc tot_amount_ht tot_amount_tva tot_amount_ttc nbr_ship) diff --git a/app/views/admin/price_line_blocks/_form_commande_achat.html.haml b/app/views/admin/price_line_blocks/_form_commande_achat.html.haml new file mode 100644 index 0000000..dca9aea --- /dev/null +++ b/app/views/admin/price_line_blocks/_form_commande_achat.html.haml @@ -0,0 +1,106 @@ + +=f.inputs do + + + -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") + .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} + = f.input :p_commercial_id, :label => "Commercial :", :collection => PCommercial.order(:name).all, :as => :select, :member_label => :long_name if f.object.id + + + = f.hidden_field :p_customer_id, :class => "p_customer_id" + + .p_customer_sheet_customer + + + -if f.object.p_customer and f.object.p_customer.particular + =render :partial => "admin/p_customers/apercu", :locals => {:particular => f.object.p_customer.particular} + + .addresses.row + .columns.span_6 + %h3 Adresse de facturation + + -if f.object.p_customer + =f.inputs do + = f.input :particular_bill_id, :collection => f.object.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de facturation" + -else + =f.inputs do + = f.input :particular_bill_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation" + + .columns.span_6 + %h3 Adresse de livraison + + -if f.object.p_customer + =f.inputs do + = f.input :particular_send_id, :collection => f.object.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de livraison" + -else + =f.inputs do + = f.input :particular_send_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation" + + .clear + + + %table{:style => "width:100%;"} + %tr + %td{:style => "width:50%;"} + = f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date + + %td{:style => "width:50%;"} + = f.input :ct_creation_date, :label => "Date de commande (si différente de la date de création) :", :as => :date + + + + = f.input :customer_ref, :label => "Référence commande client :" + -if current_admin.has_permission?("customer-sheets-bl") + = f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"} + + -if @p_customer_sheet and @p_customer_sheet.p_customer and @p_customer_sheet.p_customer.p_customer_sheet_note? + %div + %strong Notes pour les demandes de commandes pour ce client : + =simple_format @p_customer_sheet.p_customer.p_customer_sheet_note + %br + + + + + .price_lines_form + =f.semantic_fields_for :price_lines do |f| + =render :partial => "admin/price_lines/form_bon_de_reception_achat", :locals => {:form => f} + + %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary"} + + + -if current_admin.has_permission?("payments") + .qi_pannel.qi_plain.padding.price_line_block_footer{:style => "margin:20px 0;"} + + -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") + -if !@avoir + = f.input :ct_tot_discount_percent, :label => "Réduction pied de page (%) :", :input_html => {:class => "input_price_line_block_ct_tot_discount_percent"} + = f.input :ct_tot_fdp_ht, :label => "Frais de port personnalisés :" + + -if !@avoir + -if current_admin.has_permission?("customer-sheets-bl") + = f.input :ct_nbr_ship, :label => "Nombre de colis :" + + -if current_admin.has_permission?("payments") + -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") + - if f.object.id + .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} + %h4 Paiements + + = f.input :p_payment_type_id, :label => "Type de paiement :", :include_blank => false, :collection => PPaymentType.order(:name).all, :as => :select, :input_html => {:id => "payment_type_id_select"} + + + = f.input :ct_payment_comptant, :label => "Paiement comptant nécessaire ?" + + -if false + = f.input :ct_acompte, :label => "Acompte nécessaire ?" + = f.input :ct_acompte_percent, :label => "Pourcentage d'acompte :" + + = f.input :ct_payment_delais, :label => "Délais jour de paiement :" + + -if false + = f.input :ct_payment_month_end, :label => "Fin de mois ?" + + + + diff --git a/app/views/admin/price_line_blocks/_form_facture_achat.html.haml b/app/views/admin/price_line_blocks/_form_facture_achat.html.haml new file mode 100644 index 0000000..dca9aea --- /dev/null +++ b/app/views/admin/price_line_blocks/_form_facture_achat.html.haml @@ -0,0 +1,106 @@ + +=f.inputs do + + + -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") + .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} + = f.input :p_commercial_id, :label => "Commercial :", :collection => PCommercial.order(:name).all, :as => :select, :member_label => :long_name if f.object.id + + + = f.hidden_field :p_customer_id, :class => "p_customer_id" + + .p_customer_sheet_customer + + + -if f.object.p_customer and f.object.p_customer.particular + =render :partial => "admin/p_customers/apercu", :locals => {:particular => f.object.p_customer.particular} + + .addresses.row + .columns.span_6 + %h3 Adresse de facturation + + -if f.object.p_customer + =f.inputs do + = f.input :particular_bill_id, :collection => f.object.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de facturation" + -else + =f.inputs do + = f.input :particular_bill_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation" + + .columns.span_6 + %h3 Adresse de livraison + + -if f.object.p_customer + =f.inputs do + = f.input :particular_send_id, :collection => f.object.p_customer.particulars.all, :as => :select, :member_label => :address_line, :include_blank => false, :label => "Adresse de livraison" + -else + =f.inputs do + = f.input :particular_send_id, :collection => [], :as => :select, :include_blank => false, :label => "Adresse de facturation" + + .clear + + + %table{:style => "width:100%;"} + %tr + %td{:style => "width:50%;"} + = f.input :wish_date, :label => "Date de livraison souhaitée :", :as => :date + + %td{:style => "width:50%;"} + = f.input :ct_creation_date, :label => "Date de commande (si différente de la date de création) :", :as => :date + + + + = f.input :customer_ref, :label => "Référence commande client :" + -if current_admin.has_permission?("customer-sheets-bl") + = f.input :bl_comment, :label => "Commentaire à mettre sur le BL :", :input_html => {:style => "min-height:50px;height:50px;"} + + -if @p_customer_sheet and @p_customer_sheet.p_customer and @p_customer_sheet.p_customer.p_customer_sheet_note? + %div + %strong Notes pour les demandes de commandes pour ce client : + =simple_format @p_customer_sheet.p_customer.p_customer_sheet_note + %br + + + + + .price_lines_form + =f.semantic_fields_for :price_lines do |f| + =render :partial => "admin/price_lines/form_bon_de_reception_achat", :locals => {:form => f} + + %p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary"} + + + -if current_admin.has_permission?("payments") + .qi_pannel.qi_plain.padding.price_line_block_footer{:style => "margin:20px 0;"} + + -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") + -if !@avoir + = f.input :ct_tot_discount_percent, :label => "Réduction pied de page (%) :", :input_html => {:class => "input_price_line_block_ct_tot_discount_percent"} + = f.input :ct_tot_fdp_ht, :label => "Frais de port personnalisés :" + + -if !@avoir + -if current_admin.has_permission?("customer-sheets-bl") + = f.input :ct_nbr_ship, :label => "Nombre de colis :" + + -if current_admin.has_permission?("payments") + -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") + - if f.object.id + .qi_pannel.qi_plain.padding{:style => "margin:20px 0;"} + %h4 Paiements + + = f.input :p_payment_type_id, :label => "Type de paiement :", :include_blank => false, :collection => PPaymentType.order(:name).all, :as => :select, :input_html => {:id => "payment_type_id_select"} + + + = f.input :ct_payment_comptant, :label => "Paiement comptant nécessaire ?" + + -if false + = f.input :ct_acompte, :label => "Acompte nécessaire ?" + = f.input :ct_acompte_percent, :label => "Pourcentage d'acompte :" + + = f.input :ct_payment_delais, :label => "Délais jour de paiement :" + + -if false + = f.input :ct_payment_month_end, :label => "Fin de mois ?" + + + + From f17034592d9ca56ffd6acba6231fa580d479ad84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Fri, 17 Sep 2021 19:11:49 +0200 Subject: [PATCH 111/121] Update show --- .../admin/price_documents/show.html.haml | 53 +++++++++++++------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 47c1885..132a98c 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -266,6 +266,24 @@ -if @price_document.d_number -if @price_document.cc_label == "Commande achat" %p=link_to "Générer un bon de réception", bon_de_reception_admin_price_document_path(@price_document), :class => "btn btn-primary" + %p=link_to "Générer la facture", facture_achat_admin_price_document_path(@price_document), :class => "btn btn-primary" + + -if @facture_achat_childrens.present? + %h3 Facture Achat + -params[:search][:per_page] = params[:search][:per_page] || 5000 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + + -@facture_achat_childrens = @facture_achat_childrens.order("date DESC, created_at DESC") + + + -#@line_stocks = sort_by_sorting(@line_stocks, "created_at DESC") + -@facture_achat_childrens = @facture_achat_childrens.page(page).per(per_page) + %br + .clear + + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @facture_achat_childrens} + -if @price_document.cc_label == "Commande achat" =render :partial => "admin/price_documents/relicats", :locals => {:bca => @price_document} -if false @@ -359,25 +377,9 @@ =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"} - %h3.ml-2 Consultations fournisseur + %h3.ml-2 Consultations fournisseur : #consult - -params[:search][:per_page] = params[:search][:per_page] || 5000 - -per_page = params[:search][:per_page] - -page = (params[:page] and params[:page] != "") ? params[:page] : 1 - -@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Consultation fournisseur").id) - - - - - -@price_documents = sort_by_sorting(@price_documents, "created_at DESC") - -@price_documents = @price_documents.page(page).per(per_page) - %br - - - - .clear - =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"} -if @price_documents.empty? .qi_pannel.qi_plain.padding Pas de consultation générée. @@ -406,6 +408,23 @@ =f.semantic_fields_for :price_lines do |form| =render partial: "admin/price_lines/form_consult", locals: {form: form} + -params[:search][:per_page] = params[:search][:per_page] || 5000 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + + -@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Consultation fournisseur").id) + + + + + -@price_documents = sort_by_sorting(@price_documents, "created_at DESC") + -@price_documents = @price_documents.page(page).per(per_page) + %br + + + %h4.ml-2 Liste des consultations fournisseurs + .clear + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"} From cc90aa2457f9b7480c80b1a3bedd428867c6ab6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 20 Sep 2021 15:12:14 +0200 Subject: [PATCH 112/121] checkbox checked if qte > 0 --- app/views/admin/buy_lists/index.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 862b4f4..de9fbbb 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -202,9 +202,10 @@ %td.mask = qte_available %td.mask - =check_box_tag :"p_product_ref_ids[]", plr.p_product_ref.id + - default_qte = [bpa_qte - qte_available, 0].max + =check_box_tag :"p_product_ref_ids[]", plr.p_product_ref.id, (true if default_qte > 0 ) - =number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: ([bpa_qte - qte_available, 0].max), min: 0 + =number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: default_qte, min: 0 %td.mask = bpa_qte From 30ad9d661d379b29e6d6d52f9aa27d20ee23c184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 20 Sep 2021 17:50:04 +0200 Subject: [PATCH 113/121] bugfix --- app/controllers/admin/price_documents_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 6966596..2eb5ca2 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -340,14 +340,13 @@ class Admin::PriceDocumentsController < ApplicationController @avoir = true if @price_document.label == "Avoir" if @price_document.update_attributes(params.require(:price_document).permit!) - if params[:public_edit].to_s == "true" @price_document.reset_for_update #@price_document.unarchive_now #@price_document.archive_now - if @price_document.cc_label = "Facture achat" + if @price_document.cc_label == "Facture achat" redirect_to [:admin, @price_document] elsif @price_document.doc_ref_id redirect_to [:admin, PriceDocument.find(@price_document.doc_ref_id)] @@ -356,6 +355,11 @@ class Admin::PriceDocumentsController < ApplicationController else redirect_to [:admin, @price_document] end + + elsif @price_document.doc_ref_id + redirect_to [:admin, PriceDocument.find(@price_document.doc_ref_id)] + elsif @price_document.ref_element + redirect_to [:admin, @price_document.ref_element] else redirect_to [:admin, @price_document] end From c74863ad27544c5ca44b9580f0b79a39c32a683c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 20 Sep 2021 19:13:46 +0200 Subject: [PATCH 114/121] p_customer_sheet Export xls --- .../admin/p_customer_sheets_controller.rb | 4 ++ app/models/p_customer_sheet.rb | 1 + .../_p_customer_sheet.html.haml | 8 ++- .../admin/p_customer_sheets/index.html.haml | 58 ++++++++++++++++++- 4 files changed, 67 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index 76d9edd..fbc5058 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -282,6 +282,10 @@ class Admin::PCustomerSheetsController < ApplicationController def export_xls @p_customer_sheets = PCustomerSheet.all + if params[:p_customer_sheet_ids].present? + @p_customer_sheets = PCustomerSheet.where(id: params[:p_customer_sheet_ids]) + end + respond_to do |format| format.csv { @headers = ["BUID", "DATE", "NUMERO", "CLIENT", "REFERENCE", "EAN", "DESIGNATION", "QTE", "PRIX 1", "PRIX 2", "DEEE", "SORECOP", "FOURNISSEUR", "CODE ARTICLE MAG", "NomMarque", "Code Douanier", "Type SORECOP"] diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb index 70d1426..b09c5f4 100644 --- a/app/models/p_customer_sheet.rb +++ b/app/models/p_customer_sheet.rb @@ -40,6 +40,7 @@ class PCustomerSheet < ApplicationRecord :tot_amount_ht => {:name => "Total HT", :reorder => true, :sort_name => "cc_tot_amount_ht", :sort_name => "p_customer_sheets.cc_tot_amount_ht"}, :tot_amount_ttc => {:name => "Total TTC", :reorder => true, :sort_name => "cc_tot_amount_ttc", :sort_name => "p_customer_sheets.cc_tot_amount_ttc"}, :state => {:name => "Statut", :reorder => false, :as => :state}, + :check_box => {:name => "Export excel", :reorder => false}, :actions => {:name => "Actions", :reorder => false}, } diff --git a/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml b/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml index 5a8f2b5..7d589a3 100644 --- a/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml +++ b/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml @@ -43,9 +43,11 @@ -tr[:tot_amount_ttc] = capture do %td.numeraire =number_to_currency p_customer_sheet.cc_tot_amount_ttc - - - + + -tr[:check_box] = capture do + %td + =check_box_tag "p_customer_sheet_ids[]", p_customer_sheet.id, false, data: { client: p_customer_sheet.p_customer.id }, id: "p_customer_sheet_id_checkbox_#{p_customer_sheet.id}" + -tr[:actions] = capture do %td.actions -if p_customer_sheet.state == "brouillon" and p_customer_sheet.demande_type.to_s == "Brouillon" diff --git a/app/views/admin/p_customer_sheets/index.html.haml b/app/views/admin/p_customer_sheets/index.html.haml index 0819b93..1a14c94 100644 --- a/app/views/admin/p_customer_sheets/index.html.haml +++ b/app/views/admin/p_customer_sheets/index.html.haml @@ -179,5 +179,61 @@ ="-" =link_to ic(:times)+" Supprimer ce filtre", params.permit!.merge({ :active_kpi => nil, :p_customer_sheet_ids => nil}) +%div + =form_tag export_xls_admin_p_customer_sheets_path(format: :csv), id: 'export-form', :method => "get" do + .table + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_customer_sheets} + + %button.btn.btn-primary.ml-4{onclick: "checkMultipleClient()"} + =ic("file-excel-o") + Export Xls +.modal.fade#multi-client-export{"tab-index" => "-1", "role" => "dialog", "aria-labelledby" => "Raprochement Fournisseur", "aria-hidden" => "true"} + .modal-dialog{role: "dialog"} + .modal-content + .modal-header + %h5.modal-title + Export Excel + %button.close{"data-dismiss" => "modal", "aria-label" => "Close"} + %span{"aria-hidden" => "true"} + × + .modal-body + Attention ! + %br + %br + Selection de plusieurs clients détécté + %br + Vous avez selectionné des commandes liées à différents clients. + %br + Etes-vous sûr ? + + .modal-footer + %button.btn.btn-light{"data-dismiss" => "modal"} + Annuler l'export + %button.btn.btn-primary{"data-dismiss" => "modal", onclick: "submitExport()"} + =ic("file-excel-o") + Confirmer + +:javascript + function submitExport() { + $('#export-form').submit() + } + + function checkDiff(arr) { + return arr.every(e => e == arr[0]); + } + + const checkMultipleClient = () => { + let arr = [] + $('.table input[type=checkbox]').each(function( i ) { + if ( this.checked === true) + arr.push($(this).data('client')) + }) + if (checkDiff(arr) === false) { + $('#multi-client-export').modal('show') + } else { + submitExport() + } + } + + -=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_customer_sheets} From c49f7e3533658206199c2a6c1e410b4205cfa4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 20 Sep 2021 19:13:59 +0200 Subject: [PATCH 115/121] bugfix --- app/views/admin/price_documents/show.html.haml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index 132a98c..e7b30d4 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -390,7 +390,11 @@ -@price_documents.each do |price_document_consult| - %h4.ml-2= price_document_consult.p_fournisseur.name + - if price_document_consult.p_fournisseur + %h4.ml-2= price_document_consult.p_fournisseur.name + - else + %h4.ml-2=link_to ic('pencil') + " rapprocher le fournisseur", match_p_fournisseur_admin_price_document_path(price_document_consult), remote: true + = semantic_form_for [:admin, price_document_consult], :html => {:class => "qi_price_form"}, :remote => false do |form| = form.button "Valider modifications", type: :submit, class: "btn btn-primary m-2" From d84111fe672c4e71ff48a66b20d1ffdec9f8b94d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Mon, 20 Sep 2021 19:15:56 +0200 Subject: [PATCH 116/121] remove old link --- app/views/admin/p_customer_sheets/index.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/admin/p_customer_sheets/index.html.haml b/app/views/admin/p_customer_sheets/index.html.haml index 1a14c94..ad62a4b 100644 --- a/app/views/admin/p_customer_sheets/index.html.haml +++ b/app/views/admin/p_customer_sheets/index.html.haml @@ -1,7 +1,6 @@ .qi_header .right =link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add" - =link_to "Export xls", export_xls_admin_p_customer_sheets_path(format: :csv) %h1 Ventes %span @@ -186,7 +185,7 @@ %button.btn.btn-primary.ml-4{onclick: "checkMultipleClient()"} =ic("file-excel-o") - Export Xls + Export xls .modal.fade#multi-client-export{"tab-index" => "-1", "role" => "dialog", "aria-labelledby" => "Raprochement Fournisseur", "aria-hidden" => "true"} .modal-dialog{role: "dialog"} .modal-content From 70826a52ca2a21b6235e3a4087b2411319b6cbcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 21 Sep 2021 09:47:45 +0200 Subject: [PATCH 117/121] udate redirects --- app/controllers/admin/price_documents_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/price_documents_controller.rb b/app/controllers/admin/price_documents_controller.rb index 2eb5ca2..b224d70 100644 --- a/app/controllers/admin/price_documents_controller.rb +++ b/app/controllers/admin/price_documents_controller.rb @@ -346,7 +346,7 @@ class Admin::PriceDocumentsController < ApplicationController #@price_document.unarchive_now #@price_document.archive_now - if @price_document.cc_label == "Facture achat" + if ["Facture achat", "Commande achat"].include?(@price_document.cc_label) redirect_to [:admin, @price_document] elsif @price_document.doc_ref_id redirect_to [:admin, PriceDocument.find(@price_document.doc_ref_id)] From bb6e89d7f1f596a93e8c20ebf6b8d5b4fa45d83b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 21 Sep 2021 10:55:22 +0200 Subject: [PATCH 118/121] add container --- .../admin/price_documents/consult.html.haml | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/views/admin/price_documents/consult.html.haml b/app/views/admin/price_documents/consult.html.haml index 5554f0f..840b8fd 100644 --- a/app/views/admin/price_documents/consult.html.haml +++ b/app/views/admin/price_documents/consult.html.haml @@ -30,27 +30,32 @@ =f.hidden_field :doc_ref_id =f.hidden_field :price_document_type_id - - %center= f.input :public_fournisseur_name, :label => "Nom de votre société :" + + %center + .small-container + = f.input :public_fournisseur_name, :label => "Nom de votre société :" - %p{:style => "text-align:center;font-size:1.2em;"} - Vous pouvez également indiquer votre référence interne : + %p{:style => "text-align:center;font-size:1.2em;"} + Vous pouvez également indiquer votre référence interne : - =hidden_field_tag :public_edit, params[:public_edit] + =hidden_field_tag :public_edit, params[:public_edit] - .price_line_block_form - =f.semantic_fields_for :price_line_block do |f| - %center=render :partial => "admin/price_line_blocks/form_#{f.object.block_type_slug}", :locals => {:f => f} + .price_line_block_form + =f.semantic_fields_for :price_line_block do |f| + %center=render :partial => "admin/price_line_blocks/form_#{f.object.block_type_slug}", :locals => {:f => f} %center =f.submit "sauvegarder", :class => "btn btn-primary" - +:scss + .small-container{ + max-width: 500px; + } - \ No newline at end of file + From 5a979f96dccedd5731000037a9297a0dc6f83386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 23 Sep 2021 12:36:05 +0200 Subject: [PATCH 119/121] Select all p_customer_sheets export --- app/models/p_customer_sheet.rb | 2 +- .../admin/p_customer_sheets/index.html.haml | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb index b09c5f4..158e723 100644 --- a/app/models/p_customer_sheet.rb +++ b/app/models/p_customer_sheet.rb @@ -40,7 +40,7 @@ class PCustomerSheet < ApplicationRecord :tot_amount_ht => {:name => "Total HT", :reorder => true, :sort_name => "cc_tot_amount_ht", :sort_name => "p_customer_sheets.cc_tot_amount_ht"}, :tot_amount_ttc => {:name => "Total TTC", :reorder => true, :sort_name => "cc_tot_amount_ttc", :sort_name => "p_customer_sheets.cc_tot_amount_ttc"}, :state => {:name => "Statut", :reorder => false, :as => :state}, - :check_box => {:name => "Export excel", :reorder => false}, + :check_box => {:name => "Export excel #{''}", :reorder => false}, :actions => {:name => "Actions", :reorder => false}, } diff --git a/app/views/admin/p_customer_sheets/index.html.haml b/app/views/admin/p_customer_sheets/index.html.haml index ad62a4b..f61d281 100644 --- a/app/views/admin/p_customer_sheets/index.html.haml +++ b/app/views/admin/p_customer_sheets/index.html.haml @@ -199,7 +199,7 @@ Attention ! %br %br - Selection de plusieurs clients détécté + Selection de plusieurs clients détéctée %br Vous avez selectionné des commandes liées à différents clients. %br @@ -213,6 +213,17 @@ Confirmer :javascript + $("#check-all").parent().on("click", function(event) { + console.log(event.currentTarget) + event.currentTarget.classList.toggle("checked") + if(event.currentTarget.classList.contains("checked")){ + $('.table input[type=checkbox]').prop("checked", true) + }else{ + $('.table input[type=checkbox]').prop("checked", false) + } + }) + + "#dataTable tbody tr" function submitExport() { $('#export-form').submit() } @@ -235,4 +246,9 @@ } +:scss + th > i { + cursor: pointer; + } + From d9b76dfae9fe2c7cdaaacdd38fd864c1a04379e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 23 Sep 2021 17:48:13 +0200 Subject: [PATCH 120/121] remove fake marge --- app/views/admin/price_documents/analyse_reponses.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/price_documents/analyse_reponses.html.haml b/app/views/admin/price_documents/analyse_reponses.html.haml index 5801960..8627aca 100644 --- a/app/views/admin/price_documents/analyse_reponses.html.haml +++ b/app/views/admin/price_documents/analyse_reponses.html.haml @@ -2,7 +2,7 @@ %h1 Achats %span - Analyse des réponces à la consiltation n° + Analyse des réponces à la demande de prix n° = link_to @price_document.d_number, admin_price_document_path(@price_document) \- = @price_document.list_designaton @@ -175,7 +175,7 @@ - cell << "PA: #{line.ct_u_price_ht} €" - # mp = calcul de la marge prévisionelle TODO - line.id.odd? ? mp = 0.17 : mp = 0.11 - - if mp.present? + - if false -if mp > 0.15 - cell << "#{ic(:check)} MP: #{mp * 100} %" -else From 8e7442dcc044b9c14005d2413357a358b4a3d166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Thu, 23 Sep 2021 17:51:41 +0200 Subject: [PATCH 121/121] filter consult --- app/views/admin/price_documents/show.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/admin/price_documents/show.html.haml b/app/views/admin/price_documents/show.html.haml index e7b30d4..1f7bc6a 100644 --- a/app/views/admin/price_documents/show.html.haml +++ b/app/views/admin/price_documents/show.html.haml @@ -376,6 +376,7 @@ .clear =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => "reponses-prix-show"} + -@price_documents = PriceDocument.where(:doc_ref_id => @price_document.id, :price_document_type_id => PriceDocumentType.find_by_label("Consultation fournisseur").id) %h3.ml-2 Consultations fournisseur : #consult