addin good select2 instead of autocomplete. adding bon de commande client to p custommer sheet
This commit is contained in:
parent
877824fba4
commit
e2ed7e5f22
Binary file not shown.
8
Gemfile
8
Gemfile
@ -54,9 +54,9 @@ group :development do
|
|||||||
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
|
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
|
||||||
gem 'web-console', '>= 3.3.0'
|
gem 'web-console', '>= 3.3.0'
|
||||||
gem 'listen', '>= 3.0.5', '< 3.2'
|
gem 'listen', '>= 3.0.5', '< 3.2'
|
||||||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
# # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
||||||
gem 'spring'
|
# gem 'spring'
|
||||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
# gem 'spring-watcher-listen', '~> 2.0.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
@ -118,3 +118,5 @@ gem 'axlsx_rails'
|
|||||||
|
|
||||||
gem 'mimemagic', "0.3.10"
|
gem 'mimemagic', "0.3.10"
|
||||||
gem "roo"
|
gem "roo"
|
||||||
|
gem "select2-rails"
|
||||||
|
|
||||||
|
@ -301,6 +301,7 @@ GEM
|
|||||||
activemodel (>= 5)
|
activemodel (>= 5)
|
||||||
elasticsearch (>= 6)
|
elasticsearch (>= 6)
|
||||||
hashie
|
hashie
|
||||||
|
select2-rails (4.0.13)
|
||||||
selenium-webdriver (3.142.3)
|
selenium-webdriver (3.142.3)
|
||||||
childprocess (>= 0.5, < 2.0)
|
childprocess (>= 0.5, < 2.0)
|
||||||
rubyzip (~> 1.2, >= 1.2.2)
|
rubyzip (~> 1.2, >= 1.2.2)
|
||||||
@ -308,10 +309,6 @@ GEM
|
|||||||
sixarm_ruby_unaccent (1.2.0)
|
sixarm_ruby_unaccent (1.2.0)
|
||||||
sort_alphabetical (1.1.0)
|
sort_alphabetical (1.1.0)
|
||||||
unicode_utils (>= 1.2.2)
|
unicode_utils (>= 1.2.2)
|
||||||
spring (2.1.0)
|
|
||||||
spring-watcher-listen (2.0.1)
|
|
||||||
listen (>= 2.7, < 4.0)
|
|
||||||
spring (>= 1.2, < 3.0)
|
|
||||||
sprockets (3.7.2)
|
sprockets (3.7.2)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
rack (> 1, < 3)
|
rack (> 1, < 3)
|
||||||
@ -406,9 +403,8 @@ DEPENDENCIES
|
|||||||
roo
|
roo
|
||||||
sass-rails (~> 5)
|
sass-rails (~> 5)
|
||||||
searchkick
|
searchkick
|
||||||
|
select2-rails
|
||||||
selenium-webdriver
|
selenium-webdriver
|
||||||
spring
|
|
||||||
spring-watcher-listen (~> 2.0.0)
|
|
||||||
sprockets
|
sprockets
|
||||||
tiny_tds (= 1.3.0)
|
tiny_tds (= 1.3.0)
|
||||||
truncate_html
|
truncate_html
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#= require vendor/jquery.fileupload
|
#= require vendor/jquery.fileupload
|
||||||
#= require vendor/jquery.fileupload-ui
|
#= require vendor/jquery.fileupload-ui
|
||||||
#= require vendor/jquery.fileupload-process
|
#= require vendor/jquery.fileupload-process
|
||||||
#= require vendor/select2.min
|
#= require select2
|
||||||
#= require vendor/accounting
|
#= require vendor/accounting
|
||||||
#= require vendor/jquery.mask
|
#= require vendor/jquery.mask
|
||||||
#= require vendor/datatables.min
|
#= require vendor/datatables.min
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
/*
|
||||||
|
*= require select2
|
||||||
|
*/
|
||||||
// Variables
|
// Variables
|
||||||
@import "1-variables/app";
|
@import "1-variables/app";
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
|
|
||||||
|
|
||||||
if true
|
if true
|
||||||
@price_documents = @price_documents.where(:price_document_type_id => params[:price_document_type_ids]) if params[:price_document_type_ids].size > 0
|
@price_documents = @price_documents.where(:price_document_type_id => params[:price_document_type_ids]).order(:id) if params[:price_document_type_ids].size > 0
|
||||||
|
|
||||||
|
|
||||||
if current_admin.p_commercial
|
if current_admin.p_commercial
|
||||||
@ -234,7 +234,6 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
redirect_to admin_p_fournisseurs_path(:create_document => "Commande achat" )
|
redirect_to admin_p_fournisseurs_path(:create_document => "Commande achat" )
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@price_document = PriceDocument.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id])
|
@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 => params[:document_type]).first
|
@price_document.price_document_type = PriceDocumentType.where(:label => params[:document_type]).first
|
||||||
@price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id])
|
@price_document.price_line_block = PriceLineBlock.new(:p_customer_id => params[:p_customer_id], :p_fournisseur_id => params[:p_fournisseur_id])
|
||||||
@ -332,7 +331,7 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
if @price_document.save
|
if @price_document.save
|
||||||
#if @price_document.cc_label == "Demande prix"
|
#if @price_document.cc_label == "Demande prix"
|
||||||
if @price_document.cc_label == "Facture achat"
|
if @price_document.cc_label == "Facture achat"
|
||||||
render action: :show
|
redirect_to admin_price_document_path(@price_document)
|
||||||
else
|
else
|
||||||
redirect_to admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id)
|
redirect_to admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id)
|
||||||
end
|
end
|
||||||
|
@ -268,9 +268,11 @@ class PCustomerSheet < ApplicationRecord
|
|||||||
self.archive_now if !self.archived
|
self.archive_now if !self.archived
|
||||||
self.block_price if !self.price_blocked
|
self.block_price if !self.price_blocked
|
||||||
price_document = self.price_documents.new(:price_document_type => PriceDocumentType.find_by_label(label), :date => Date.today)
|
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.p_customer = self.p_customer
|
||||||
|
|
||||||
price_document.price_line_block = self.price_line_block.dup
|
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
|
price_document.price_line_block.ac_block_type = nil
|
||||||
|
|
||||||
@ -306,7 +308,7 @@ class PCustomerSheet < ApplicationRecord
|
|||||||
|
|
||||||
def generate_bc
|
def generate_bc
|
||||||
|
|
||||||
generate_doc("Bon de commande", "commande")
|
generate_doc("Bon de commande client", "commande")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
belongs_to :p_fournisseur
|
belongs_to :p_fournisseur
|
||||||
accepts_nested_attributes_for :p_fournisseur
|
accepts_nested_attributes_for :p_fournisseur
|
||||||
|
|
||||||
|
belongs_to :price_document
|
||||||
|
|
||||||
def to_no_archive
|
def to_no_archive
|
||||||
if self.imported
|
if self.imported
|
||||||
%w()
|
%w()
|
||||||
@ -829,8 +831,4 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
AVOIR_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)
|
AVOIR_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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
-if params[:price_document_type_id]
|
-if params[:price_document_type_id]
|
||||||
=breadcrumb second_title: PriceDocumentType.find(params[:price_document_type_id]).label
|
=breadcrumb second_title: PriceDocumentType.find(params[:price_document_type_id]).label
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.qi_search_row
|
.qi_search_row
|
||||||
=form_tag "", :method => "get", :onsubmit => "" do
|
=form_tag "", :method => "get", :onsubmit => "" do
|
||||||
|
|
||||||
@ -137,7 +135,7 @@
|
|||||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @price_documents}
|
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @price_documents}
|
||||||
|
|
||||||
-if true #if params[:price_document_type_id].to_i != 0
|
-if true #if params[:price_document_type_id].to_i != 0
|
||||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => params[:price_document_type_id].to_s}
|
= render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @price_documents, :key => params[:price_document_type_id].to_s}
|
||||||
|
|
||||||
|
|
||||||
:scss
|
:scss
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
=f.semantic_fields_for :price_lines do |f|
|
=f.semantic_fields_for :price_lines do |f|
|
||||||
=render :partial => "admin/price_lines/form_bon_de_reception_achat", :locals => {:form => f}
|
=render :partial => "admin/price_lines/form_bon_de_reception_achat", :locals => {:form => f}
|
||||||
|
|
||||||
%p= link_to_add_fields "Ajouter une ligneeeeeee", f, :price_lines, {:class => "btn btn-primary add_lines"}
|
%p= link_to_add_fields "Ajouter une ligne", f, :price_lines, {:class => "btn btn-primary add_lines"}
|
||||||
|
|
||||||
|
|
||||||
-if current_admin.has_permission?("payments")
|
-if current_admin.has_permission?("payments")
|
||||||
@ -106,7 +106,8 @@
|
|||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
$('.add_lines').click(function() {
|
$('.add_lines').click(function() {
|
||||||
console.log('LENGTH ' + $('.p_product_ref_select').length)
|
$('.p_product_ref_select').last().select2({
|
||||||
$('.p_product_ref_select').last().select2();
|
//theme: "bootstrap"
|
||||||
$('.p_product_ref_select').last().removeClass('form-control');
|
});
|
||||||
|
//$('.p_product_ref_select').last().removeClass('form-control');
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
=form.input :p_article_id, as: :select, collection: PArticle.all.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
|
:javascript
|
||||||
$('.p_article_select').select2();
|
$('.p_article_select').select2({
|
||||||
$('.p_article_select').removeClass('form-control');
|
//theme: "bootstrap"
|
||||||
|
});
|
||||||
|
//$('.p_article_select').removeClass('form-control');
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
.mx-2.my-2
|
.mx-2.my-2
|
||||||
=semantic_form_for [:admin, @price_line], :remote => true do |f|
|
=semantic_form_for [:admin, @price_line], :remote => true do |f|
|
||||||
=f.inputs do
|
=f.inputs do
|
||||||
.price_line_p_articles_form
|
.price_line_p_articles_form.col-3
|
||||||
= f.semantic_fields_for :price_line_p_articles do |form|
|
= f.semantic_fields_for :price_line_p_articles do |form|
|
||||||
=render :partial => "admin/price_line_p_articles/form", :locals => {:form => form}
|
=render :partial => "admin/price_line_p_articles/form", :locals => {: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
|
%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}
|
=render :partial => "qi/actions", :locals => {:f => f}
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
.take.mr-1{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
|
.take.mr-1{:style => "padding-left:10px;", :class => ("error has-error" if form.object.errors[:p_product_ref_id].size > 0 )}
|
||||||
=ic :arrows
|
=ic :arrows
|
||||||
.col-3{:style => "white-space: nowrap;"}
|
.col-3
|
||||||
=form.input :p_product_ref, as: :select, collection: PProductRef.all.map{ |p_product_ref| [p_product_ref.member_label, p_product_ref.id] }, label: "Référence", input_html: {class:"p_product_ref_select"}
|
= form.input :p_product_ref, as: :select, collection: PProductRef.all.map{ |p_product_ref| [p_product_ref.member_label, p_product_ref.id] }, label: "Référence :", input_html: {class:"p_product_ref_select"}
|
||||||
.input-group
|
.input-group
|
||||||
-# %label Référence
|
-# %label Référence
|
||||||
-# %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.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"}
|
||||||
@ -32,7 +32,7 @@
|
|||||||
-# = form.input :forced_price, :label => "Prix personnalisé ?", :as => :boolean, :input_html => {:class => "form-inline input_price_line_forced_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"}
|
-# .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"}
|
||||||
.col-3
|
.col-3
|
||||||
= form.input :qte, :label => "Quantité", :input_html => {:class => "input_price_line_qte form-control p_product_ref_qte", tabindex: 1}
|
= form.input :qte, :label => "Quantité :", :input_html => {:class => "input_price_line_qte form-control p_product_ref_qte", tabindex: 1}
|
||||||
.col-3
|
.col-3
|
||||||
= form.input :ct_u_price_ht, :label => "Prix Unitaire HT :", :input_html => { class: "mx-2"}
|
= form.input :ct_u_price_ht, :label => "Prix Unitaire HT :", :input_html => { class: "mx-2"}
|
||||||
|
|
||||||
@ -43,59 +43,50 @@
|
|||||||
= qi_js_field(form, :price_line, :tva_account_value, :hidden => true)
|
= 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"
|
||||||
|
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
$('.p_product_ref_autocomplete_input').focus()
|
-# $('.p_product_ref_autocomplete_input').focus()
|
||||||
$( function() {
|
-# $( function() {
|
||||||
$('.p_product_ref_autocomplete_input').autocomplete({
|
-# $('.p_product_ref_autocomplete_input').autocomplete({
|
||||||
source: function( request, response ) {
|
-# source: function( request, response ) {
|
||||||
$.ajax( {
|
-# $.ajax( {
|
||||||
url: "/admin/p_product_refs/autocomplete.json",
|
-# url: "/admin/p_product_refs/autocomplete.json",
|
||||||
dataType: "json",
|
-# dataType: "json",
|
||||||
data: {
|
-# data: {
|
||||||
search: request.term,
|
-# search: request.term,
|
||||||
p_customer_id: $(".p_customer_id").val()
|
-# p_customer_id: $(".p_customer_id").val()
|
||||||
},
|
-# },
|
||||||
success: function(data){
|
-# success: function(data){
|
||||||
arr = jQuery.map( data, function( item ) {
|
-# arr = jQuery.map( data, function( item ) {
|
||||||
return {
|
-# return {
|
||||||
label: item.member_label,
|
-# label: item.member_label,
|
||||||
value: item.member_label,
|
-# value: item.member_label,
|
||||||
id: item.id
|
-# id: item.id
|
||||||
}
|
-# }
|
||||||
});
|
-# });
|
||||||
response(arr)
|
-# response(arr)
|
||||||
}
|
-# }
|
||||||
});
|
-# });
|
||||||
},
|
-# },
|
||||||
minLength: 2,
|
-# minLength: 2,
|
||||||
select: function( event, ui ) {
|
-# select: function( event, ui ) {
|
||||||
$(this).next(".p_product_ref_id").val(ui.item.id)
|
-# $(this).next(".p_product_ref_id").val(ui.item.id)
|
||||||
form = $(this).closest(".price_line_form")
|
-# form = $(this).closest(".price_line_form")
|
||||||
$.ajax( {
|
-# $.ajax( {
|
||||||
url: "/admin/p_product_refs/"+ui.item.id+"/get_infos.json",
|
-# url: "/admin/p_product_refs/"+ui.item.id+"/get_infos.json",
|
||||||
dataType: "json",
|
-# dataType: "json",
|
||||||
data: {
|
-# data: {
|
||||||
type: "price",
|
-# type: "price",
|
||||||
qte: form.find(".input_price_line_qte").val(),
|
-# qte: form.find(".input_price_line_qte").val(),
|
||||||
p_customer_id: $(".p_customer_id").val()
|
-# p_customer_id: $(".p_customer_id").val()
|
||||||
},
|
-# },
|
||||||
success: function (data) {
|
-# success: function (data) {
|
||||||
form.find(".input_price_line_price_u_ht").val(data.price);
|
-# form.find(".input_price_line_price_u_ht").val(data.price);
|
||||||
form.find(".input_price_line_tva_account_id").val(data.tva_account_id);
|
-# form.find(".input_price_line_tva_account_id").val(data.tva_account_id);
|
||||||
form.find(".input_price_line_tva_account_value").val(data.tva_account_value);
|
-# form.find(".input_price_line_tva_account_value").val(data.tva_account_value);
|
||||||
form.find(".input_price_line_weight_u").val(data.weight);
|
-# form.find(".input_price_line_weight_u").val(data.weight);
|
||||||
}
|
-# }
|
||||||
});
|
-# });
|
||||||
//return false
|
-# //return false
|
||||||
}
|
-# }
|
||||||
});
|
-# });
|
||||||
});
|
-# });
|
||||||
|
|
||||||
|
|
||||||
:scss
|
|
||||||
.price_line_form{
|
|
||||||
.form-group{
|
|
||||||
margin-bottom:0;}
|
|
||||||
|
|
||||||
}
|
|
@ -6,5 +6,8 @@ class AddColumnsToPriceDocsAdnPriceLineBlocks < ActiveRecord::Migration[6.0]
|
|||||||
add_column :price_documents, :supplier_document_date, :date
|
add_column :price_documents, :supplier_document_date, :date
|
||||||
add_column :price_line_blocks, :stock_entrance_date, :date
|
add_column :price_line_blocks, :stock_entrance_date, :date
|
||||||
add_column :price_line_blocks, :ct_tot_amount_ht, :decimal, :precision => 14, :scale => 2
|
add_column :price_line_blocks, :ct_tot_amount_ht, :decimal, :precision => 14, :scale => 2
|
||||||
|
change_table :price_line_blocks do |t|
|
||||||
|
t.belongs_to :price_document
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2471,7 +2471,9 @@ ActiveRecord::Schema.define(version: 2021_11_03_085623) do
|
|||||||
t.string "cc_state"
|
t.string "cc_state"
|
||||||
t.date "stock_entrance_date"
|
t.date "stock_entrance_date"
|
||||||
t.decimal "ct_tot_amount_ht", precision: 14, scale: 2
|
t.decimal "ct_tot_amount_ht", precision: 14, scale: 2
|
||||||
|
t.bigint "price_document_id"
|
||||||
t.index ["p_customer_id"], name: "index_price_line_blocks_on_p_customer_id"
|
t.index ["p_customer_id"], name: "index_price_line_blocks_on_p_customer_id"
|
||||||
|
t.index ["price_document_id"], name: "index_price_line_blocks_on_price_document_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "price_line_p_articles", force: :cascade do |t|
|
create_table "price_line_p_articles", force: :cascade do |t|
|
||||||
|
Reference in New Issue
Block a user