From 820bd0364076487cdb4ec57c1621cfe39e741d91 Mon Sep 17 00:00:00 2001 From: Philippe Date: Tue, 9 Nov 2021 12:13:52 +0100 Subject: [PATCH] fixing p_article_price_line mannel bug --- .../(__TEMPLATE__)c | Bin 1374 -> 5965 bytes app/models/p_customer_sheet.rb | 10 +--- .../admin/p_customer_sheets/_form.html.haml | 1 - .../admin/price_line_blocks/_form.html.haml | 53 +++++++++--------- .../price_line_p_articles/_form.html.haml | 2 +- .../_add_price_line_p_article_form.html.haml | 2 +- app/views/admin/price_lines/_form.html.haml | 51 ----------------- 7 files changed, 31 insertions(+), 88 deletions(-) diff --git a/.sass-cache/f6b9a0b1905a68d5dbb2139e95d49cba92f6fa93/(__TEMPLATE__)c b/.sass-cache/f6b9a0b1905a68d5dbb2139e95d49cba92f6fa93/(__TEMPLATE__)c index e1c3ae14c64ffb6b86d264611307231a215c18c3..f14f6942a4eff9a4b9af0c9026e5b8e2e708b671 100644 GIT binary patch literal 5965 zcmbVQUvt~W5f?Qbii9jtbo9@ZEVHzu*orOEk{sE0Gwmg=JYgnrG#1krJz$RHi9!S7 zPym#pdi>UWh4f?eOSNC2eQb9Re~w2&ij*hfh}*s2?(P0|7yG-1y9d_c!NDQ#?RC4a z&iLMo?w)8J?Dt;r=l$Nx7hJsT9f~iyqPyR+epiy@-U$ywLOOvEguIh7dMo?l4q0Tq zbI0um!aFTbZW_4)H&uwm0(d?xwi{~?yRv_2hY^pQFmnDn5@C@Pk2>To^LY@8zKuIW zNgDBSC&CrINCt$wmct=G5g_69M2Rf0p%`{W5S|t#xj(r%-8VNw?l5_F z7K#WS7ntz+N`%(bOS<8#!_f$_1yI3y8AKvzp&-2*|HO}EgN2FDZ37=&FVlNc>nqaD zvDG@g-)?;J*tR=I-yMJZW#`DYpA^ACbW4(YjJlm13PJP+aDwKJ%Sg~6E^pK)C+zI1b6Mr)MRR}EnL|f^(xS`RQFKjS@6{!GzeTt3dXzB!B##da$vL>+Qg$D>x=Zh~8r@|8sY@TY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yi&o3=E+Dqh)=xa=W;jOr!{~*}TOdV;FNivRLcnph4lp@eZA6!c8V33I^p{ zbbGWhhB~%Kj}?-qb!Y^hj14~5;2A3b3ez+fBA}aIRAO|3C};XZv#q3w%DzY>jDiia NrnY#MHog0u{{w}+6Mp~z delta 389 zcmX@BcaKZYSkGL~gv-Ft$jCf3HQB=4I4#v6HPtxPBq=#1&D_W+H6It+*WW5_3~Mm3W{MlU*3sGxAOT!WauA zgP5*QUc@3R#*>m+T#%Dk$!5(NV#V!HmY7qT8qGFYo>zSGdlp?8&b<7*RInVcLw-R? zW`16AH3QJ(lFEYA$(F48%IwzS`PLGg){^!FD8Pv&LQl7O1)pl>bfAZ0D*AZ;yVV6Ew(F}aIP8t9#DHaRm5D?W#k v)Lfu%N`SsrfrUpkmx2P+lU5+#SaWgJa&d8iJOy+U+vJbjiacy^Qw>7^kL+bZ diff --git a/app/models/p_customer_sheet.rb b/app/models/p_customer_sheet.rb index 414af69..76b4e3d 100644 --- a/app/models/p_customer_sheet.rb +++ b/app/models/p_customer_sheet.rb @@ -267,29 +267,25 @@ class PCustomerSheet < ApplicationRecord def generate_doc(label, state) self.archive_now if !self.archived self.block_price if !self.price_blocked - price_document = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today) - #raise - price_document.p_customer = self.p_customer + price_document = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today) + price_document.p_customer = self.p_customer price_document.price_line_block = self.price_line_block.dup price_document.tva_type = self.price_line_block.price_document.tva_type - price_document.price_line_block.ac_block_type = nil self.price_line_block.price_lines.each do |pl| new_pl = pl.dup new_pl.ac_block_type = nil + pl.p_articles.each { |p_article| new_pl.p_articles << p_article } price_document.price_line_block.price_lines << new_pl end if price_document.save - price_document.archive_now self.state = state self.save - end - end def generate_d diff --git a/app/views/admin/p_customer_sheets/_form.html.haml b/app/views/admin/p_customer_sheets/_form.html.haml index 9f1576e..5df9e97 100755 --- a/app/views/admin/p_customer_sheets/_form.html.haml +++ b/app/views/admin/p_customer_sheets/_form.html.haml @@ -19,4 +19,3 @@ =link_to "Annuler", admin_p_customer_sheets_path(), :class => "btn" =form.submit "sauvegarder", :class => "btn btn-primary btn-ap-add" .clear - diff --git a/app/views/admin/price_line_blocks/_form.html.haml b/app/views/admin/price_line_blocks/_form.html.haml index 861d505..d069561 100644 --- a/app/views/admin/price_line_blocks/_form.html.haml +++ b/app/views/admin/price_line_blocks/_form.html.haml @@ -51,34 +51,24 @@ %br - %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{: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"} - - - - - - - - - - + -# %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 + .qi_row.price_lines_form + =f.semantic_fields_for :price_lines do |f| + =render :partial => "admin/price_lines/form", :locals => {:form => f} + %p{:style=>"padding-left:10px;"}= link_to_add_fields ic("plus-circle") + " Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary p-2 add_lines", tabindex: 10} -if current_admin.has_permission?("payments") -if !@p_customer_sheet or (@p_customer_sheet and @p_customer_sheet.state != "commande") @@ -108,3 +98,12 @@ -if false .col-6 = f.input :ct_payment_month_end, :label => "Fin de mois ?" + +:javascript + $('.p_product_ref_select').select2(); + $('.add_lines').click(function() { + $('.p_product_ref_select').last().select2({ + //theme: "bootstrap" + }); + //$('.p_product_ref_select').last().removeClass('form-control'); + }) \ No newline at end of file diff --git a/app/views/admin/price_line_p_articles/_form.html.haml b/app/views/admin/price_line_p_articles/_form.html.haml index ea396e6..b58b1ec 100644 --- a/app/views/admin/price_line_p_articles/_form.html.haml +++ b/app/views/admin/price_line_p_articles/_form.html.haml @@ -1,4 +1,4 @@ -= form.input :p_article_id, as: :select, collection: PArticle.joins(:p_product_ref).where(p_product_ref: price_line.p_product_ref).map{|p_article| [p_article.serialized_name, p_article.id]}, label: "Article(s) associé(s)", input_html: {class:"p_article_select"} += form.input :p_article_id, as: :select, collection: PArticle.joins(:p_product_ref).where(p_product_ref: @price_line.p_product_ref).map{|p_article| [p_article.serialized_name, p_article.id]}, label: "Article(s) associé(s)", input_html: {class:"p_article_select"} :javascript $('.p_article_select').select2({ diff --git a/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml b/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml index 8071164..d410809 100644 --- a/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml +++ b/app/views/admin/price_lines/_add_price_line_p_article_form.html.haml @@ -3,6 +3,6 @@ =f.inputs do .price_line_p_articles_form.col-3 = f.semantic_fields_for :price_line_p_articles do |form| - =render :partial => "admin/price_line_p_articles/form", :locals => {:form => form, price_line: @price_line} + = render "admin/price_line_p_articles/form", form: form, price_line: @price_line %p= link_to_add_fields "Ajouter un article", f, :price_line_p_articles, {:class => "btn btn-primary"} if @price_line.p_articles.count < @price_line.qte =render :partial => "qi/actions", :locals => {:f => f} diff --git a/app/views/admin/price_lines/_form.html.haml b/app/views/admin/price_lines/_form.html.haml index ffc3c7a..e1c9540 100644 --- a/app/views/admin/price_lines/_form.html.haml +++ b/app/views/admin/price_lines/_form.html.haml @@ -1,7 +1,4 @@ .row.qi_pannel.qi_plain.padding.price_line_form.col-12.field{:style =>"border-left:4px solid gray;margin-bottom:10px;padding-left:5px;"} - - - .take.mr-1{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )} =ic :arrows .col-3 @@ -42,51 +39,3 @@ %span.destroy{style: "font-size: 2rem;"}=link_to_remove_fields ic(:"trash-o"), form = 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 --# } --# }); --# }); \ No newline at end of file