Merge branch 'pre-prod'
This commit is contained in:
commit
2e0a38e67c
6
Gemfile
6
Gemfile
@ -9,6 +9,8 @@ gem 'rails', '6.0.3.4'
|
|||||||
gem 'mysql2'
|
gem 'mysql2'
|
||||||
# Use Puma as the app server
|
# Use Puma as the app server
|
||||||
|
|
||||||
|
gem "postgresql"
|
||||||
|
|
||||||
# Use SCSS for stylesheets
|
# Use SCSS for stylesheets
|
||||||
gem 'sass-rails', '~> 5'
|
gem 'sass-rails', '~> 5'
|
||||||
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
|
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
|
||||||
@ -96,6 +98,7 @@ gem "country_select"
|
|||||||
gem 'haml-rails'
|
gem 'haml-rails'
|
||||||
gem 'rails_autolink'
|
gem 'rails_autolink'
|
||||||
|
|
||||||
|
gem 'pg_search'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem "capistrano", "~> 3.10", require: false
|
gem "capistrano", "~> 3.10", require: false
|
||||||
@ -103,7 +106,7 @@ group :development do
|
|||||||
gem 'capistrano-bundler', '~> 1.1', require: false
|
gem 'capistrano-bundler', '~> 1.1', require: false
|
||||||
gem "capistrano-rvm", group: :development
|
gem "capistrano-rvm", group: :development
|
||||||
gem 'capistrano3-nginx', '~> 2.0', group: :development
|
gem 'capistrano3-nginx', '~> 2.0', group: :development
|
||||||
|
gem "awesome_print"
|
||||||
end
|
end
|
||||||
|
|
||||||
gem 'zip-zip'
|
gem 'zip-zip'
|
||||||
@ -114,3 +117,4 @@ gem 'axlsx', '3.0.0.pre'
|
|||||||
gem 'axlsx_rails'
|
gem 'axlsx_rails'
|
||||||
|
|
||||||
gem 'mimemagic', "0.3.10"
|
gem 'mimemagic', "0.3.10"
|
||||||
|
gem "roo"
|
||||||
|
14
Gemfile.lock
14
Gemfile.lock
@ -63,6 +63,7 @@ GEM
|
|||||||
public_suffix (>= 2.0.2, < 5.0)
|
public_suffix (>= 2.0.2, < 5.0)
|
||||||
airbrussh (1.3.3)
|
airbrussh (1.3.3)
|
||||||
sshkit (>= 1.6.1, != 1.7.0)
|
sshkit (>= 1.6.1, != 1.7.0)
|
||||||
|
awesome_print (1.9.2)
|
||||||
axlsx (3.0.0.pre)
|
axlsx (3.0.0.pre)
|
||||||
htmlentities (~> 4.3, >= 4.3.4)
|
htmlentities (~> 4.3, >= 4.3.4)
|
||||||
mimemagic (~> 0.3)
|
mimemagic (~> 0.3)
|
||||||
@ -229,7 +230,13 @@ GEM
|
|||||||
nio4r (2.5.4)
|
nio4r (2.5.4)
|
||||||
nokogiri (1.10.10)
|
nokogiri (1.10.10)
|
||||||
mini_portile2 (~> 2.4.0)
|
mini_portile2 (~> 2.4.0)
|
||||||
|
pg (1.2.3)
|
||||||
|
pg_search (2.3.5)
|
||||||
|
activerecord (>= 5.2)
|
||||||
|
activesupport (>= 5.2)
|
||||||
posix-spawn (0.3.13)
|
posix-spawn (0.3.13)
|
||||||
|
postgresql (1.0.0)
|
||||||
|
pg
|
||||||
public_suffix (4.0.1)
|
public_suffix (4.0.1)
|
||||||
puma (3.12.1)
|
puma (3.12.1)
|
||||||
rack (2.2.3)
|
rack (2.2.3)
|
||||||
@ -270,6 +277,9 @@ GEM
|
|||||||
ffi (~> 1.0)
|
ffi (~> 1.0)
|
||||||
regexp_parser (1.6.0)
|
regexp_parser (1.6.0)
|
||||||
rmagick (4.2.2)
|
rmagick (4.2.2)
|
||||||
|
roo (2.8.2)
|
||||||
|
nokogiri (~> 1)
|
||||||
|
rubyzip (>= 1.2.1, < 2.0.0)
|
||||||
ruby-vips (2.0.14)
|
ruby-vips (2.0.14)
|
||||||
ffi (~> 1.9)
|
ffi (~> 1.9)
|
||||||
ruby_dep (1.5.0)
|
ruby_dep (1.5.0)
|
||||||
@ -357,6 +367,7 @@ PLATFORMS
|
|||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
acts_as_commentable
|
acts_as_commentable
|
||||||
acts_as_tree
|
acts_as_tree
|
||||||
|
awesome_print
|
||||||
axlsx (= 3.0.0.pre)
|
axlsx (= 3.0.0.pre)
|
||||||
axlsx_rails
|
axlsx_rails
|
||||||
bcrypt (~> 3.1.7)
|
bcrypt (~> 3.1.7)
|
||||||
@ -385,11 +396,14 @@ DEPENDENCIES
|
|||||||
mimemagic (= 0.3.10)
|
mimemagic (= 0.3.10)
|
||||||
mysql2
|
mysql2
|
||||||
nokogiri
|
nokogiri
|
||||||
|
pg_search
|
||||||
posix-spawn
|
posix-spawn
|
||||||
|
postgresql
|
||||||
puma (~> 3.11)
|
puma (~> 3.11)
|
||||||
rails (= 6.0.3.4)
|
rails (= 6.0.3.4)
|
||||||
rails_autolink
|
rails_autolink
|
||||||
rmagick
|
rmagick
|
||||||
|
roo
|
||||||
sass-rails (~> 5)
|
sass-rails (~> 5)
|
||||||
searchkick
|
searchkick
|
||||||
selenium-webdriver
|
selenium-webdriver
|
||||||
|
@ -12,7 +12,7 @@ class Admin::BuyListsController < ApplicationController
|
|||||||
|
|
||||||
@price_line_blocks = PriceLineBlock.where(:price_lineable_type => "PCustomerSheet", :price_lineable_id => @p_customer_sheets.ids)
|
@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)
|
@price_lines = PriceLine.where(:price_line_block_id => @price_line_blocks.ids).unscoped
|
||||||
|
|
||||||
if params[:search][:s_brand].present? && params[:search][:s_brand] != ""
|
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])
|
@price_lines = @price_lines.joins(p_product_ref: :p_product).where("s_brand_id = ?", params[:search][:s_brand])
|
||||||
@ -149,12 +149,13 @@ class Admin::BuyListsController < ApplicationController
|
|||||||
@p_customer_sheet = PCustomerSheet.find(params[:id])
|
@p_customer_sheet = PCustomerSheet.find(params[:id])
|
||||||
@p_customer = @p_customer_sheet.p_customer
|
@p_customer = @p_customer_sheet.p_customer
|
||||||
|
|
||||||
|
@price_line_id = params[:price_line_id]
|
||||||
|
|
||||||
if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!)
|
if @p_customer_sheet.update(state: params[:state])
|
||||||
|
|
||||||
@p_customer_sheets = PCustomerSheet.order(:id).all
|
@p_customer_sheets = PCustomerSheet.where(:state => ["AV BPA", "PAS BPA", "BPA"])
|
||||||
|
return @p_customer_sheet
|
||||||
redirect_to admin_p_customer_sheet_path(@p_customer_sheet)
|
# redirect_to admin_p_customer_sheet_path(@p_customer_sheet)
|
||||||
else
|
else
|
||||||
render action: "edit"
|
render action: "edit"
|
||||||
|
|
||||||
@ -235,6 +236,4 @@ class Admin::BuyListsController < ApplicationController
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,7 @@ class Admin::EditWatchersController < ApplicationController
|
|||||||
|
|
||||||
@edit_wacthers_to_destroy = EditWatcher.where("created_at < ?", (Time.now - 2)).destroy_all
|
@edit_wacthers_to_destroy = EditWatcher.where("created_at < ?", (Time.now - 2)).destroy_all
|
||||||
|
|
||||||
@edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).group(:admin_id).all
|
@edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).select(:admin_id).group(:admin_id).all
|
||||||
|
|
||||||
else
|
else
|
||||||
render :action => :new
|
render :action => :new
|
||||||
|
@ -31,13 +31,20 @@ class Admin::ImportCsvsController < ApplicationController
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def match_refs
|
||||||
|
@price_documents = PriceDocument.joins(price_line_block: :price_lines).where({price_line_block: {price_lines: {p_product_ref: nil}}}).distinct
|
||||||
|
redirect_to :action => :index if @price_documents.empty?
|
||||||
|
end
|
||||||
|
|
||||||
def charge
|
def charge
|
||||||
@import_csv = ImportCsv.find(params[:id])
|
@import_csv = ImportCsv.find(params[:id])
|
||||||
@import_csv.load
|
@import_csv.load
|
||||||
|
|
||||||
redirect_to :action => :index
|
# redirect_to :action => :index
|
||||||
|
redirect_to match_refs_admin_import_csvs_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@import_csv = ImportCsv.new(:parent_id => params[:parent_id])
|
@import_csv = ImportCsv.new(:parent_id => params[:parent_id])
|
||||||
if @import_csv.parent
|
if @import_csv.parent
|
||||||
@ -85,4 +92,13 @@ class Admin::ImportCsvsController < ApplicationController
|
|||||||
@import_csv.destroy
|
@import_csv.destroy
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def temp_p_product
|
||||||
|
if params[:price_line_id]
|
||||||
|
@price_line = PriceLine.find(params[:price_line_id])
|
||||||
|
p_product = PProduct.find_or_create_by(name: "--> Selectioner un produit <--", code: "--> Indiquer un code produit <--")
|
||||||
|
@p_product_ref = PProductRef.find_or_create_by(p_product: p_product, description: @price_line.title, ct_price_ht: @price_line.ct_u_price_ht)
|
||||||
|
@p_product_ref.p_product_ref_specs.build
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,6 +12,11 @@ class Admin::PArticlesController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@p_articles = PArticle.all
|
@p_articles = PArticle.all
|
||||||
|
global_search_ids = @p_articles.ids
|
||||||
|
|
||||||
|
if params[:search][:global].to_s != ""
|
||||||
|
global_search_ids = PArticle.global_search(params[:search][:global]).ids
|
||||||
|
end
|
||||||
|
|
||||||
if params[:search][:p_product_color].to_s != ""
|
if params[:search][:p_product_color].to_s != ""
|
||||||
if params[:search][:p_product_color].to_s == "null"
|
if params[:search][:p_product_color].to_s == "null"
|
||||||
@ -38,6 +43,11 @@ class Admin::PArticlesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final_ids = global_search_ids
|
||||||
|
|
||||||
|
@p_articles = PArticle.where(id: final_ids)
|
||||||
|
|
||||||
@p_articles = sort_by_sorting(@p_articles, "id DESC")
|
@p_articles = sort_by_sorting(@p_articles, "id DESC")
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html{
|
format.html{
|
||||||
|
@ -193,13 +193,13 @@ class Admin::PCustomerSheetsController < ApplicationController
|
|||||||
@p_customer_sheet = PCustomerSheet.find(params[:id])
|
@p_customer_sheet = PCustomerSheet.find(params[:id])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!)
|
if @p_customer_sheet.update_attributes(params.require(:p_customer_sheet).permit!)
|
||||||
|
|
||||||
@p_customer = @p_customer_sheet.price_line_block.p_customer
|
@p_customer = @p_customer_sheet.price_line_block.p_customer
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{redirect_to admin_p_customer_sheet_path(@p_customer_sheet)}
|
||||||
redirect_to admin_p_customer_sheet_path(@p_customer_sheet)
|
format.js{}
|
||||||
|
end
|
||||||
else
|
else
|
||||||
render action: "edit"
|
render action: "edit"
|
||||||
|
|
||||||
@ -207,7 +207,6 @@ class Admin::PCustomerSheetsController < ApplicationController
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@p_customer_sheet = PCustomerSheet.find(params[:id])
|
@p_customer_sheet = PCustomerSheet.find(params[:id])
|
||||||
@p_customer_sheet.destroy
|
@p_customer_sheet.destroy
|
||||||
|
76
app/controllers/admin/p_fournisseur_refs_controller.rb
Normal file
76
app/controllers/admin/p_fournisseur_refs_controller.rb
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
|
||||||
|
class Admin::PFournisseurRefsController < ApplicationController
|
||||||
|
layout "admin"
|
||||||
|
before_action :auth_admin
|
||||||
|
|
||||||
|
before_action :admin_space
|
||||||
|
|
||||||
|
def admin_space
|
||||||
|
@admin_space = "default"
|
||||||
|
end
|
||||||
|
|
||||||
|
def index
|
||||||
|
@p_fournisseur_refs = PFournisseurRef.all
|
||||||
|
|
||||||
|
@p_fournisseur_refs = sort_by_sorting(@p_fournisseur_refs, "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_fournisseur_refs = @p_fournisseur_refs.page(page).per(per_page)
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@p_fournisseur_ref = PFournisseurRef.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@p_fournisseur_ref = PFournisseurRef.new
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@p_fournisseur_ref = PFournisseurRef.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@p_fournisseur_ref = PFournisseurRef.new(params.require(:p_fournisseur_ref).permit!)
|
||||||
|
|
||||||
|
if @p_fournisseur_ref.save
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "new"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def update
|
||||||
|
@p_fournisseur_ref = PFournisseurRef.find(params[:id])
|
||||||
|
|
||||||
|
|
||||||
|
if @p_fournisseur_ref.update_attributes(params.require(:p_fournisseur_ref).permit!)
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "edit"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@p_fournisseur_ref = PFournisseurRef.find(params[:id])
|
||||||
|
@p_fournisseur_ref.destroy
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -23,7 +23,6 @@ class Admin::PFournisseursController < ApplicationController
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@p_fournisseurs = PFournisseur.order(:name).all
|
@p_fournisseurs = PFournisseur.order(:name).all
|
||||||
|
|
||||||
|
@ -108,12 +108,13 @@ class Admin::PPaymentsController < ApplicationController
|
|||||||
@p_payments = @p_payments.where("affected = ?", params[:affected].to_i)
|
@p_payments = @p_payments.where("affected = ?", params[:affected].to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:remise].to_s != ""
|
# PROBLEME AVEC POSTGRES. Attend un booléen mais le where envoi 1/0
|
||||||
@p_payments = @p_payments.where("remise = ?", params[:remise].to_i)
|
# if params[:remise].to_s != ""
|
||||||
if params[:remise].to_s == "0"
|
# @p_payments = @p_payments.where("remise = ?", params[:remise].to_i)
|
||||||
@p_payments = @p_payments.where(:imported => false)
|
# if params[:remise].to_s == "0"
|
||||||
end
|
# @p_payments = @p_payments.where(:imported => false)
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
if params[:p_customer_id].to_s != ""
|
if params[:p_customer_id].to_s != ""
|
||||||
@p_payments = @p_payments.where(:p_customer_id => params[:p_customer_id])
|
@p_payments = @p_payments.where(:p_customer_id => params[:p_customer_id])
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
|
|
||||||
class Admin::PProductRefsController < ApplicationController
|
class Admin::PProductRefsController < ApplicationController
|
||||||
|
include ActionView::RecordIdentifier # adds `dom_id`
|
||||||
|
|
||||||
layout "admin"
|
layout "admin"
|
||||||
before_action :auth_admin
|
before_action :auth_admin
|
||||||
|
|
||||||
@ -16,9 +18,13 @@ class Admin::PProductRefsController < ApplicationController
|
|||||||
|
|
||||||
@p_product_refs = PProductRef.joins(:p_product)
|
@p_product_refs = PProductRef.joins(:p_product)
|
||||||
|
|
||||||
@purchase_p_product_cats = PProductCat.where(:purchase => true).order(:name).all
|
# @purchase_p_product_cats = PProductCat.where(:purchase => true).order(:name).all
|
||||||
|
|
||||||
|
global_search_ids = p_product_ref_cat_id_ids = s_brand_id_ids = @p_product_refs.ids
|
||||||
|
|
||||||
|
if params[:search][:global].to_s != ""
|
||||||
|
global_search_ids = PProductRef.global_search(params[:search][:global]).ids
|
||||||
|
end
|
||||||
|
|
||||||
if params[:search][:code].to_s != ""
|
if params[:search][:code].to_s != ""
|
||||||
@p_product_refs = @p_product_refs.where("p_product_refs.ref LIKE ?","#{params[:search][:code]}%")
|
@p_product_refs = @p_product_refs.where("p_product_refs.ref LIKE ?","#{params[:search][:code]}%")
|
||||||
@ -28,23 +34,30 @@ class Admin::PProductRefsController < ApplicationController
|
|||||||
@p_product_refs = @p_product_refs.joins(:fournisseur_product_refs).where("fournisseur_product_refs.ref LIKE ?","%#{params[:search][:fournisseur_ref]}%")
|
@p_product_refs = @p_product_refs.joins(:fournisseur_product_refs).where("fournisseur_product_refs.ref LIKE ?","%#{params[:search][:fournisseur_ref]}%")
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:search][:name].to_s != ""
|
|
||||||
@p_product_refs = @p_product_refs.where("p_product_refs.ct_sub_name LIKE ? or p_product_refs.cc_name LIKE ?","%#{params[:search][:name]}%", "%#{params[:search][:name]}%")
|
|
||||||
end
|
|
||||||
|
|
||||||
if params[:search][:p_product_ref_cat_id].to_s != ""
|
if params[:search][:p_product_ref_cat_id].to_s != ""
|
||||||
if params[:search][:p_product_ref_cat_id].to_s == "null"
|
if params[:search][:p_product_ref_cat_id].to_s == "null"
|
||||||
@p_product_refs = @p_product_refs.where(:cc_p_product_cat_id => nil)
|
# @p_product_refs = @p_product_refs.where(:cc_p_product_cat_id => nil)
|
||||||
|
p_product_ref_cat_id_ids = @p_product_refs.where(:cc_p_product_cat_id => nil).ids
|
||||||
else
|
else
|
||||||
@p_product_refs = @p_product_refs.where(:cc_p_product_cat_id => params[:search][:p_product_ref_cat_id])
|
# @p_product_refs = @p_product_refs.where(:cc_p_product_cat_id => params[:search][:p_product_ref_cat_id])
|
||||||
|
p_product_ref_cat_id_ids = @p_product_refs.where(:cc_p_product_cat_id => params[:search][:p_product_ref_cat_id]).ids
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if params[:search][:s_brand_id].to_s != ""
|
if params[:search][:s_brand_id].to_s != ""
|
||||||
@p_product_refs = @p_product_refs.where(:p_products => {: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]})
|
||||||
|
# @p_product_refs = @p_product_refs.select { |ref| ref.p_product.s_brand_id == params[:search][:s_brand_id]}
|
||||||
|
s_brand_id_ids = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}).ids
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
final_ids = global_search_ids & p_product_ref_cat_id_ids & s_brand_id_ids
|
||||||
|
|
||||||
|
@p_product_refs = PProductRef.where(id: final_ids)
|
||||||
|
|
||||||
|
|
||||||
@p_product_refs = sort_by_sorting(@p_product_refs, "id DESC")
|
@p_product_refs = sort_by_sorting(@p_product_refs, "id DESC")
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js{
|
format.js{
|
||||||
@ -102,12 +115,14 @@ class Admin::PProductRefsController < ApplicationController
|
|||||||
|
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
||||||
@p_product_ref = PProductRef.find(params[:id])
|
@p_product_ref = PProductRef.find(params[:id])
|
||||||
|
|
||||||
|
|
||||||
if @p_product_ref.update_attributes(params.require(:p_product_ref).permit!)
|
if @p_product_ref.update_attributes(params.require(:p_product_ref).permit!)
|
||||||
|
if params[:update_price_line_id]
|
||||||
|
@price_line = PriceLine.find(params[:update_price_line_id])
|
||||||
|
@price_line.update(p_product_ref: @p_product_ref)
|
||||||
|
end
|
||||||
|
# redirect_to admin_p_products_path(@p_product_ref.p_product, anchor: dom_id(@p_product_ref))
|
||||||
else
|
else
|
||||||
|
|
||||||
render action: "edit"
|
render action: "edit"
|
||||||
@ -124,28 +139,36 @@ class Admin::PProductRefsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def autocomplete
|
def autocomplete
|
||||||
@p_product_refs = PProductRef.for_search(params[:search]).limit(50)
|
# @p_product_refs = PProductRef.joins(:p_product)
|
||||||
|
@p_product_refs = PProductRef.limit(10).global_search(params[:search])
|
||||||
|
|
||||||
if params[:p_customer_id]
|
|
||||||
@p_customer = PCustomer.where(:id => params[:p_customer_id]).first
|
|
||||||
#@p_product_refs = @p_product_refs.where("p_products.p_customer_id IS NULL or p_products.p_customer_id = ? ", @p_customer.id).joins(:p_customer_cats).where(:p_customer_cats => {:id => @p_customer.p_customer_cat_id})
|
|
||||||
end
|
|
||||||
|
|
||||||
@p_product_refs = @p_product_refs.where(:p_products => {:enabled => true})
|
# @p_product_refs = PProductRef.joins(:p_product).all
|
||||||
|
# # @p_product_refs = PProductRef.for_search(params[:search]).limit(50)
|
||||||
|
|
||||||
if params[:not_assembled].to_s == "true"
|
# if params[:p_customer_id]
|
||||||
|
# @p_customer = PCustomer.where(:id => params[:p_customer_id]).first
|
||||||
|
# #@p_product_refs = @p_product_refs.where("p_products.p_customer_id IS NULL or p_products.p_customer_id = ? ", @p_customer.id).joins(:p_customer_cats).where(:p_customer_cats => {:id => @p_customer.p_customer_cat_id})
|
||||||
|
# end
|
||||||
|
|
||||||
@p_product_refs = @p_product_refs.not_assembleds
|
# @p_product_refs = @p_product_refs.where(:p_products => {:enabled => true})
|
||||||
|
|
||||||
end
|
# if params[:not_assembled].to_s == "true"
|
||||||
|
|
||||||
|
# @p_product_refs = @p_product_refs.not_assembleds
|
||||||
|
|
||||||
|
# end
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
|
|
||||||
@p_product_refs.distinct.all.each do |p_product_ref|
|
# @p_product_refs.distinct.all.each do |p_product_ref|
|
||||||
|
# result << {:member_label => p_product_ref.member_label, :id => p_product_ref.id }
|
||||||
|
# end
|
||||||
|
|
||||||
|
@p_product_refs.all.each do |p_product_ref|
|
||||||
result << {:member_label => p_product_ref.member_label, :id => p_product_ref.id }
|
result << {:member_label => p_product_ref.member_label, :id => p_product_ref.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json { render json: result}
|
format.json { render json: result}
|
||||||
end
|
end
|
||||||
|
@ -18,9 +18,13 @@ class Admin::PProductsController < ApplicationController
|
|||||||
|
|
||||||
params[:search] = params[:search] || {}
|
params[:search] = params[:search] || {}
|
||||||
|
|
||||||
|
global_search_ids = p_product_cat_id_ids = s_brand_id_ids = @p_products.ids
|
||||||
|
|
||||||
|
if params[:search][:global].to_s != ""
|
||||||
|
global_search_ids = PProduct.global_search(params[:search][:global]).ids
|
||||||
|
end
|
||||||
|
|
||||||
params[:search][:enabled] = "Oui" if !params[:search][:enabled]
|
params[:search][:enabled] = "Oui" if !params[:search][:enabled]
|
||||||
|
|
||||||
if params[:search][:enabled].to_s == "Oui"
|
if params[:search][:enabled].to_s == "Oui"
|
||||||
@p_products = @p_products.where(:enabled => true)
|
@p_products = @p_products.where(:enabled => true)
|
||||||
elsif params[:search][:enabled].to_s == "Non"
|
elsif params[:search][:enabled].to_s == "Non"
|
||||||
@ -37,17 +41,23 @@ class Admin::PProductsController < ApplicationController
|
|||||||
|
|
||||||
if params[:search][:p_product_cat_id].to_s != ""
|
if params[:search][:p_product_cat_id].to_s != ""
|
||||||
if params[:search][:p_product_cat_id].to_s == "null"
|
if params[:search][:p_product_cat_id].to_s == "null"
|
||||||
@p_products = @p_products.where(:p_product_cat_id => nil)
|
# @p_products = @p_products.where(:p_product_cat_id => nil)
|
||||||
|
p_product_cat_id_ids = @p_product_refs.where(:cc_p_product_cat_id => nil).ids
|
||||||
else
|
else
|
||||||
@p_products = @p_products.where(:p_product_cat_id => params[:search][:p_product_cat_id])
|
# @p_products = @p_products.where(:p_product_cat_id => params[:search][:p_product_cat_id])
|
||||||
|
p_product_cat_id_ids = @p_products.where(:p_product_cat_id => params[:search][:p_product_cat_id]).ids
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if params[:search][:s_brand_id].to_s != ""
|
if params[:search][:s_brand_id].to_s != ""
|
||||||
@p_products = @p_products.where(:s_brand_id => params[:search][:s_brand_id])
|
@p_products = @p_products.where(:s_brand_id => params[:search][:s_brand_id])
|
||||||
|
s_brand_id_ids = @p_products.where(:s_brand_id => params[:search][:s_brand_id]).ids
|
||||||
end
|
end
|
||||||
|
|
||||||
|
final_ids = global_search_ids & p_product_cat_id_ids & s_brand_id_ids
|
||||||
|
@p_products = PProduct.where(id: final_ids)
|
||||||
|
|
||||||
@p_products = sort_by_sorting(@p_products, "id DESC")
|
@p_products = sort_by_sorting(@p_products, "id DESC")
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html{
|
format.html{
|
||||||
@ -60,7 +70,6 @@ class Admin::PProductsController < ApplicationController
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@ -72,9 +81,12 @@ class Admin::PProductsController < ApplicationController
|
|||||||
|
|
||||||
|
|
||||||
@p_product = PProduct.new #(:p_customer_cat_ids => [3])
|
@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
|
fournisseur_label = params[:fournisseur_label] if params[:fournisseur_label]
|
||||||
|
if params[:price_line_id]
|
||||||
|
@price_line = PriceLine.find(params[:price_line_id])
|
||||||
|
end
|
||||||
|
@p_product_refs = @p_product.p_product_refs.build(ct_sub_name: fournisseur_label)
|
||||||
@p_product_ref_specs = @p_product_refs.p_product_ref_specs.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_type = @p_product_ref_specs.build_p_spec_type
|
||||||
@p_spec_value = @p_product_ref_specs.build_p_spec_value
|
@p_spec_value = @p_product_ref_specs.build_p_spec_value
|
||||||
|
@ -13,7 +13,7 @@ class Admin::PSpecValuesController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@p_spec_values = PSpecValue.all
|
@p_spec_values = PSpecValue.all
|
||||||
|
|
||||||
@p_spec_values = sort_by_sorting(@p_spec_values, "id DESC")
|
@p_spec_values = sort_by_sorting(@p_spec_values, "value + 0 ASC")
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html{
|
format.html{
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
|
|
||||||
@ref_price_lines = @demande.price_line_block.price_lines
|
@ref_price_lines = @demande.price_line_block.price_lines
|
||||||
|
|
||||||
@ref_price_lines.group(:p_product_ref_id).each do |plr|
|
@ref_price_lines.unscoped.select(:p_product_ref_id).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))
|
@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
|
||||||
|
|
||||||
@ -296,6 +296,8 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
if @price_document.save
|
if @price_document.save
|
||||||
redirect_to consult_edit_admin_price_document_path(:id => @price_document.token)
|
redirect_to consult_edit_admin_price_document_path(:id => @price_document.token)
|
||||||
else
|
else
|
||||||
|
@demande = PriceDocument.where(:id => @price_document.doc_ref_id).first
|
||||||
|
|
||||||
render action: "consult"
|
render action: "consult"
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -336,6 +338,7 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
|
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
raise
|
||||||
@price_document = PriceDocument.find(params[:id])
|
@price_document = PriceDocument.find(params[:id])
|
||||||
|
|
||||||
@avoir = true if @price_document.label == "Avoir"
|
@avoir = true if @price_document.label == "Avoir"
|
||||||
@ -360,6 +363,8 @@ class Admin::PriceDocumentsController < ApplicationController
|
|||||||
redirect_to [:admin, PriceDocument.find(@price_document.doc_ref_id)]
|
redirect_to [:admin, PriceDocument.find(@price_document.doc_ref_id)]
|
||||||
elsif @price_document.ref_element
|
elsif @price_document.ref_element
|
||||||
redirect_to [:admin, @price_document.ref_element]
|
redirect_to [:admin, @price_document.ref_element]
|
||||||
|
elsif @price_document.label == "Catalogue fournisseur"
|
||||||
|
redirect_to match_refs_admin_import_csvs_path
|
||||||
else
|
else
|
||||||
redirect_to [:admin, @price_document]
|
redirect_to [:admin, @price_document]
|
||||||
end
|
end
|
||||||
|
76
app/controllers/admin/sorecop_cats_controller.rb
Normal file
76
app/controllers/admin/sorecop_cats_controller.rb
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
|
||||||
|
class Admin::SorecopCatsController < ApplicationController
|
||||||
|
layout "admin"
|
||||||
|
before_action :auth_admin
|
||||||
|
|
||||||
|
before_action :admin_space
|
||||||
|
|
||||||
|
def admin_space
|
||||||
|
@admin_space = "default"
|
||||||
|
end
|
||||||
|
|
||||||
|
def index
|
||||||
|
@sorecop_cats = SorecopCat.all
|
||||||
|
|
||||||
|
@sorecop_cats = sort_by_sorting(@sorecop_cats, "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
|
||||||
|
@sorecop_cats = @sorecop_cats.page(page).per(per_page)
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@sorecop_cat = SorecopCat.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@sorecop_cat = SorecopCat.new
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@sorecop_cat = SorecopCat.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@sorecop_cat = SorecopCat.new(params.require(:sorecop_cat).permit!)
|
||||||
|
|
||||||
|
if @sorecop_cat.save
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "new"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def update
|
||||||
|
@sorecop_cat = SorecopCat.find(params[:id])
|
||||||
|
|
||||||
|
|
||||||
|
if @sorecop_cat.update_attributes(params.require(:sorecop_cat).permit!)
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "edit"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@sorecop_cat = SorecopCat.find(params[:id])
|
||||||
|
@sorecop_cat.destroy
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
76
app/controllers/admin/sorecop_taxes_controller.rb
Normal file
76
app/controllers/admin/sorecop_taxes_controller.rb
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# -*- encoding : utf-8 -*-
|
||||||
|
|
||||||
|
class Admin::SorecopTaxesController < ApplicationController
|
||||||
|
layout "admin"
|
||||||
|
before_action :auth_admin
|
||||||
|
|
||||||
|
before_action :admin_space
|
||||||
|
|
||||||
|
def admin_space
|
||||||
|
@admin_space = "default"
|
||||||
|
end
|
||||||
|
|
||||||
|
def index
|
||||||
|
@sorecop_taxes = SorecopTax.all
|
||||||
|
|
||||||
|
@sorecop_taxes = sort_by_sorting(@sorecop_taxes, "sorecop_cat_id ASC")
|
||||||
|
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
|
||||||
|
@sorecop_taxes = @sorecop_taxes.page(page).per(per_page)
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@sorecop_tax = SorecopTax.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@sorecop_tax = SorecopTax.new
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@sorecop_tax = SorecopTax.find(params[:id])
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@sorecop_tax = SorecopTax.new(params.require(:sorecop_tax).permit!)
|
||||||
|
|
||||||
|
if @sorecop_tax.save
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "new"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def update
|
||||||
|
@sorecop_tax = SorecopTax.find(params[:id])
|
||||||
|
|
||||||
|
|
||||||
|
if @sorecop_tax.update_attributes(params.require(:sorecop_tax).permit!)
|
||||||
|
|
||||||
|
else
|
||||||
|
render action: "edit"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@sorecop_tax = SorecopTax.find(params[:id])
|
||||||
|
@sorecop_tax.destroy
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -50,7 +50,7 @@ class Admin::TimerWatchersController < ApplicationController
|
|||||||
|
|
||||||
@edit_wacthers_to_destroy = EditWatcher.where("created_at < ?", (Time.now - 2)).destroy_all
|
@edit_wacthers_to_destroy = EditWatcher.where("created_at < ?", (Time.now - 2)).destroy_all
|
||||||
|
|
||||||
@edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).group(:admin_id).all
|
@edit_watchers_source = @edit_watchers_source.where("created_at >= ?", (Time.now - 2)).select(:admin_id).group(:admin_id).all
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ class ApplicationController < ActionController::Base
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
set_breadcrumb
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -126,6 +127,10 @@ class ApplicationController < ActionController::Base
|
|||||||
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_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_powers, "Types de chargeurs"
|
||||||
set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_zones, "Zones produits"
|
set_sub_sub_menu :stocks, :p_preferences_products_menu, :p_product_zones, "Zones produits"
|
||||||
|
set_sub_sub_menu :stocks, :p_preferences_products_menu, :import_csvs, "Import Excel"
|
||||||
|
set_sub_sub_menu :stocks, :p_preferences_products_menu, :import_csv_match_refs, "Rapprochement références", match_refs_admin_import_csvs_path
|
||||||
|
set_sub_sub_menu :stocks, :p_preferences_products_menu, :sorecop_cats, "Catégories SORECOP"
|
||||||
|
set_sub_sub_menu :stocks, :p_preferences_products_menu, :sorecop_taxes, "taxe SORECOP"
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -539,5 +544,26 @@ class ApplicationController < ActionController::Base
|
|||||||
@dropdown_title = "Parametrage"
|
@dropdown_title = "Parametrage"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_breadcrumb
|
||||||
|
@result = {}
|
||||||
|
if @qi_menu_active.present?
|
||||||
|
current_menu = @qi_menus[@qi_menu_active]
|
||||||
|
current_controller = controller_name.to_sym
|
||||||
|
@action = action_name.to_sym
|
||||||
|
@result[:first] = {name: current_menu[:name], link: current_menu[:link]}
|
||||||
|
if current_menu[:elements][current_controller]
|
||||||
|
@result[:second] = current_menu[:elements][current_controller]
|
||||||
|
elsif current_menu[:elements][:p_preferences_products_menu] && current_menu[:elements][:p_preferences_products_menu][:sub_elements][current_controller]
|
||||||
|
@result[:second] = current_menu[:elements][:p_preferences_products_menu][:sub_elements][current_controller]
|
||||||
|
else
|
||||||
|
@result[:second] = nil
|
||||||
|
end
|
||||||
|
if @result[:second]
|
||||||
|
if @result[:first][:name] == @result[:second][:name]
|
||||||
|
@result[:second] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
74
app/helpers/breadcrumb_helper.rb
Normal file
74
app/helpers/breadcrumb_helper.rb
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# DOC :
|
||||||
|
# ajouter =breadcrumb dans une vue
|
||||||
|
# pour personaliser le breadcrumb, il y a plusieurs options :
|
||||||
|
# passer un ou plusieurs parametre piur overrider l'existant par défaut
|
||||||
|
# :first_title premier element du breadcrumb
|
||||||
|
# :first_link premier path du breadcrumb
|
||||||
|
#
|
||||||
|
# :second_title second element du breadcrumb
|
||||||
|
# :second_link second path du breadcrumb
|
||||||
|
#
|
||||||
|
# :last_element le tout dernier element du breadcrumb
|
||||||
|
#
|
||||||
|
# :record est le nom du record pour un show ou un edit par exemple :record => @p_product.name
|
||||||
|
#
|
||||||
|
# :default_crud booléen qui active/neutralise la création du titre "Détail de .." ou "Modification .."
|
||||||
|
|
||||||
|
|
||||||
|
module BreadcrumbHelper
|
||||||
|
def breadcrumb(opts = {})
|
||||||
|
default_opts = {
|
||||||
|
action: @action,
|
||||||
|
first_title: @result[:first][:name],
|
||||||
|
first_link: @result[:first][:link],
|
||||||
|
default_crud: true
|
||||||
|
}
|
||||||
|
|
||||||
|
if @result[:second]
|
||||||
|
default_opts[:second_title] = @result[:second][:name]
|
||||||
|
default_opts[:second_link] = @result[:second][:link]
|
||||||
|
end
|
||||||
|
|
||||||
|
options = default_opts.merge opts
|
||||||
|
|
||||||
|
|
||||||
|
capture_haml do
|
||||||
|
haml_tag :h1 do
|
||||||
|
unless @result.present?
|
||||||
|
haml_concat "Erreur dans le BreadcrumbHelper"
|
||||||
|
else
|
||||||
|
if options[:record].present? || options[:last_element].present?
|
||||||
|
haml_concat(link_to options[:first_title], options[:first_link])
|
||||||
|
if options[:second_title].present? && options[:second_link].present?
|
||||||
|
haml_tag(:span) { haml_concat(link_to options[:second_title], options[:second_link]) }
|
||||||
|
elsif options[:second_title].present?
|
||||||
|
haml_tag(:span) {haml_concat( options[:second_title])}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if options[:second_title].present?
|
||||||
|
haml_concat(link_to options[:first_title], options[:first_link])
|
||||||
|
haml_tag(:span) { haml_concat( options[:second_title]) }
|
||||||
|
else
|
||||||
|
haml_concat( options[:first_title])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if options[:default_crud]
|
||||||
|
case options[:action]
|
||||||
|
when :new
|
||||||
|
haml_tag(:span) {haml_concat("Création #{options[:first_title].singularize.downcase}")}
|
||||||
|
when :edit
|
||||||
|
options[:record].present? ? haml_tag(:span) {haml_concat("Modification de : #{options[:record]}")} : haml_tag(:span) {haml_concat("Modification")}
|
||||||
|
when :index
|
||||||
|
haml_tag(:span) {haml_concat("Liste")}
|
||||||
|
when :show
|
||||||
|
options[:record].present? ? haml_tag(:span) {haml_concat("Détail de : #{options[:record]}")} : haml_tag(:span) {haml_concat("Détail")}
|
||||||
|
else
|
||||||
|
haml_tag(:span) {haml_concat(options[:record])} if options[:record].present?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
haml_tag(:span) { haml_concat( options[:last_element]) } if options[:last_element].present?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -32,11 +32,15 @@ class ImportCsv < ApplicationRecord
|
|||||||
|
|
||||||
|
|
||||||
after_create do
|
after_create do
|
||||||
|
if file_is_csv?
|
||||||
csv_text = File.read(self.file.path, :encoding => 'UTF-8')
|
csv_text = File.read(self.file.path, :encoding => 'UTF-8')
|
||||||
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
||||||
|
headers = csv.headers
|
||||||
@csv.headers.each do |header|
|
else
|
||||||
|
xlsx = Roo::Spreadsheet.open(self.file.path, extension: :xlsx) # open spreadsheet
|
||||||
|
headers = xlsx.row(1)
|
||||||
|
end
|
||||||
|
headers.each do |header|
|
||||||
self.import_csv_headers << ImportCsvHeader.new(:name => header)
|
self.import_csv_headers << ImportCsvHeader.new(:name => header)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -50,12 +54,15 @@ class ImportCsv < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
self.save
|
self.save
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def file_is_csv?
|
||||||
|
File.read(self.file.path, :encoding => 'utf-8').valid_encoding?
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def charge
|
def charge
|
||||||
|
|
||||||
self.import_csv_elements.each do |e|
|
self.import_csv_elements.each do |e|
|
||||||
@ -63,10 +70,12 @@ class ImportCsv < ApplicationRecord
|
|||||||
e.destroy
|
e.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
csv_text = File.read(self.file.path, :encoding => 'UTF-8')
|
|
||||||
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
|
||||||
r = []
|
r = []
|
||||||
@csv.each do |row|
|
|
||||||
|
if file_is_csv?
|
||||||
|
csv_text = File.read(self.file.path, :encoding => 'UTF-8')
|
||||||
|
csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
||||||
|
csv.each do |row|
|
||||||
line = {}
|
line = {}
|
||||||
self.import_csv_champs.each do |import_csv_champ|
|
self.import_csv_champs.each do |import_csv_champ|
|
||||||
if import_csv_champ.header?
|
if import_csv_champ.header?
|
||||||
@ -74,14 +83,30 @@ class ImportCsv < ApplicationRecord
|
|||||||
elsif import_csv_champ.value?
|
elsif import_csv_champ.value?
|
||||||
eval "line['#{import_csv_champ.champ}'] = \"#{import_csv_champ.value}\""
|
eval "line['#{import_csv_champ.champ}'] = \"#{import_csv_champ.value}\""
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
r << line
|
r << line
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return r
|
return r
|
||||||
|
else
|
||||||
|
xlsx = Roo::Spreadsheet.open(self.file.path, extension: :xlsx) # open spreadsheet
|
||||||
|
headers = xlsx.row(1) # get header row
|
||||||
|
xlsx.each_with_index do |row, idx|
|
||||||
|
line = {}
|
||||||
|
next if idx == 0 # skip header
|
||||||
|
# create hash from headers and cells
|
||||||
|
data = Hash[[headers, row].transpose]
|
||||||
|
self.import_csv_champs.each do |import_csv_champ|
|
||||||
|
# raise
|
||||||
|
if import_csv_champ.header?
|
||||||
|
eval "line['#{import_csv_champ.champ}'] = data[\"#{import_csv_champ.header}\"]"
|
||||||
|
elsif import_csv_champ.value?
|
||||||
|
eval "line['#{import_csv_champ.champ}'] = \"#{import_csv_champ.value}\""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
r << line
|
||||||
|
end
|
||||||
|
return r
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def load
|
def load
|
||||||
|
@ -3,9 +3,10 @@ class PArticle < ApplicationRecord
|
|||||||
belongs_to :p_product_ref
|
belongs_to :p_product_ref
|
||||||
has_one :p_product, through: :p_product_ref
|
has_one :p_product, through: :p_product_ref
|
||||||
has_one :p_product_color, through: :p_product_ref
|
has_one :p_product_color, through: :p_product_ref
|
||||||
|
has_one :s_brand, through: :p_product_ref
|
||||||
|
|
||||||
has_many :p_article_serial_nums, dependent: :destroy
|
has_many :p_article_serial_nums, dependent: :destroy
|
||||||
has_many :p_serial_num_values, through: :p_article_serial_nums
|
# has_many :p_serial_num_values, through: :p_article_serial_nums
|
||||||
accepts_nested_attributes_for :p_article_serial_nums
|
accepts_nested_attributes_for :p_article_serial_nums
|
||||||
|
|
||||||
validates_presence_of :p_product_ref
|
validates_presence_of :p_product_ref
|
||||||
@ -15,7 +16,7 @@ class PArticle < ApplicationRecord
|
|||||||
if PGrade::ACTIVATED
|
if PGrade::ACTIVATED
|
||||||
acts_as_sorting :fields => {
|
acts_as_sorting :fields => {
|
||||||
:id => {:name => "id", :reorder => true},
|
:id => {:name => "id", :reorder => true},
|
||||||
:p_product_ref_code => {:name => "Code ref", :reorder => true},
|
:p_product_ref_ref => {:name => "Code ref", :reorder => true},
|
||||||
:p_product_ref => {:name => "Désignation", :reorder => true},
|
:p_product_ref => {:name => "Désignation", :reorder => true},
|
||||||
:p_grade => {:name => "Grade", :reorder => true},
|
:p_grade => {:name => "Grade", :reorder => true},
|
||||||
:color => {:name => "Couleur"},
|
:color => {:name => "Couleur"},
|
||||||
@ -25,13 +26,26 @@ class PArticle < ApplicationRecord
|
|||||||
else
|
else
|
||||||
acts_as_sorting :fields => {
|
acts_as_sorting :fields => {
|
||||||
:id => {:name => "id", :reorder => true},
|
:id => {:name => "id", :reorder => true},
|
||||||
:p_product_ref_code => {:name => "Code ref", :reorder => true},
|
:p_product_ref_ref => {:name => "Code ref", :reorder => true},
|
||||||
:p_product_ref => {:name => "Désignation", :reorder => true},
|
:p_product_ref => {:name => "Désignation", :reorder => true},
|
||||||
:color => {:name => "Couleur"},
|
:color => {:name => "Couleur"},
|
||||||
:p_article_serial_nums => {:name => "N° identifiants"},
|
:p_article_serial_nums => {:name => "N° identifiants"},
|
||||||
:actions => {:name => "Actions", :reorder => false},
|
:actions => {:name => "Actions", :reorder => false},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
include PgSearch::Model
|
||||||
|
pg_search_scope :global_search,
|
||||||
|
associated_against: {
|
||||||
|
p_product_ref: [:cc_name, :ref],
|
||||||
|
s_brand: [ :code, :name ],
|
||||||
|
p_product_color: [:name, :color],
|
||||||
|
p_article_serial_nums: [:value]
|
||||||
|
},
|
||||||
|
using: {
|
||||||
|
tsearch: { prefix: true }
|
||||||
|
}
|
||||||
|
|
||||||
def member_label
|
def member_label
|
||||||
"#{p_product_ref.cc_name}"
|
"#{p_product_ref.cc_name}"
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
class PBank < ApplicationRecord
|
class PBank < ApplicationRecord
|
||||||
|
has_many :particulars, :as => :owner, :dependent => :destroy
|
||||||
end
|
end
|
||||||
|
@ -5,5 +5,5 @@ class PContact < ApplicationRecord
|
|||||||
has_many :p_contact_contact_types, :dependent => :destroy
|
has_many :p_contact_contact_types, :dependent => :destroy
|
||||||
|
|
||||||
has_many :p_contact_types, :through => :p_contact_contact_types
|
has_many :p_contact_types, :through => :p_contact_contact_types
|
||||||
|
belongs_to :p_payment_type
|
||||||
end
|
end
|
||||||
|
@ -65,6 +65,26 @@ class PCustomer < ApplicationRecord
|
|||||||
has_many :order_hists
|
has_many :order_hists
|
||||||
|
|
||||||
# before_validation :set_auth_token, on: [:create, :update]
|
# before_validation :set_auth_token, on: [:create, :update]
|
||||||
|
before_validation do
|
||||||
|
if self.code.blank?
|
||||||
|
generate_code
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_code
|
||||||
|
if !self.code
|
||||||
|
last_used_code = self.class.all.order(code: :desc).limit(1)[0].code
|
||||||
|
last_number = last_used_code.match(/\d+/).to_s.to_i + 1
|
||||||
|
|
||||||
|
code = "CLI%04d" % [last_number]
|
||||||
|
|
||||||
|
while self.class.find_by(code: code)
|
||||||
|
last_number += 1
|
||||||
|
code = "CLI%04d" % [last_number]
|
||||||
|
end
|
||||||
|
self.code = code
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.qi_table_order
|
def self.qi_table_order
|
||||||
@ -123,8 +143,10 @@ class PCustomer < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
after_initialize do
|
after_initialize do
|
||||||
|
begin
|
||||||
self.p_payment_type_id = 41 if !self.p_payment_type_id?
|
self.p_payment_type_id = 41 if !self.p_payment_type_id?
|
||||||
|
rescue
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -256,6 +278,7 @@ class PCustomer < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def solde_avoir_and_bills(date = Date.today)
|
def solde_avoir_and_bills(date = Date.today)
|
||||||
|
raise # p_document_id à remplacer
|
||||||
self.p_documents.where(:p_document_type_id => [4,7]).where("created_at < ?", date.to_time.end_of_day).sum(:cache_total_ttc)
|
self.p_documents.where(:p_document_type_id => [4,7]).where("created_at < ?", date.to_time.end_of_day).sum(:cache_total_ttc)
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -480,5 +503,438 @@ class PCustomer < ApplicationRecord
|
|||||||
end while PCustomer.exists?(column => self[column])
|
end while PCustomer.exists?(column => self[column])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
acts_as_csv_import :fields => [
|
||||||
|
:code,
|
||||||
|
:societe_raison_sociale,
|
||||||
|
:nom_enseigne,
|
||||||
|
:adresse_facturation_1,
|
||||||
|
:adresse_livraison_2,
|
||||||
|
:adresse_3,
|
||||||
|
:cp,
|
||||||
|
:cp2,
|
||||||
|
:ville_1,
|
||||||
|
:ville_2,
|
||||||
|
:pays,
|
||||||
|
:societe_livraison,
|
||||||
|
:forme_juridique,
|
||||||
|
:famille_client,
|
||||||
|
:facturer_ttc,
|
||||||
|
:mode_reglement,
|
||||||
|
:libelle_mode_reglement,
|
||||||
|
:telephone_1,
|
||||||
|
:telephone_2,
|
||||||
|
:fax,
|
||||||
|
:risque,
|
||||||
|
:bloque,
|
||||||
|
:credit_accorde,
|
||||||
|
:mode_tva,
|
||||||
|
:nii,
|
||||||
|
:nom_banque,
|
||||||
|
:adresse_banque_1,
|
||||||
|
:adresse_banque_2,
|
||||||
|
:adresse_banque_3,
|
||||||
|
:code_postal_banque,
|
||||||
|
:ville_banque,
|
||||||
|
:pays_banque,
|
||||||
|
:code_banque,
|
||||||
|
:code_guichet,
|
||||||
|
:numero_compte,
|
||||||
|
:cle_rib,
|
||||||
|
:compte_comptable,
|
||||||
|
:analytique,
|
||||||
|
:taux_remise,
|
||||||
|
:observation,
|
||||||
|
:export_compta,
|
||||||
|
:releve_compte,
|
||||||
|
:email,
|
||||||
|
:url,
|
||||||
|
:siret,
|
||||||
|
:representant,
|
||||||
|
:nom_representant,
|
||||||
|
:encour_initial,
|
||||||
|
:credit_disponible,
|
||||||
|
:code_tarif,
|
||||||
|
:telephone_livraison,
|
||||||
|
:portable_livraison,
|
||||||
|
:fax_livraison,
|
||||||
|
:encours_courant,
|
||||||
|
:encours,
|
||||||
|
:client_divers,
|
||||||
|
:contacts_client,
|
||||||
|
:date_creation,
|
||||||
|
:code_iban,
|
||||||
|
:code_bic,
|
||||||
|
:nom_contact,
|
||||||
|
:societe_contact,
|
||||||
|
:titre_contact,
|
||||||
|
:fonction_contact,
|
||||||
|
:telephone_contact,
|
||||||
|
:portable_contact,
|
||||||
|
:email_contact
|
||||||
|
]
|
||||||
|
|
||||||
|
def self.custom_csv_import(list, import_csv)
|
||||||
|
#OK Code AUTO :code OK :code
|
||||||
|
#OK Société - Raison Sociale :particular.organisation OK :societe_raison_sociale
|
||||||
|
#OK Nom enseigne :particular.com_name OK :nom_enseigne
|
||||||
|
#OK Adresse facturation 1 :particular.address_1 OK :adresse_facturation_1
|
||||||
|
#OK Adresse Livraison 2 :particular.address_2 OK :adresse_livraison_2
|
||||||
|
#OK Adresse 3 :particular.address_3 OK :adresse_3
|
||||||
|
#OK Code Postal 1 :particular.cp OK :cp
|
||||||
|
#OK Code Postal 2 VIDE OK :cp2
|
||||||
|
#OK Ville 1 :particular_city OK :ville_1
|
||||||
|
#OK Ville 2 VIDE OK :ville_2
|
||||||
|
#OK Pays :particular.country OK :pays
|
||||||
|
#OK Société Livraison :particular.address_4 OK :societe_livraison
|
||||||
|
#OK Forme juridique livraison :particular.address_5 OK :forme_juridique
|
||||||
|
#OK Famille Client VIDE OK :famille_client
|
||||||
|
#OK Facturer en TTC VIDE OK :facturer_ttc
|
||||||
|
#OK Mode Règlement :p_payment_type OK :mode_reglement
|
||||||
|
#OK Libellé Mode Règlement :payment_delais OK :libelle_mode_reglement
|
||||||
|
#OK Téléphone 1 :particular.tel OK :telephone_1
|
||||||
|
#OK Téléphone 2 :particular.tel2 OK :telephone_2
|
||||||
|
#OK Fax :particular.fax OK :fax
|
||||||
|
#OK Risque VIDE OK :risque
|
||||||
|
#OK Bloqué VIDE OK :bloque
|
||||||
|
#OK Crédit accordé VIDE OK :credit_accorde
|
||||||
|
#OK Mode TVA VIDE OK :mode_tva
|
||||||
|
#OK N.I.I. VIDE OK :nii
|
||||||
|
#OK Nom Banque :p_bank.name OK :nom_banque
|
||||||
|
#OK Adresse 1 Banque :p_bank.particular.address_1 OK :adresse_banque_1
|
||||||
|
#OK Adresse 2 Banque :p_bank.particular.address_2 OK :adresse_banque_2
|
||||||
|
#OK Adresse 3 Banque VIDE OK :adresse_banque_3
|
||||||
|
#OK Code Postal Banque :p_bank.particular.cp OK :code_postal_banque
|
||||||
|
#OK Ville Banque :p_bank.particular.ville OK :ville_banque
|
||||||
|
#OK Pays Banque :p_bank.particular.pays OK :pays_banque
|
||||||
|
#OK Code Banque INUTILE OK :code_banque
|
||||||
|
#OK Code Guichet INUTILE OK :code_guichet
|
||||||
|
#OK Numéro Compte INUTILE OK :numero_compte
|
||||||
|
#OK Clé RIB INUTILE OK :cle_rib
|
||||||
|
# Compte Comptable ??? ?? :compte_comptable
|
||||||
|
#OK Analytique VIDE OK :analytique
|
||||||
|
#OK Taux Remise VIDE OK :taux_remise
|
||||||
|
#OK Observations AUTO :p_customer_sheet_note OK :observation
|
||||||
|
#OK Export Compta VIDE OK :export_compta
|
||||||
|
# Relevé Compte Bboolean à ajouter dans la base ?? :releve_compte
|
||||||
|
#OK E-mail AUTO :email OK :email
|
||||||
|
#OK URL VIDE OK :url
|
||||||
|
#OK SIRET AUTO :siret OK :siret
|
||||||
|
#OK Représentant :p_commercial_code OK :representant
|
||||||
|
#OK Nom Représentant :p_commercial_firstname OK :nom_representant
|
||||||
|
# Encours initial ??? ?? :encour_initial
|
||||||
|
# Crédit Disponible ??? ?? :credit_disponible
|
||||||
|
#OK Code Tarif VIDE OK :code_tarif
|
||||||
|
#OK Téléphone Livraison :particular.send_tel OK :telephone_livraison
|
||||||
|
#OK Portable Livraison :particular.send_tel2 OK :portable_livraison
|
||||||
|
#OK Fax Livraison :particular.send_fax OK :fax_livraison
|
||||||
|
# Encours courant ??? ?? :encours_courant
|
||||||
|
# encours_courant ??? ?? :encours
|
||||||
|
# Client divers ??? ?? :client_divers
|
||||||
|
#OK Contacts client INUTILE OK :contacts_client
|
||||||
|
#OK Date de création INUTILE OK :date_creation
|
||||||
|
#OK Code IBAN :p_customer_ribs.iban OK :code_iban
|
||||||
|
#OK Code BIC :p_customer_ribs.bic OK :code_bic
|
||||||
|
#OK Nom du contact :p_contact_name OK :nom_contact
|
||||||
|
#OK Société du contact VIDE OK :societe_contact
|
||||||
|
#OK Titre du contact :p_contact.civilite OK :titre_contact
|
||||||
|
#OK Fonction du contact :p_contact.comment OK :fonction_contact
|
||||||
|
#OK Téléphone du contact :p_contact.tel OK :telephone_contact
|
||||||
|
#OK Portable du contact :p_contact.tel2 OK :portable_contact
|
||||||
|
#OK E-mail du contact :p_contact.email OK :email_contact
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap list
|
||||||
|
# ap list.class
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap import_csv
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
|
||||||
|
list.each do |row|
|
||||||
|
|
||||||
|
n = self.new(imported: true, p_customer_cat: PCustomerCat.find_by_name("Professionnel"))
|
||||||
|
# particular = Particular.new(pro: true)
|
||||||
|
particular_bill = Particular.new(pro: true)
|
||||||
|
bank = bic = iban = p_commercial = particular_send = send_tel = send_tel2 = send_fax = send_address_2 = p_commercial_code = p_commercial_firstname = contact_2 = nil
|
||||||
|
|
||||||
|
|
||||||
|
bank_particular = Particular.new(pro: true)
|
||||||
|
contact = PContact.new
|
||||||
|
|
||||||
|
row.each do |key, value|
|
||||||
|
|
||||||
|
if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal
|
||||||
|
eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')"
|
||||||
|
else
|
||||||
|
case key
|
||||||
|
when "societe_raison_sociale"
|
||||||
|
particular_bill.organisation = value if !value.blank?
|
||||||
|
|
||||||
|
when "nom_enseigne"
|
||||||
|
particular_bill.com_name = value if !value.blank?
|
||||||
|
|
||||||
|
when "adresse_facturation_1"
|
||||||
|
particular_bill.address_1 = value if !value.blank?
|
||||||
|
|
||||||
|
when "adresse_livraison_2"
|
||||||
|
send_address_2 = value if !value.blank?
|
||||||
|
|
||||||
|
when "adresse_3"
|
||||||
|
particular_bill.address_3 = value if !value.blank?
|
||||||
|
|
||||||
|
when "cp"
|
||||||
|
particular_bill.cp = value if !value.blank?
|
||||||
|
|
||||||
|
when "ville_1"
|
||||||
|
particular_bill.city = value if !value.blank?
|
||||||
|
|
||||||
|
when "pays"
|
||||||
|
particular_bill.country = value if !value.blank?
|
||||||
|
|
||||||
|
when "societe_livraison"
|
||||||
|
particular_bill.address_4 = value if !value.blank?
|
||||||
|
|
||||||
|
when "forme_juridique"
|
||||||
|
particular_bill.address_5 = value if !value.blank?
|
||||||
|
|
||||||
|
when "telephone_1"
|
||||||
|
particular_bill.tel = value if !value.blank?
|
||||||
|
|
||||||
|
when "telephone_2"
|
||||||
|
particular_bill.tel2 = value if !value.blank?
|
||||||
|
|
||||||
|
when "fax"
|
||||||
|
particular_bill.fax = value if !value.blank?
|
||||||
|
|
||||||
|
when "mode_reglement"
|
||||||
|
if value.present?
|
||||||
|
if value == "VIR" || "VIR COM" || "VIR 60 J NET" || "VIR 30 J NET"
|
||||||
|
n.p_payment_type_id = PPaymentType.find_or_create_by!(name: "Virement").id
|
||||||
|
elsif value == "TRAITE"
|
||||||
|
n.p_payment_type_id = PPaymentType.find_or_create_by!(name: "Traite").id
|
||||||
|
else
|
||||||
|
n.p_payment_type_id = PPaymentType.find_or_create_by!(name: value).id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
when "libelle_mode_reglement"
|
||||||
|
case value
|
||||||
|
when "Virement à la commande"
|
||||||
|
n.payment_delais = 0
|
||||||
|
when "Chèque à la commande"
|
||||||
|
n.payment_delais = 0
|
||||||
|
when "Chèque à réception"
|
||||||
|
n.payment_delais = 0
|
||||||
|
when "30 JOURS FIN DE MOIS"
|
||||||
|
n.payment_delais = 30
|
||||||
|
n.comptant = false
|
||||||
|
when "VIR 60J NET DATE RELEVE"
|
||||||
|
n.payment_delais = 60
|
||||||
|
n.comptant = false
|
||||||
|
when "TRAITE A 60 JOURS FIN DE MOIS"
|
||||||
|
n.payment_delais = 60
|
||||||
|
n.comptant = false
|
||||||
|
when "Mensuel - 30j fin de mois du dépôt"
|
||||||
|
n.payment_delais = 30
|
||||||
|
n.comptant = false
|
||||||
|
else
|
||||||
|
n.payment_delais = value if !value.blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
when "nom_banque"
|
||||||
|
if value.present?
|
||||||
|
bank = PBank.find_or_create_by!(name: value)
|
||||||
|
end
|
||||||
|
|
||||||
|
when "adresse_banque_1"
|
||||||
|
bank_particular.address_1 = value if !value.blank?
|
||||||
|
|
||||||
|
when "adresse_banque_2"
|
||||||
|
bank_particular.address_2 = value if !value.blank?
|
||||||
|
|
||||||
|
when "code_postal_banque"
|
||||||
|
bank_particular.cp = value if !value.blank?
|
||||||
|
|
||||||
|
when "ville_banque"
|
||||||
|
bank_particular.city = value if !value.blank?
|
||||||
|
|
||||||
|
when "pays_banque"
|
||||||
|
bank_particular.country = value if !value.blank?
|
||||||
|
|
||||||
|
when "telephone_livraison"
|
||||||
|
send_tel = value if !value.blank?
|
||||||
|
|
||||||
|
when "portable_livraison"
|
||||||
|
send_tel2 = value if !value.blank?
|
||||||
|
|
||||||
|
when "fax_livraison"
|
||||||
|
send_fax = value if !value.blank?
|
||||||
|
|
||||||
|
when "representant"
|
||||||
|
p_commercial_code = value if !value.blank?
|
||||||
|
when "nom_representant"
|
||||||
|
p_commercial_firstname = value if !value.blank?
|
||||||
|
|
||||||
|
when "code_iban"
|
||||||
|
iban = value if !value.blank?
|
||||||
|
when "code_bic"
|
||||||
|
bic = value if !value.blank?
|
||||||
|
|
||||||
|
when "nom_contact"
|
||||||
|
contact.name = value if !value.blank?
|
||||||
|
|
||||||
|
when "titre_contact"
|
||||||
|
particular_bill.civilite = value if !value.blank?
|
||||||
|
|
||||||
|
when "fonction_contact"
|
||||||
|
if value.present?
|
||||||
|
contact.p_contact_types << PContactType.find_or_create_by!(name: value)
|
||||||
|
end
|
||||||
|
when "telephone_contact"
|
||||||
|
contact.tel = value if !value.blank?
|
||||||
|
|
||||||
|
when "portable_contact"
|
||||||
|
if value.present?
|
||||||
|
if contact.tel.nil?
|
||||||
|
contact.tel = value if !value.blank?
|
||||||
|
else
|
||||||
|
contact_2 = PContact.new(tel: value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
when "email_contact"
|
||||||
|
contact.email = value if !value.blank?
|
||||||
|
|
||||||
|
when "observation"
|
||||||
|
n.p_customer_sheet_note = value if !value.blank?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# champs vides ou inutiles :
|
||||||
|
when "cp2"
|
||||||
|
when "ville_2"
|
||||||
|
when "famille_client"
|
||||||
|
when "facturer_ttc"
|
||||||
|
when "risque"
|
||||||
|
when "bloque"
|
||||||
|
when "credit_accorde"
|
||||||
|
when "mode_tva"
|
||||||
|
when "nii"
|
||||||
|
when "adresse_banque_3"
|
||||||
|
when "code_banque"
|
||||||
|
when "code_guichet"
|
||||||
|
when "numero_compte"
|
||||||
|
when "cle_rib"
|
||||||
|
when "analytique"
|
||||||
|
when "taux_remise"
|
||||||
|
when "export_compta"
|
||||||
|
when "url"
|
||||||
|
when "code_tarif"
|
||||||
|
when "contacts_client"
|
||||||
|
when "date_creation"
|
||||||
|
when "societe_contact"
|
||||||
|
|
||||||
|
# Champs ???
|
||||||
|
when "compte_comptable"
|
||||||
|
when "encour_initial"
|
||||||
|
when "credit_disponible"
|
||||||
|
when "releve_compte"
|
||||||
|
when "encours_courant"
|
||||||
|
when "releve_compte"
|
||||||
|
when "encours"
|
||||||
|
when "client_divers"
|
||||||
|
|
||||||
|
else
|
||||||
|
eval "n.#{key} = value if !value.blank?"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
n.particulars << particular_bill
|
||||||
|
|
||||||
|
n.save!
|
||||||
|
|
||||||
|
if bank
|
||||||
|
bank.bic = bic
|
||||||
|
bank_particular.organisation = bank.name
|
||||||
|
bank.particulars << bank_particular if bank_particular.address_1
|
||||||
|
bank.save!
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => bank)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if bic || iban
|
||||||
|
rib = PCustomerRib.find_or_create_by!(bic: bic, iban: iban)
|
||||||
|
rib.bank = bank.name if bank
|
||||||
|
account = PBankAccount.find_or_create_by!(bic: bic, iban: iban, p_customer: n)
|
||||||
|
account.update(p_bank: bank) if bank
|
||||||
|
|
||||||
|
n.p_customer_ribs << rib
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => rib)
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => account)
|
||||||
|
end
|
||||||
|
|
||||||
|
if p_commercial_code || p_commercial_firstname
|
||||||
|
p_commercial = PCommercial.find_or_create_by!(code: p_commercial_code, firstname: p_commercial_firstname)
|
||||||
|
n.p_commercial = p_commercial
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => p_commercial)
|
||||||
|
end
|
||||||
|
|
||||||
|
if send_tel || send_tel2 || send_fax || send_address_2
|
||||||
|
particular_send = Particular.new
|
||||||
|
particular_send.tel = send_tel if send_tel
|
||||||
|
particular_send.tel2 = send_tel2 if send_tel2
|
||||||
|
particular_send.fax = send_fax if send_fax
|
||||||
|
|
||||||
|
n.particulars << particular_send
|
||||||
|
n.particular_send_id = particular_send.id
|
||||||
|
end
|
||||||
|
|
||||||
|
n.p_contacts << contact if (contact.name || contact.tel || contact.email)
|
||||||
|
n.p_contacts << contact_2 if contact_2
|
||||||
|
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap n
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ contact §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap contact
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.contacts §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap n.p_contacts
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.particulars §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap n.particulars
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.p_customer_ribs §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap n.p_customer_ribs
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.p_commercial §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap n.p_commercial
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => n)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
class PCustomerRib < ActiveRecord::Base
|
class PCustomerRib < ActiveRecord::Base
|
||||||
belongs_to :p_customer
|
belongs_to :p_customer
|
||||||
|
|
||||||
has_many :p_documents, :dependent => :nullify
|
# has_many :p_documents, :dependent => :nullify
|
||||||
|
|
||||||
def generate_rum
|
def generate_rum
|
||||||
if self.sign_date
|
if self.sign_date
|
||||||
|
@ -44,6 +44,8 @@ class PCustomerSheet < ApplicationRecord
|
|||||||
:actions => {:name => "Actions", :reorder => false},
|
:actions => {:name => "Actions", :reorder => false},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# STATES = ["brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"]
|
||||||
|
STATES = ["AV BPA", "PAS BPA","BPA", "Traitée"]
|
||||||
|
|
||||||
|
|
||||||
def personalised_archive
|
def personalised_archive
|
||||||
@ -328,7 +330,6 @@ class PCustomerSheet < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
STATES = ["brouillon", "offre", "commande", "livrée","facturée", "annulée", "refusée"]
|
|
||||||
|
|
||||||
|
|
||||||
def unblock_price
|
def unblock_price
|
||||||
|
@ -1,2 +1,136 @@
|
|||||||
class PFournisseur < ApplicationRecord
|
class PFournisseur < ApplicationRecord
|
||||||
|
# has_many :particulars, :as => :owner, :dependent => :destroy
|
||||||
|
has_many :p_contacts, :as => :contactable, :dependent => :destroy
|
||||||
|
has_many :p_fournisseur_refs
|
||||||
|
|
||||||
|
acts_as_csv_import :fields => [
|
||||||
|
:nom_fournisseur,
|
||||||
|
:address,
|
||||||
|
:cp,
|
||||||
|
:ville,
|
||||||
|
:pays,
|
||||||
|
:tva_intracom,
|
||||||
|
:delai_paiement,
|
||||||
|
:interlocuteur,
|
||||||
|
:fonction,
|
||||||
|
:tel,
|
||||||
|
:skype,
|
||||||
|
:email_1,
|
||||||
|
:email_2,
|
||||||
|
:email_3,
|
||||||
|
:iban,
|
||||||
|
:bic,
|
||||||
|
:reglement_par
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def self.custom_csv_import(list, import_csv)
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap list
|
||||||
|
# ap list.class
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap import_csv
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
|
||||||
|
list.each do |row|
|
||||||
|
|
||||||
|
n = self.new
|
||||||
|
# particular = Particular.new(pro: true)
|
||||||
|
contact_1 = PContact.new
|
||||||
|
contact_2 = nil
|
||||||
|
contact_3 = nil
|
||||||
|
row.each do |key, value|
|
||||||
|
|
||||||
|
if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal
|
||||||
|
eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')"
|
||||||
|
else
|
||||||
|
case key
|
||||||
|
when "nom_fournisseur"
|
||||||
|
n.name = value if !value.blank?
|
||||||
|
when "address"
|
||||||
|
n.address1 = value if !value.blank?
|
||||||
|
when "ville"
|
||||||
|
n.city = value if !value.blank?
|
||||||
|
when "pays"
|
||||||
|
n.country = value if !value.blank?
|
||||||
|
when "tva_intracom"
|
||||||
|
n.tva_num = value if !value.blank?
|
||||||
|
when "delai_paiement"
|
||||||
|
if value.present?
|
||||||
|
case value
|
||||||
|
when "A la commande"
|
||||||
|
n.payment_delais = 0
|
||||||
|
when "A réception"
|
||||||
|
n.payment_delais = 0
|
||||||
|
when "7 jours net"
|
||||||
|
n.payment_delais = 7
|
||||||
|
when "21 jours net"
|
||||||
|
n.payment_delais = 21
|
||||||
|
when "30 jours"
|
||||||
|
n.payment_delais = 30
|
||||||
|
when "30 jours net"
|
||||||
|
n.payment_delais = 30
|
||||||
|
when "30 jours fin de mois"
|
||||||
|
n.payment_delais = 30
|
||||||
|
when "35 jours net"
|
||||||
|
n.payment_delais = 35
|
||||||
|
when "40 jours net"
|
||||||
|
n.payment_delais = 40
|
||||||
|
when "60 jours net"
|
||||||
|
n.payment_delais = 60
|
||||||
|
when "60 jours fin de mois"
|
||||||
|
n.payment_delais = 60
|
||||||
|
else
|
||||||
|
n.payment_delais = value if !value.blank?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
when "interlocuteur"
|
||||||
|
contact_1.name = value if !value.blank?
|
||||||
|
when "fonction"
|
||||||
|
contact_1.p_contact_types << PContactType.find_or_create_by!(name: value)
|
||||||
|
when "tel"
|
||||||
|
contact_1.tel = value if !value.blank?
|
||||||
|
when "skype"
|
||||||
|
contact_1.skype = value if !value.blank?
|
||||||
|
when "email_1"
|
||||||
|
contact_1.email = value if !value.blank?
|
||||||
|
when "email_2"
|
||||||
|
contact_2 = PContact.new(email: value)
|
||||||
|
when "email_3"
|
||||||
|
contact_3 = PContact.new(email: value)
|
||||||
|
when "reglement_par"
|
||||||
|
n.p_payment_type_id = PPaymentType.find_or_create_by!(name: value).id
|
||||||
|
else
|
||||||
|
eval "n.#{key} = value if !value.blank?"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
# particular.organisation = self.name
|
||||||
|
n.save!
|
||||||
|
if (contact_1.name || contact_1.tel || contact_1.skype || contact_1.email)
|
||||||
|
n.p_contacts << contact_1
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => contact_1)
|
||||||
|
end
|
||||||
|
if contact_2
|
||||||
|
n.p_contacts << contact_2
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => contact_2)
|
||||||
|
end
|
||||||
|
|
||||||
|
if contact_3
|
||||||
|
n.p_contacts << contact_3
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => contact_3)
|
||||||
|
end
|
||||||
|
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => n)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
4
app/models/p_fournisseur_ref.rb
Normal file
4
app/models/p_fournisseur_ref.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
class PFournisseurRef < ApplicationRecord
|
||||||
|
belongs_to :p_product_ref
|
||||||
|
belongs_to :p_fournisseur
|
||||||
|
end
|
@ -1,6 +1,7 @@
|
|||||||
class PPaymentType < ApplicationRecord
|
class PPaymentType < ApplicationRecord
|
||||||
belongs_to :p_bank_account
|
belongs_to :p_bank_account
|
||||||
has_many :p_payments
|
has_many :p_payments
|
||||||
|
has_many :p_fournisseurs
|
||||||
|
|
||||||
after_save do
|
after_save do
|
||||||
if self.p_bank_account
|
if self.p_bank_account
|
||||||
|
@ -28,14 +28,13 @@ class PProduct < ApplicationRecord
|
|||||||
has_many :p_product_images
|
has_many :p_product_images
|
||||||
|
|
||||||
belongs_to :p_customer
|
belongs_to :p_customer
|
||||||
|
belongs_to :sorecop_cat
|
||||||
|
|
||||||
belongs_to :p_product_cat
|
belongs_to :p_product_cat
|
||||||
belongs_to :s_brand
|
belongs_to :s_brand
|
||||||
|
|
||||||
validates :name, :presence => true
|
validates :name, :presence => true, exclusion: { in: ["--> Selectioner un produit <--"], message: "Selectioner un produit avant de valider" }
|
||||||
validates :code, :presence => true, :uniqueness => true
|
validates :code, :presence => true, :uniqueness => true, exclusion: { in: ["--> Indiquer un code produit <--"], message: "Indiquer un code produit avant de valider" }
|
||||||
|
|
||||||
|
|
||||||
has_many :tvable_tva_rates, :as => :tvable
|
has_many :tvable_tva_rates, :as => :tvable
|
||||||
has_many :tva_rates, :through => :tvable_tva_rates
|
has_many :tva_rates, :through => :tvable_tva_rates
|
||||||
@ -70,7 +69,22 @@ class PProduct < ApplicationRecord
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include PgSearch::Model
|
||||||
|
pg_search_scope :global_search,
|
||||||
|
against: [:name, :code],
|
||||||
|
associated_against: {
|
||||||
|
p_product_refs: [:cc_name, :ref],
|
||||||
|
s_brand: [ :code, :name ],
|
||||||
|
},
|
||||||
|
using: {
|
||||||
|
tsearch: { prefix: true }
|
||||||
|
}
|
||||||
|
|
||||||
|
before_validation do
|
||||||
|
if self.code.blank?
|
||||||
|
generate_code
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.for_search(search)
|
def self.for_search(search)
|
||||||
@ -104,15 +118,21 @@ class PProduct < ApplicationRecord
|
|||||||
|
|
||||||
after_create do
|
after_create do
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after_save do
|
after_save do
|
||||||
self.p_product_refs.each do |ppr|
|
self.p_product_refs.each do |ppr|
|
||||||
ppr.save
|
ppr.save
|
||||||
end
|
end
|
||||||
|
self.class.destroy_temp_p_product
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.destroy_temp_p_product
|
||||||
|
temp_p_product = PProduct.find_by(name: "--> Selectioner un produit <--", code: "--> Indiquer un code produit <--")
|
||||||
|
if temp_p_product.present?
|
||||||
|
temp_p_product.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def tva_rate(accounting_zone_id)
|
def tva_rate(accounting_zone_id)
|
||||||
if r = self.tva_rates.where(:accounting_zone_id => accounting_zone_id).first
|
if r = self.tva_rates.where(:accounting_zone_id => accounting_zone_id).first
|
||||||
@ -161,4 +181,277 @@ class PProduct < ApplicationRecord
|
|||||||
self.p_product_images.order(:position).first
|
self.p_product_images.order(:position).first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def generate_code
|
||||||
|
if !self.code
|
||||||
|
arr = []
|
||||||
|
brand = self.s_brand.code.to_s if self.s_brand
|
||||||
|
|
||||||
|
cat = self.p_product_cat.name.slice(0, 5).to_slug.upcase.to_s if self.p_product_cat
|
||||||
|
last_number = 1
|
||||||
|
|
||||||
|
arr << brand if brand.present?
|
||||||
|
arr << cat if cat.present?
|
||||||
|
arr << "%02d" % [last_number]
|
||||||
|
arr.prepend("PRODUCT") if arr.length < 2
|
||||||
|
code = arr.join('-')
|
||||||
|
|
||||||
|
while self.class.find_by(code: code)
|
||||||
|
arr = []
|
||||||
|
last_number += 1
|
||||||
|
arr << brand if brand.present?
|
||||||
|
arr << cat if cat.present?
|
||||||
|
arr << "%02d" % [last_number]
|
||||||
|
arr.prepend("PRODUCT") if arr.length < 2
|
||||||
|
code = arr.join('-')
|
||||||
|
end
|
||||||
|
self.code = code
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
acts_as_csv_import :fields => [
|
||||||
|
:identifiant,
|
||||||
|
:gencode,
|
||||||
|
:id,
|
||||||
|
:marque,
|
||||||
|
:famille,
|
||||||
|
:reference,
|
||||||
|
:modele,
|
||||||
|
:couleur,
|
||||||
|
:color,
|
||||||
|
:connectivite,
|
||||||
|
:sim,
|
||||||
|
:taille,
|
||||||
|
:capacite,
|
||||||
|
:infos_supp,
|
||||||
|
:reference_fabricant,
|
||||||
|
:etat,
|
||||||
|
:code_hs,
|
||||||
|
:indice_reparabilite,
|
||||||
|
:duree_dispo_pces_detachees,
|
||||||
|
:das_tete,
|
||||||
|
:das_corps,
|
||||||
|
:das_membre,
|
||||||
|
:poids,
|
||||||
|
:nb_pcs_colis,
|
||||||
|
:code_om,
|
||||||
|
:dtl,
|
||||||
|
:gbh_code_971,
|
||||||
|
:gbh_code_972,
|
||||||
|
:gbh_code_973,
|
||||||
|
:code_art,
|
||||||
|
:sorecop,
|
||||||
|
:pmp_hors_sorecop,
|
||||||
|
:target_hors_sorecop,
|
||||||
|
:frs,
|
||||||
|
:date,
|
||||||
|
:spec,
|
||||||
|
:dtl_targ,
|
||||||
|
:commentaires,
|
||||||
|
:com
|
||||||
|
]
|
||||||
|
|
||||||
|
def self.custom_csv_import(list, import_csv)
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
ap "*********************************************************************************************************"
|
||||||
|
# ap list.size
|
||||||
|
# ap list.class
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap import_csv
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
# ap "*********************************************************************************************************"
|
||||||
|
soreco_cat_hash = {
|
||||||
|
"Smartphone" => "Smartphones & Téléphones mobiles",
|
||||||
|
"Mobile" => "Smartphones & Téléphones mobiles",
|
||||||
|
"Tablette" => "Tablettes média et tablette PC",
|
||||||
|
"MP4" => "Baladeur MP4",
|
||||||
|
"Clé USB" => "Clés USB",
|
||||||
|
"Carte Mémoire" => "Cartes mémoires",
|
||||||
|
"Boitier Multimédia" => "Décodeurs, téléviseurs, enregistreurs"
|
||||||
|
}
|
||||||
|
|
||||||
|
list.each do |row|
|
||||||
|
next if row["marque"].blank?
|
||||||
|
n = self.find_or_initialize_by(s_brand: SBrand.find_by(name: row["marque"]), name: row["reference"])
|
||||||
|
n.imported = true
|
||||||
|
n.sorecop_cat = SorecopCat.find_by(name: soreco_cat_hash[row["famille"]])
|
||||||
|
ref = n.p_product_refs.build
|
||||||
|
|
||||||
|
row.each do |key, value|
|
||||||
|
if value.present?
|
||||||
|
case key
|
||||||
|
when "identifiant"
|
||||||
|
ref.description = value if !value.blank?
|
||||||
|
when "gencode"
|
||||||
|
ref.genecode = value if !value.blank?
|
||||||
|
when "id"
|
||||||
|
|
||||||
|
when "marque"
|
||||||
|
n.s_brand = SBrand.find_or_create_by!(name: value)
|
||||||
|
|
||||||
|
when "famille"
|
||||||
|
n.p_product_cat = PProductCat.find_or_create_by!(name: value)
|
||||||
|
|
||||||
|
when "reference"
|
||||||
|
n.name = value if !value.blank?
|
||||||
|
|
||||||
|
when "modele"
|
||||||
|
ref.ct_sub_name = value if !value.blank?
|
||||||
|
|
||||||
|
when "couleur"
|
||||||
|
ref.p_product_color = PProductColor.find_or_create_by!(name: value)
|
||||||
|
|
||||||
|
when "color"
|
||||||
|
if ref.p_product_color.nil?
|
||||||
|
ref.p_product_color = PProductColor.find_or_create_by!(color: value)
|
||||||
|
end
|
||||||
|
when "connectivite"
|
||||||
|
arr = []
|
||||||
|
cellular = [ "5G", "3G", "3G+", "4G", "4G+", "2G", "wifi", "BT"]
|
||||||
|
video = ["4K","HD" ]
|
||||||
|
power = ["5W", "12W", "18W", "20W", "96W", "40W", "10W", "40W"]
|
||||||
|
mix = ["<87W/4K", "5G/4K", "wifi/BT" ]
|
||||||
|
geoloc = [ "GPS" ]
|
||||||
|
|
||||||
|
if mix.include?(value)
|
||||||
|
arr = value.split('/')
|
||||||
|
else
|
||||||
|
arr << value
|
||||||
|
end
|
||||||
|
|
||||||
|
arr.each do |value|
|
||||||
|
spec = nil
|
||||||
|
if cellular.include?(value)
|
||||||
|
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
|
||||||
|
elsif video.include?(value)
|
||||||
|
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Résolution"), p_spec_value: PSpecValue.find_or_create_by!(value: value.to_s))
|
||||||
|
elsif power.include?(value)
|
||||||
|
PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Puissance éléctrique"), p_spec_value: PSpecValue.find_or_create_by!(value: value.gsub('W', ''), unit: "W"))
|
||||||
|
elsif geoloc.include?(value)
|
||||||
|
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Géolocalisation"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
|
||||||
|
else
|
||||||
|
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
|
||||||
|
end
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => spec)
|
||||||
|
end
|
||||||
|
|
||||||
|
when "sim"
|
||||||
|
if ["DS", "SS"].include?(value)
|
||||||
|
PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Sim"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
|
||||||
|
elsif value == "4G"
|
||||||
|
PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Connectivité"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
|
||||||
|
end
|
||||||
|
|
||||||
|
when "taille"
|
||||||
|
float = value.to_s.match(/[^"\s]*/)
|
||||||
|
PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Taille"), p_spec_value: PSpecValue.find_or_create_by!(value: float.to_s, unit: '"'))
|
||||||
|
|
||||||
|
when "capacite"
|
||||||
|
unit = value.match(/\D+/)
|
||||||
|
num = value.match(/\d+/)
|
||||||
|
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Stockage"), p_spec_value: PSpecValue.find_or_create_by!(value: num.to_s, unit: unit.to_s))
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => spec)
|
||||||
|
when "infos_supp"
|
||||||
|
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Autre"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => spec)
|
||||||
|
when "reference_fabricant"
|
||||||
|
ref.manufacturer_ref = value if !value.blank?
|
||||||
|
when "etat"
|
||||||
|
ref.used_state = value if !value.blank?
|
||||||
|
when "code_hs"
|
||||||
|
ref.i_code_hs = value if !value.blank?
|
||||||
|
when "indice_reparabilite"
|
||||||
|
ref.prepair_score = value if !value.blank?
|
||||||
|
when "duree_dispo_pces_detachees"
|
||||||
|
ref.part_delay = value if !value.blank?
|
||||||
|
when "das_tete"
|
||||||
|
ref.das_head = value if !value.blank?
|
||||||
|
when "das_corps"
|
||||||
|
ref.das_body = value if !value.blank?
|
||||||
|
when "das_membre"
|
||||||
|
ref.das_membre = value if !value.blank?
|
||||||
|
when "poids"
|
||||||
|
ref.weight = value if !value.blank?
|
||||||
|
when "nb_pcs_colis"
|
||||||
|
ref.nb_pcs_colis = value if !value.blank?
|
||||||
|
when "code_om"
|
||||||
|
ref.code_om = value if !value.blank?
|
||||||
|
when "gbh_code_971"
|
||||||
|
ref.gbh_code_971 = value if !value.blank?
|
||||||
|
when "gbh_code_972"
|
||||||
|
ref.gbh_code_972 = value if !value.blank?
|
||||||
|
when "gbh_code_973"
|
||||||
|
ref.gbh_code_973 = value if !value.blank?
|
||||||
|
when "code_art"
|
||||||
|
ref.code_art = value if !value.blank?
|
||||||
|
when "sorecop"
|
||||||
|
ref.p_product.sorecop_cat = SorecopCat.find_by(name: soreco_cat_hash[row["famille"]])
|
||||||
|
if ref.sorecop.kind_of?(String)
|
||||||
|
ref.ct_sorecop = value if !value.blank?
|
||||||
|
end
|
||||||
|
when "pmp_hors_sorecop"
|
||||||
|
ref.i_pmp_hors_sorecop = value if !value.blank?
|
||||||
|
when "target_hors_sorecop"
|
||||||
|
ref.i_target_hors_sorecop = value if !value.blank?
|
||||||
|
when "frs"
|
||||||
|
ref.p_fournisseur_id = PFournisseur.find_or_create_by!(name: value).id
|
||||||
|
when "spec"
|
||||||
|
spec = PProductRefSpec.create!(p_product_ref: ref, p_spec_type: PSpecType.find_by(name: "Version ROM"), p_spec_value: PSpecValue.find_or_create_by!(value: value))
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => spec)
|
||||||
|
when "commentaires"
|
||||||
|
ref.i_comment = value if !value.blank?
|
||||||
|
|
||||||
|
# champs ignorés
|
||||||
|
when "date"
|
||||||
|
# colonne vide
|
||||||
|
when "dtl_targ"
|
||||||
|
when "dtl"
|
||||||
|
when "com"
|
||||||
|
else
|
||||||
|
eval "n.#{key} = value"
|
||||||
|
end
|
||||||
|
# if self.type_for_attribute(key) and self.type_for_attribute(key).type == :decimal
|
||||||
|
# eval "n.#{key} = value.to_s.gsub(' ', '').gsub(',', '.')"
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
n.save!
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => ref)
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => n)
|
||||||
|
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap n
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.ref §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap ref
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.contacts §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap n.p_contacts
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.particulars §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap n.particulars
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.p_customer_ribs §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap n.p_customer_ribs
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ n.p_commercial §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap n.p_commercial
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
# ap "§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§"
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
class PProductRef < ApplicationRecord
|
class PProductRef < ApplicationRecord
|
||||||
belongs_to :p_product
|
|
||||||
|
|
||||||
|
belongs_to :p_product
|
||||||
|
belongs_to :sorecop_cat
|
||||||
|
has_many :sorecop_taxes, through: :sorecop_cat
|
||||||
|
has_one :s_brand, through: :p_product
|
||||||
has_many :p_customer_cats, :through => :p_product
|
has_many :p_customer_cats, :through => :p_product
|
||||||
|
|
||||||
has_many :p_product_features
|
has_many :p_product_features
|
||||||
@ -10,18 +13,21 @@ class PProductRef < ApplicationRecord
|
|||||||
|
|
||||||
belongs_to :p_product_color
|
belongs_to :p_product_color
|
||||||
|
|
||||||
|
has_many :line_stocks
|
||||||
|
|
||||||
has_many :p_articles
|
has_many :p_articles
|
||||||
has_many :p_article_serial_nums, through: :p_articles
|
has_many :p_article_serial_nums, through: :p_articles
|
||||||
accepts_nested_attributes_for :p_article_serial_nums, allow_destroy: true
|
accepts_nested_attributes_for :p_article_serial_nums, allow_destroy: true
|
||||||
|
|
||||||
has_many :p_product_ref_specs
|
has_many :p_product_ref_specs, dependent: :destroy
|
||||||
accepts_nested_attributes_for :p_product_ref_specs, allow_destroy: true
|
accepts_nested_attributes_for :p_product_ref_specs, allow_destroy: true, reject_if: :all_blank
|
||||||
|
|
||||||
#validates :ct_price_ht, :presence => true
|
#validates :ct_price_ht, :presence => true
|
||||||
validate :ean, :is_integer
|
validate :ean, :is_integer
|
||||||
|
|
||||||
has_many :p_customer_product_prices, :dependent => :destroy
|
has_many :p_customer_product_prices, :dependent => :destroy
|
||||||
accepts_nested_attributes_for :p_customer_product_prices, allow_destroy: true
|
accepts_nested_attributes_for :p_customer_product_prices, allow_destroy: true
|
||||||
|
has_many :p_fournisseur_refs
|
||||||
|
|
||||||
scope :enableds, -> {where(:enabled => true)}
|
scope :enableds, -> {where(:enabled => true)}
|
||||||
|
|
||||||
@ -37,20 +43,44 @@ class PProductRef < ApplicationRecord
|
|||||||
|
|
||||||
acts_as_sorting :fields => {
|
acts_as_sorting :fields => {
|
||||||
:id => {:name => "Id", :reorder => true},
|
:id => {:name => "Id", :reorder => true},
|
||||||
:p_product_cat => {:name => "Catégorie", :reorder => true},
|
:p_product_cat => {:name => "Catégorie", :reorder => true, :sort_name => "cc_p_product_cat_id",},
|
||||||
:ref => {:name => "Référence"},
|
:ref => {:name => "Référence"},
|
||||||
:cc_name => {:name => "Produit"},
|
# :cc_name => {:name => "Produit"},
|
||||||
:description => {:name => "Description"},
|
# :description => {:name => "Description"},
|
||||||
:ct_sub_name => {:name => "Nom référence"},
|
:cc_name => {:name => "Nom référence"},
|
||||||
:ct_price_ht => {:name => "Prix de vente", :as => :currency},
|
:ct_price_ht => {:name => "Prix de vente", :as => :currency},
|
||||||
:ean => {:name => "EAN"},
|
:ean => {:name => "EAN"},
|
||||||
:ca_deee => {:name => "DEEE", :as => :currency},
|
:deee => {:name => "DEEE", :as => :currency},
|
||||||
:ca_sorecop => {:name => "Sorecop", :as => :currency},
|
:sorecop => {:name => "Sorecop", :as => :currency},
|
||||||
:sorecop_comment => {:name => "Type de Sorecop"},
|
:sorecop_comment => {:name => "Commentaire Sorecop"},
|
||||||
:actions => {:name => "Actions", :reorder => false}
|
:actions => {:name => "Actions", :reorder => false}
|
||||||
}
|
}
|
||||||
|
|
||||||
acts_as_caching :fields => [:sorecop, :deee]
|
acts_as_caching :fields => [:sorecop, :deee, :name, :code, :p_product_cat_id]
|
||||||
|
include PgSearch::Model
|
||||||
|
pg_search_scope :global_search,
|
||||||
|
against: [:ref, :cc_name],
|
||||||
|
associated_against: {
|
||||||
|
s_brand: [ :code, :name ],
|
||||||
|
p_product: [:code],
|
||||||
|
p_product_color: [:name, :color]
|
||||||
|
},
|
||||||
|
using: {
|
||||||
|
tsearch: { prefix: true }
|
||||||
|
}
|
||||||
|
|
||||||
|
attr_accessor :price_line_id
|
||||||
|
|
||||||
|
after_create do
|
||||||
|
if self.price_line_id
|
||||||
|
pl = PriceLine.find(self.price_line_id)
|
||||||
|
pl.update(p_product_ref: self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
after_save do
|
||||||
|
PProduct.destroy_temp_p_product
|
||||||
|
end
|
||||||
|
|
||||||
def not_imported?
|
def not_imported?
|
||||||
if !self.p_product or !self.p_product.imported
|
if !self.p_product or !self.p_product.imported
|
||||||
@ -74,9 +104,35 @@ class PProductRef < ApplicationRecord
|
|||||||
|
|
||||||
|
|
||||||
def ca_name
|
def ca_name
|
||||||
if self.p_product
|
storage = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Stockage")).first
|
||||||
self.p_product.name + " - " + self.ct_sub_name
|
cellular = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Connectivité")).first
|
||||||
end
|
screen = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Résolution")).first
|
||||||
|
power = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Puissance éléctrique")).first
|
||||||
|
geoloc = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Géolocalisation")).first
|
||||||
|
sim = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Sim")).first
|
||||||
|
size = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Taille")).first
|
||||||
|
version = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by(name: "Version ROM")).first
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
arr = []
|
||||||
|
arr << self.p_product.name if self.p_product
|
||||||
|
arr << self.ct_sub_name
|
||||||
|
arr << storage.p_spec_value.member_label if storage
|
||||||
|
arr << cellular.p_spec_value.member_label if cellular
|
||||||
|
arr << screen.p_spec_value.member_label if screen
|
||||||
|
arr << power.p_spec_value.member_label if power
|
||||||
|
arr << geoloc.p_spec_value.member_label if geoloc
|
||||||
|
arr << sim.p_spec_value.member_label if sim
|
||||||
|
arr << size.p_spec_value.member_label if size
|
||||||
|
arr << version.p_spec_value.member_label if version
|
||||||
|
arr << self.p_product_color.name if p_product_color
|
||||||
|
|
||||||
|
arr.compact.each{|el| el.strip!}.join(' ')
|
||||||
|
# if self.p_product
|
||||||
|
# self.p_product.name + " - " + self.ct_sub_name
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
def ca_code
|
def ca_code
|
||||||
@ -87,11 +143,11 @@ class PProductRef < ApplicationRecord
|
|||||||
self.p_product.p_product_cat_id
|
self.p_product.p_product_cat_id
|
||||||
end
|
end
|
||||||
|
|
||||||
QI_DYNAMICS = %w(name code p_product_cat_id sub_cat_names cat_name)
|
# QI_DYNAMICS = %w(name code p_product_cat_id sub_cat_names cat_name)
|
||||||
|
|
||||||
eval(QI_DYNAMICS_CORE)
|
# eval(QI_DYNAMICS_CORE)
|
||||||
|
|
||||||
before_validation :qi_dynamics_cache
|
# before_validation :qi_dynamics_cache
|
||||||
|
|
||||||
def get_price(options)
|
def get_price(options)
|
||||||
p_customer = PCustomer.find(options[:p_customer_id]) if options[:p_customer_id]
|
p_customer = PCustomer.find(options[:p_customer_id]) if options[:p_customer_id]
|
||||||
@ -150,22 +206,48 @@ class PProductRef < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def member_label
|
def member_label
|
||||||
"#{self.ref} | #{self.p_product.name} - #{self.ct_sub_name} - #{self.p_product_color.name if self.p_product_color} | #{self.cat_name}"
|
"#{self.ref} | #{self.cc_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def ca_sorecop
|
def ca_sorecop
|
||||||
if self.cc_sorecop
|
return ct_sorecop if ct_sorecop
|
||||||
return self.cc_sorecop
|
return "Pas de catégorie Sorecop" if self.p_product.sorecop_cat.blank?
|
||||||
|
|
||||||
|
# if self.cc_sorecop and self.cc_sorecop > 0.0
|
||||||
|
# return self.cc_sorecop
|
||||||
|
# else
|
||||||
|
find_sorecop_tax
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_sorecop_tax
|
||||||
|
p_product_ref_spec = self.p_product_ref_specs.where(p_spec_type: PSpecType.find_by_name("Stockage")).first
|
||||||
|
return "Pas de stockage" if p_product_ref_spec.blank?
|
||||||
|
|
||||||
|
storage_capacity = p_product_ref_spec.p_spec_value.value.to_f
|
||||||
|
if p_product_ref_spec.p_spec_value.unit.casecmp?("Gb")
|
||||||
|
tax = self.p_product.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity, storage_capacity).first
|
||||||
|
elsif p_product_ref_spec.p_spec_value.unit.casecmp?("Tb")
|
||||||
|
tax = self.p_product.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity * 1000, storage_capacity * 1000).first
|
||||||
|
elsif p_product_ref_spec.p_spec_value.unit.casecmp?("Mb")
|
||||||
|
tax = self.p_product.sorecop_cat.sorecop_taxes.where('critere_min < ? AND critere_max >= ?', storage_capacity / 1000, storage_capacity / 1000).first
|
||||||
|
end
|
||||||
|
|
||||||
|
if tax.fixed_price
|
||||||
|
tax.price
|
||||||
else
|
else
|
||||||
"TODO Calcul sorecop"
|
tax.price * storage_capacity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def ca_deee
|
def ca_deee
|
||||||
|
if ct_deee
|
||||||
|
return ct_deee
|
||||||
|
end
|
||||||
if self.cc_deee
|
if self.cc_deee
|
||||||
return self.cc_deee
|
return self.cc_deee
|
||||||
else
|
else
|
||||||
"TODO Calcul DEEE"
|
"DEEE à renseigner"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ class PProductRefSpec < ApplicationRecord
|
|||||||
|
|
||||||
accepts_nested_attributes_for :p_spec_type, :p_spec_value
|
accepts_nested_attributes_for :p_spec_type, :p_spec_value
|
||||||
|
|
||||||
|
validates :p_spec_type_id, :p_spec_value_id, presence: true
|
||||||
|
|
||||||
acts_as_sorting :fields => {
|
acts_as_sorting :fields => {
|
||||||
:id => {:name => "ID"},
|
:id => {:name => "ID"},
|
||||||
:p_product_ref => {:name => "Référence produit", :reorder => true},
|
:p_product_ref => {:name => "Référence produit", :reorder => true},
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
class PSerialNumValue < ApplicationRecord
|
class PSerialNumValue < ApplicationRecord
|
||||||
|
# USELESS MODEL : VALUES A ON p_article_serial_nums TABLE
|
||||||
has_many :p_article_serial_nums, inverse_of: :p_serial_num_value
|
has_many :p_article_serial_nums, inverse_of: :p_serial_num_value
|
||||||
has_many :p_articles, through: :p_article_serial_nums
|
has_many :p_articles, through: :p_article_serial_nums
|
||||||
end
|
end
|
||||||
|
@ -172,7 +172,7 @@ class PSheetLine < ApplicationRecord
|
|||||||
|
|
||||||
def stock_is_ok
|
def stock_is_ok
|
||||||
if !self.stock_done
|
if !self.stock_done
|
||||||
if self.brut_product_needs_ok.size == self.p_sheet_line_stocks.group(:p_brut_product_id).length
|
if self.brut_product_needs_ok.size == self.p_sheet_line_stocks.select(:p_brut_product_id).group(:p_brut_product_id).length
|
||||||
|
|
||||||
self.stock_done = true
|
self.stock_done = true
|
||||||
self.save
|
self.save
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
class PSpecType < ApplicationRecord
|
class PSpecType < ApplicationRecord
|
||||||
has_many :p_product_ref_specs
|
has_many :p_product_ref_specs
|
||||||
TYPES = ["Ram", "Stockage"]
|
|
||||||
|
TYPES = self.distinct.pluck(:name)
|
||||||
|
|
||||||
acts_as_sorting :fields => {
|
acts_as_sorting :fields => {
|
||||||
:id => {:name => "ID"},
|
:id => {:name => "ID"},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
class PSpecValue < ApplicationRecord
|
class PSpecValue < ApplicationRecord
|
||||||
has_many :p_product_ref_specs
|
has_many :p_product_ref_specs
|
||||||
|
|
||||||
UNITS = ["Go", "Mo"]
|
UNITS = self.distinct.pluck(:unit)
|
||||||
|
|
||||||
def member_label
|
def member_label
|
||||||
"#{value} #{unit}"
|
"#{value} #{unit}"
|
||||||
|
@ -31,6 +31,7 @@ class PriceDocument < ApplicationRecord
|
|||||||
AVANCEMENT = ["0%", "25%", "50%", "75%", "100"]
|
AVANCEMENT = ["0%", "25%", "50%", "75%", "100"]
|
||||||
|
|
||||||
validates :public_fournisseur_name, :presence => true, :if => :public_fournisseur_name_needed?
|
validates :public_fournisseur_name, :presence => true, :if => :public_fournisseur_name_needed?
|
||||||
|
acts_as_csv_import :fields => [:p_fournisseur_id, :p_fournisseur_name, :p_fournisseur_ref_ref, :p_fournisseur_ref_label, :p_product_ref_name, :price_line_qte, :date, :price_line_ct_u_price_ht, :p_devise ]
|
||||||
|
|
||||||
def public_fournisseur_name_needed?
|
def public_fournisseur_name_needed?
|
||||||
if self.label == "Réponse fournisseur"
|
if self.label == "Réponse fournisseur"
|
||||||
@ -707,6 +708,58 @@ class PriceDocument < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def self.custom_csv_import(list, import_csv)
|
||||||
|
|
||||||
|
list.each do |row|
|
||||||
|
p_product_ref = nil
|
||||||
|
|
||||||
|
p_devise = PDevise.find_by(symbol: row["p_devise"])
|
||||||
|
|
||||||
|
p_fournisseur = PFournisseur.find_by(id: row["p_fournisseur_id"])
|
||||||
|
|
||||||
|
if row["p_fournisseur_id"].nil?
|
||||||
|
p_fournisseur = PFournisseur.find_by(name: row["p_fournisseur_name"])
|
||||||
|
end
|
||||||
|
|
||||||
|
if p_fournisseur.nil?
|
||||||
|
# TODO : envoyer une alerte sans bloquer l'import.
|
||||||
|
# idée ? creer une priceline vide => pour la retrouver dans les ref à matcher.
|
||||||
|
end
|
||||||
|
|
||||||
|
n = self.find_or_initialize_by(price_document_type: PriceDocumentType.find_by_label("Catalogue fournisseur"), p_fournisseur: p_fournisseur, date: row["date"], p_devise: p_devise )
|
||||||
|
if n.price_line_block.nil?
|
||||||
|
n.price_line_block = PriceLineBlock.new(p_devise: p_devise, p_fournisseur: p_fournisseur, imported: true)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if row["p_fournisseur_ref_ref"].present?
|
||||||
|
p_fournisseur_ref = PFournisseurRef.find_by(p_fournisseur: p_fournisseur, ref: row["p_fournisseur_ref_ref"])
|
||||||
|
p_product_ref = p_fournisseur_ref.p_product_ref if p_fournisseur_ref
|
||||||
|
else
|
||||||
|
p_fournisseur_ref = PFournisseurRef.find_by(p_fournisseur: p_fournisseur, label: row["p_fournisseur_ref_label"])
|
||||||
|
p_product_ref = p_fournisseur_ref.p_product_ref if p_fournisseur_ref
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if row["price_line_qte"].kind_of? Float
|
||||||
|
qte = row["price_line_qte"]
|
||||||
|
elsif row["price_line_qte"].kind_of? Integer
|
||||||
|
qte = row["price_line_qte"].to_f
|
||||||
|
elsif row["price_line_qte"].kind_of? String
|
||||||
|
qte = row["price_line_qte"].split.map {|x| x[/\d+/]}[0].to_f
|
||||||
|
else
|
||||||
|
qte = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
price_line = PriceLine.new(p_product_ref: p_product_ref, ct_ref: row["p_fournisseur_ref_ref"], ct_title: row["p_fournisseur_ref_label"], price_line_block: n.price_line_block, qte: qte || 0.0, ct_u_price_ht: row["price_line_ct_u_price_ht"], imported: true )
|
||||||
|
price_line.p_product = p_product_ref.p_product if p_product_ref && p_product_ref.p_product
|
||||||
|
n.price_line_block.price_lines << price_line
|
||||||
|
|
||||||
|
|
||||||
|
n.save
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => n)
|
||||||
|
import_csv.import_csv_elements << ImportCsvElement.new(:element => price_line)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,7 @@ class PriceLine < ApplicationRecord
|
|||||||
default_scope { order('position ASC') }
|
default_scope { order('position ASC') }
|
||||||
|
|
||||||
validates :p_product_ref_id, :presence => true, :if => :p_product_ref_needed?
|
validates :p_product_ref_id, :presence => true, :if => :p_product_ref_needed?
|
||||||
|
validates :p_product_id, :presence => true, :if => :p_product_needed?
|
||||||
validates :qte, :presence => true
|
validates :qte, :presence => true
|
||||||
|
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ class PriceLine < ApplicationRecord
|
|||||||
|
|
||||||
has_many :line_stocks
|
has_many :line_stocks
|
||||||
|
|
||||||
|
after_update :memorize_p_fournisseur_ref, if: :p_fournisseur_ref_is_memorizable?
|
||||||
|
|
||||||
acts_as_sorting :fields => {
|
acts_as_sorting :fields => {
|
||||||
:ref => {:name => "Ref", :reorder => true},
|
:ref => {:name => "Ref", :reorder => true},
|
||||||
@ -171,6 +173,12 @@ class PriceLine < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def p_product_needed?
|
||||||
|
if !self.ct_title? and !self.imported
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def personalised_archive
|
def personalised_archive
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -617,6 +625,12 @@ class PriceLine < ApplicationRecord
|
|||||||
return [asap, non_asap]
|
return [asap, non_asap]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def p_fournisseur_ref_is_memorizable?
|
||||||
|
self.p_product_ref.present? && self.imported? && PFournisseurRef.where(p_fournisseur: self.p_fournisseur, ref: self.ct_ref, label: self.ct_title).empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def memorize_p_fournisseur_ref
|
||||||
|
PFournisseurRef.create(p_fournisseur: self.p_fournisseur, p_product_ref: self.p_product_ref, ref: self.ct_ref, label: self.ct_title)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,7 @@ class PriceLineBlock < ApplicationRecord
|
|||||||
|
|
||||||
belongs_to :p_payment_type
|
belongs_to :p_payment_type
|
||||||
|
|
||||||
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"]
|
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", "Catalogue fournisseur"]
|
||||||
|
|
||||||
SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"]
|
SALE_BLOCKS = ["Demande de commande", "Bon de commande", "Devis", "Bon de livraison", "Facture", "Avoir"]
|
||||||
|
|
||||||
|
@ -1,4 +1,26 @@
|
|||||||
class SBrand < ApplicationRecord
|
class SBrand < ApplicationRecord
|
||||||
|
has_many :p_products
|
||||||
|
has_many :p_product_refs, through: :p_products
|
||||||
validates :name, :presence => true, :uniqueness => true
|
validates :name, :presence => true, :uniqueness => true
|
||||||
|
|
||||||
|
before_save do
|
||||||
|
if self.code.blank?
|
||||||
|
generate_code
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def generate_code
|
||||||
|
if self.code.blank?
|
||||||
|
prefix = self.name.slice(0, 4).to_slug.upcase
|
||||||
|
last_number = 1
|
||||||
|
code = prefix + "%02d" % [last_number]
|
||||||
|
|
||||||
|
while self.class.find_by(code: code)
|
||||||
|
last_number += 1
|
||||||
|
code = prefix + "%02d" % [last_number]
|
||||||
|
end
|
||||||
|
self.code = code
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
10
app/models/sorecop_cat.rb
Normal file
10
app/models/sorecop_cat.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
class SorecopCat < ApplicationRecord
|
||||||
|
has_many :p_products
|
||||||
|
has_many :sorecop_taxes, dependent: :destroy
|
||||||
|
|
||||||
|
acts_as_sorting :fields => {
|
||||||
|
:id => {:name => "ID"},
|
||||||
|
:name => {:name => "Catégorie", :reorder => true},
|
||||||
|
:actions => {:name => "Actions", :reorder => true}
|
||||||
|
}
|
||||||
|
end
|
15
app/models/sorecop_tax.rb
Normal file
15
app/models/sorecop_tax.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
class SorecopTax < ApplicationRecord
|
||||||
|
belongs_to :sorecop_cat
|
||||||
|
|
||||||
|
|
||||||
|
acts_as_sorting :fields => {
|
||||||
|
:id => {:name => "ID"},
|
||||||
|
:title => {:name => "Désignation", :reorder => true},
|
||||||
|
:critere_min => {:name => "Critère mini (Go)", :reorder => true},
|
||||||
|
:critere_max => {:name => "Critère maxi (Go)", :reorder => true},
|
||||||
|
:fixed_price => {:name => "Prix forfaitaire", :reorder => true, :format => :boolean},
|
||||||
|
:sorecop_cat => {:name => "Catégorie SORECOP",member_label: :name, :reorder => true, :sort_name => "sorecop_taxes.sorecop_cat_id"},
|
||||||
|
:price => {:name => "Prix", :reorder => false, as: :currency},
|
||||||
|
:actions => {:name => "Actions", :reorder => true}
|
||||||
|
}
|
||||||
|
end
|
@ -203,7 +203,7 @@ class VContact < ApplicationRecord
|
|||||||
|
|
||||||
# Mettre nbr_mvt à 0 pour toutes les cartes actives qui n'ont pas eu de mouvement
|
# Mettre nbr_mvt à 0 pour toutes les cartes actives qui n'ont pas eu de mouvement
|
||||||
|
|
||||||
vc_ids = VolumePeriodique.group(:codemanaginn).map{|a| a.codemanaginn}
|
vc_ids = VolumePeriodique.select(:codemanaginn).group(:codemanaginn).map{|a| a.codemanaginn}
|
||||||
|
|
||||||
|
|
||||||
VContact.where(:enabled => true).where("codemanaginn not in(?)", vc_ids).update_all(:nbr_mvt => 0, :cc_cagnotte => 0, :cc_total => 0, :cc_remise => 0)
|
VContact.where(:enabled => true).where("codemanaginn not in(?)", vc_ids).update_all(:nbr_mvt => 0, :cc_cagnotte => 0, :cc_total => 0, :cc_remise => 0)
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
%th Client
|
%th Client
|
||||||
%th Temps passé
|
%th Temps passé
|
||||||
%th
|
%th
|
||||||
-@timer_watchers.group(:p_customer_id).order("p_customer_id DESC").uniq.each do |twp|
|
-@timer_watchers.select(:p_customer_id).group(:p_customer_id).order("p_customer_id DESC").uniq.each do |twp|
|
||||||
%tbody
|
%tbody
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right
|
.right
|
||||||
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add"
|
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add"
|
||||||
|
= breadcrumb
|
||||||
%h1
|
|
||||||
Tableaux de bord achats
|
|
||||||
|
|
||||||
|
|
||||||
.qi_search_row
|
.qi_search_row
|
||||||
@ -30,7 +28,7 @@
|
|||||||
=ic(:times)
|
=ic(:times)
|
||||||
%td
|
%td
|
||||||
Statut :
|
Statut :
|
||||||
=select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]), class: "custom-select"
|
=select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.select(:state).group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]), class: "custom-select"
|
||||||
|
|
||||||
%td
|
%td
|
||||||
Marque :
|
Marque :
|
||||||
@ -145,7 +143,7 @@
|
|||||||
|
|
||||||
%tbody
|
%tbody
|
||||||
-p_product_id = nil
|
-p_product_id = nil
|
||||||
-@price_lines.where.not(:p_product_ref_id => nil).group(:p_product_ref_id).order("p_product_id ASC").each do |plr|
|
-@price_lines.select("DISTINCT ON (price_lines.p_product_ref_id) price_lines.*").where.not(:p_product_ref_id => nil).order("price_lines.p_product_ref_id, p_product_id ASC").each do |plr|
|
||||||
|
|
||||||
-if p_product_id != plr.p_product_id
|
-if p_product_id != plr.p_product_id
|
||||||
-p_product_id = plr.p_product_id
|
-p_product_id = plr.p_product_id
|
||||||
@ -216,7 +214,7 @@
|
|||||||
|
|
||||||
%tbody.detail
|
%tbody.detail
|
||||||
-ppr_lines.each do |price_line|
|
-ppr_lines.each do |price_line|
|
||||||
%tr
|
%tr{id: "price_line_row_#{price_line.id}"}
|
||||||
- if checkbox
|
- if checkbox
|
||||||
%td
|
%td
|
||||||
=check_box_tag :"price_line_ids[]", price_line.id
|
=check_box_tag :"price_line_ids[]", price_line.id
|
||||||
@ -227,15 +225,28 @@
|
|||||||
%td.col-detail
|
%td.col-detail
|
||||||
=link_to [:admin, price_line.price_line_block.price_lineable] do
|
=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.id
|
||||||
=price_line.price_line_block.price_lineable.past_id
|
=#price_line.price_line_block.price_lineable.past_id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%td.col-detail
|
%td.col-detail
|
||||||
=link_to price_line.p_customer.show_name, [:admin, price_line.p_customer]
|
=#link_to price_line.p_customer.show_name, [:admin, price_line.p_customer]
|
||||||
|
|
||||||
%td
|
%td
|
||||||
=state_helper price_line.price_line_block.price_lineable.state
|
-@p_customer_sheet = price_line.price_line_block.price_lineable
|
||||||
|
.dropdown
|
||||||
|
%button.btn.btn-default.dropdown-toggle{"aria-expanded" => "true", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
|
||||||
|
%span.span_cat{'class' => "p_customer_sheet_#{@p_customer_sheet.id}"}
|
||||||
|
=#@p_customer_sheet.state
|
||||||
|
=state_helper @p_customer_sheet.state
|
||||||
|
%span.caret
|
||||||
|
%ul.dropdown-menu{"aria-labelledby" => "dropdownMenu1"}
|
||||||
|
-PCustomerSheet::STATES.each do |state|
|
||||||
|
%li
|
||||||
|
=link_to admin_p_customer_sheet_path(:id => @p_customer_sheet.id, :p_customer_sheet => {:state => state}), :method => :put, :remote => true, :onclick => "$('.dropdown-toggle').dropdown('hide');$(\".p_customer_sheet_#{@p_customer_sheet.id}\").html($(this).find('span').html());", :class => "dropdown-item" do
|
||||||
|
=ic :check if false
|
||||||
|
%span=state_helper state
|
||||||
|
|
||||||
|
|
||||||
%td
|
%td
|
||||||
=price_line.comment
|
=price_line.comment
|
||||||
@ -246,7 +257,7 @@
|
|||||||
= l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date
|
= l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date
|
||||||
|
|
||||||
%td
|
%td
|
||||||
= l price_line.cc_wish_date, :format => "semaine %V (%Y)"
|
= #l price_line.cc_wish_date, :format => "semaine %V (%Y)"
|
||||||
|
|
||||||
%td
|
%td
|
||||||
=price_line.qte.to_i
|
=price_line.qte.to_i
|
||||||
@ -364,6 +375,7 @@
|
|||||||
checkbox.prop("checked", false)
|
checkbox.prop("checked", false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
$('.plus-all').click()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@
|
|||||||
.check_box_search_index
|
.check_box_search_index
|
||||||
<input type="text" class="check_box_search_input" placeholder="Recherche"></input>
|
<input type="text" class="check_box_search_input" placeholder="Recherche"></input>
|
||||||
.check_box_search_index_inner.clientsCheck
|
.check_box_search_index_inner.clientsCheck
|
||||||
-st = StatLine.group(:p_customer_id).order(:p_customer_name)
|
-st = StatLine.select(:p_customer_id, :p_customer_name).group(:p_customer_id, :p_customer_name).order('stat_lines.p_customer_name')
|
||||||
-if current_admin.p_commercial
|
-if current_admin.p_commercial
|
||||||
-st = st.where(:p_customer_id => current_admin.p_commercial.p_customers.ids)
|
-st = st.where(:p_customer_id => current_admin.p_commercial.p_customers.ids)
|
||||||
-st.all.each do |pdt|
|
-st.all.each do |pdt|
|
||||||
@ -675,6 +675,8 @@
|
|||||||
%span.text-success
|
%span.text-success
|
||||||
%i.mdi.mdi-arrow-bottom-right
|
%i.mdi.mdi-arrow-bottom-right
|
||||||
=number_to_currency(((@periode_tot_weight.to_f != 0.0 ? @periode_avg_price_per_kg = @ca_produits_degrade / @periode_tot_weight : 0.0)), :precision => 2)
|
=number_to_currency(((@periode_tot_weight.to_f != 0.0 ? @periode_avg_price_per_kg = @ca_produits_degrade / @periode_tot_weight : 0.0)), :precision => 2)
|
||||||
|
/ DEBUG POUR AFFICHER LA PAGE SANS DATA
|
||||||
|
- @periode_avg_price_per_kg = 1
|
||||||
="/ Kg"
|
="/ Kg"
|
||||||
ca moyen / kilo
|
ca moyen / kilo
|
||||||
|
|
||||||
@ -748,10 +750,10 @@
|
|||||||
-@tot_clients_inactifs = (@tot_customs - @periode_lines.group(:p_customer_id).map{|p| p.p_customer_id}.uniq)
|
-@tot_clients_inactifs = (@tot_customs - @periode_lines.group(:p_customer_id).map{|p| p.p_customer_id}.uniq)
|
||||||
-@all_customers_rows = @all_customers_rows.where(id: params[:p_customer_ids])
|
-@all_customers_rows = @all_customers_rows.where(id: params[:p_customer_ids])
|
||||||
-else
|
-else
|
||||||
-@tot_clients_inactifs = (@all_customers_rows.ids - (@periode_lines.group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq )
|
-@tot_clients_inactifs = (@all_customers_rows.ids - (@periode_lines.select(:p_customer_id).group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq )
|
||||||
|
|
||||||
|
|
||||||
-@periode_nbr_clients_actifs = (@periode_lines.group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq.length
|
-@periode_nbr_clients_actifs = (@periode_lines.select(:p_customer_id).group(:p_customer_id).map{|a| a.p_customer_id}).reject { |e| e.to_s.empty? }.uniq.length
|
||||||
/ -@clients_inactifs = []
|
/ -@clients_inactifs = []
|
||||||
/ -@periode_nbr_clients_inactifs = params[:p_customer_ids].each do |a|
|
/ -@periode_nbr_clients_inactifs = params[:p_customer_ids].each do |a|
|
||||||
/ -@clients_inactifs << PCustomer.where(id: a, enabled: false)
|
/ -@clients_inactifs << PCustomer.where(id: a, enabled: false)
|
||||||
@ -759,7 +761,7 @@
|
|||||||
/ -@tot_clients_inactifs = (@clients_inactifs.length - @periode_nbr_clients_actifs)
|
/ -@tot_clients_inactifs = (@clients_inactifs.length - @periode_nbr_clients_actifs)
|
||||||
|
|
||||||
%div{:style => "font-size:0.7em;float:right"}
|
%div{:style => "font-size:0.7em;float:right"}
|
||||||
=link_to admin_p_customers_path(:p_customer_ids => (@all_customers_rows.ids - (@periode_lines.group(:p_customer_id).map{|a| a.p_customer_id}).uniq )), :method => :patch do
|
=link_to admin_p_customers_path(:p_customer_ids => (@all_customers_rows.ids - (@periode_lines.select(:p_customer_id).group(:p_customer_id).map{|a| a.p_customer_id}).uniq )), :method => :patch do
|
||||||
=@tot_clients_inactifs.length
|
=@tot_clients_inactifs.length
|
||||||
inactifs
|
inactifs
|
||||||
|
|
||||||
@ -810,7 +812,8 @@
|
|||||||
%span.text-success
|
%span.text-success
|
||||||
%i.mdi.mdi-arrow-bottom-right
|
%i.mdi.mdi-arrow-bottom-right
|
||||||
=number_to_currency((@periode_avg_ca_per_customer = @ca_produits_degrade / @periode_nbr_clients_actifs.to_f), :precision => 0)
|
=number_to_currency((@periode_avg_ca_per_customer = @ca_produits_degrade / @periode_nbr_clients_actifs.to_f), :precision => 0)
|
||||||
|
/ DEBUG POUR AFFICHER LA PAGE SANS DATA
|
||||||
|
-@periode_avg_ca_per_customer = 1
|
||||||
ca moyen / clients
|
ca moyen / clients
|
||||||
|
|
||||||
.mb-0
|
.mb-0
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
= f.input :name, :label => "Nom de l'import :"
|
= f.input :name, :label => "Nom de l'import :"
|
||||||
= f.input :file, :label => "file :"
|
= f.input :file, :label => "file :"
|
||||||
|
|
||||||
= f.input :table_name, :label => "Table :" , :as => :select, :collection => ["order_hist_lines"]
|
= f.input :table_name, :label => "Type d'import :" , :as => :select, :collection => [["Mise à jour catalogue prix","price_document"], ["Base fournisseurs", "p_fournisseur"], ["Base client", "p_customer"], ["Base produit", "p_product"]]
|
||||||
|
|
||||||
-if f.object.id
|
-if f.object.id
|
||||||
%table.import_csv_champs_form
|
%table.import_csv_champs_form
|
||||||
|
109
app/views/admin/import_csvs/_form_temp_p_product.html.haml
Normal file
109
app/views/admin/import_csvs/_form_temp_p_product.html.haml
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
=semantic_form_for [:admin, @p_product_ref], remote: true do |form|
|
||||||
|
=hidden_field_tag :update_price_line_id, @price_line.id
|
||||||
|
.content
|
||||||
|
.qi_row.field
|
||||||
|
.padding
|
||||||
|
|
||||||
|
%h1 Ajouter une référence
|
||||||
|
.card.border.border-primary.mb-3
|
||||||
|
%h5.card-header.border-bottom Rappel des infos fournisseurs
|
||||||
|
%ul.list-group.list-group-flush
|
||||||
|
%li.list-group-item
|
||||||
|
.d-inline-flex
|
||||||
|
%h5{style: "min-width: 80px;"} libellé :
|
||||||
|
%p.card-text=@p_product_ref.description
|
||||||
|
%li.list-group-item
|
||||||
|
.d-inline-flex
|
||||||
|
%h5{style: "min-width: 80px;"} Qté :
|
||||||
|
%p.card-text
|
||||||
|
=@price_line.qte
|
||||||
|
%li.list-group-item
|
||||||
|
.d-inline-flex
|
||||||
|
%h5{style: "min-width: 80px;"} Prix :
|
||||||
|
%p.card-text
|
||||||
|
=number_to_currency @p_product_ref.ct_price_ht
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
%table.form-table
|
||||||
|
%tr
|
||||||
|
%td{colspan: 3}
|
||||||
|
%label Selectionner le produit parent :
|
||||||
|
.input-group
|
||||||
|
%input.p_product_autocomplete_input.form-control{:type => "text", :style => "", tabindex: 1, autofocus: true, :class => "p_product_name"}
|
||||||
|
=form.hidden_field :p_product_id, :class => "p_product_id"
|
||||||
|
|
||||||
|
=link_to ic(:plus)+ " Ajouter produit", new_admin_p_product_path(fournisseur_label: @p_product_ref.description, price_line_id: @price_line.id)
|
||||||
|
%br
|
||||||
|
|
||||||
|
%tr{height: "20px"}
|
||||||
|
-if false
|
||||||
|
%tr
|
||||||
|
%td{:colspan => 3}
|
||||||
|
= form.input :ct_sub_name, :label => "Désignation ARCOM :"
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
= form.input :ref, :label => "Réf int. :"
|
||||||
|
|
||||||
|
%td
|
||||||
|
= form.input :ct_price_ht, :label => "Prix vente € HT:"
|
||||||
|
|
||||||
|
%td
|
||||||
|
=form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true, input_html: {class: "custom-select"}
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
=form.input :ct_sorecop, :label => "Sorecop personalisée (€) :"
|
||||||
|
%td
|
||||||
|
=form.input :sorecop_comment, :label => "Commentaire Sorecop :"
|
||||||
|
%td
|
||||||
|
=form.input :ct_deee, :label => "DEEE personalisée (€):"
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
=form.input :ean
|
||||||
|
|
||||||
|
%td{:colspan => 2}
|
||||||
|
= form.input :description, :label => "Désignation longue :" , :input_html => {rows: 1}
|
||||||
|
|
||||||
|
%tr
|
||||||
|
%td{:colspan => 3}
|
||||||
|
.qi_pannel.qi_plain.padding
|
||||||
|
.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
|
||||||
|
|
||||||
|
.actions=form.submit "sauvegarder", :class => "btn btn-primary"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$('.p_product_autocomplete_input').focus()
|
||||||
|
$( function() {
|
||||||
|
$('.p_product_autocomplete_input').autocomplete({
|
||||||
|
source: function( request, response ) {
|
||||||
|
$.ajax( {
|
||||||
|
url: "/admin/p_products/autocomplete.json",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
search: request.term,
|
||||||
|
},
|
||||||
|
success: function(data){
|
||||||
|
arr = jQuery.map( data, function( item ) {
|
||||||
|
return {
|
||||||
|
label: item.name,
|
||||||
|
value: item.name,
|
||||||
|
id: item.id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
response(arr)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
minLength: 2,
|
||||||
|
select: function( event, ui ) {
|
||||||
|
$(this).next(".p_product_id").val(ui.item.id)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
@ -1,6 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter', new_admin_import_csv_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter', new_admin_import_csv_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
%h1 Import xls
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -12,4 +12,4 @@
|
|||||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @import_csvs}
|
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @import_csvs}
|
||||||
|
|
||||||
|
|
||||||
=debug OrderHistLine.new.class.type_for_attribute("ff")
|
=#debug OrderHistLine.new.class.type_for_attribute("ff")
|
||||||
|
27
app/views/admin/import_csvs/match_refs.html.haml
Normal file
27
app/views/admin/import_csvs/match_refs.html.haml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
:javascript
|
||||||
|
var p_product_refs_url = "#{admin_p_product_refs_path(:manager => true)}"
|
||||||
|
.qi_row
|
||||||
|
%h1 Rapprochement de références produits
|
||||||
|
|
||||||
|
-@price_documents.each do |price_document|
|
||||||
|
%br
|
||||||
|
.qi_pannel.qi_plain.padding.mt-4
|
||||||
|
=semantic_form_for [:admin, price_document] do |f|
|
||||||
|
=f.semantic_fields_for :price_line_block do |f|
|
||||||
|
%h2= "Import catalogue : " + f.object.p_fournisseur.name
|
||||||
|
%div{:style=>"padding:0 30px;"}
|
||||||
|
.row.qi_field_wrapper
|
||||||
|
%table{:style => "width:100%;border-collapse:separate;"}
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th
|
||||||
|
%th Référence Produit Arcom
|
||||||
|
%th Créer une référence
|
||||||
|
%th Libélé fournisseur
|
||||||
|
%th Prix unitaire
|
||||||
|
%th Quantité
|
||||||
|
%tbody.price_lines_form
|
||||||
|
=f.semantic_fields_for :price_lines do |form|
|
||||||
|
-if form.object.p_product_ref.nil?
|
||||||
|
=render :partial => "admin/price_lines/form_match_refs", :locals => {:form => form}
|
||||||
|
=f.submit "Valider", class: "btn btn-primary mt-3"
|
1
app/views/admin/import_csvs/temp_p_product.js.erb
Normal file
1
app/views/admin/import_csvs/temp_p_product.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
show_pane_hover("<%= escape_javascript(render(:partial => "form_temp_p_product"))%>",700,900);
|
@ -4,8 +4,7 @@
|
|||||||
= link_to ic(:minus)+' Sortie de stock', new_admin_stock_movement_path(:movement_type => "deb"), :class => "btn btn-primary bgbd-documents", :remote => true
|
= link_to ic(:minus)+' Sortie de stock', new_admin_stock_movement_path(:movement_type => "deb"), :class => "btn btn-primary bgbd-documents", :remote => true
|
||||||
= link_to ic(:plus)+' Entrée de stock', new_admin_stock_movement_path(:movement_type => "cred"), :class => "btn btn-primary bgbd-documents", :remote => true
|
= link_to ic(:plus)+' Entrée de stock', new_admin_stock_movement_path(:movement_type => "cred"), :class => "btn btn-primary bgbd-documents", :remote => true
|
||||||
|
|
||||||
%h1
|
= breadcrumb
|
||||||
Mouvements de stocks
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_article_serial_num_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_article_serial_num_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
=breadcrumb
|
||||||
=PArticleSerialNum.human rescue ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
%tr#p_article_row{:id => p_article.id}
|
%tr#p_article_row{:id => p_article.id}
|
||||||
-tr = {}
|
-tr = {}
|
||||||
|
|
||||||
-tr[:p_product_ref_code] = capture do
|
-tr[:p_product_ref_ref] = capture do
|
||||||
%td
|
%td
|
||||||
= p_article.p_product_ref.code
|
= p_article.p_product_ref.ref
|
||||||
|
|
||||||
-tr[:p_grade] = capture do
|
-tr[:p_grade] = capture do
|
||||||
%td
|
%td
|
||||||
@ -33,7 +33,7 @@
|
|||||||
%td.actions
|
%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(:"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(:pencil), edit_admin_p_article_path(p_article), :remote => true
|
||||||
= link_to i(:eye), admin_p_article_path(p_article), :remote => true
|
=# link_to i(:eye), admin_p_article_path(p_article), :remote => true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_article_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_article_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
=breadcrumb
|
||||||
=PArticle.human rescue ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -12,19 +11,30 @@
|
|||||||
|
|
||||||
%table
|
%table
|
||||||
%tr
|
%tr
|
||||||
|
%td{style: "min-width: 500px;"}
|
||||||
|
.input-group
|
||||||
|
=text_field_tag "search[global]", params[:search][:global],:class => "form-control", :placeholder => "Marque, modèle, couleur, code, IMEI, SN..."
|
||||||
|
.input-group-append{:onclick => "$(this).prev('input').val('');"}
|
||||||
|
.btn.btn-outline-dark
|
||||||
|
=ic(:times)
|
||||||
|
|
||||||
|
%tr
|
||||||
|
-if false
|
||||||
%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_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_product_ref_cc_name]", params[:search][:p_product_ref_cc_name],:class => "form-control", :placeholder => "Article"
|
||||||
|
|
||||||
%td=text_field_tag "search[p_article_serial_num]", params[:search][:p_article_serial_num],: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"
|
|
||||||
|
|
||||||
%td.pl-2 Couleur :
|
%td.pl-2 Couleur :
|
||||||
%td
|
%td
|
||||||
=select_tag "search[p_product_color]", options_for_select([["",""],["Aucune","null"]]+PProductColor.pluck(:color, :id), params[:search][:p_product_color]),class: "custom-select"
|
=select_tag "search[p_product_color]", options_for_select([["",""],["Aucune","null"]]+PProductColor.pluck(:color, :id), params[:search][:p_product_color]),class: "custom-select"
|
||||||
|
|
||||||
|
-if PGrade::ACTIVATED
|
||||||
|
%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"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_articles}
|
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_articles}
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to 'Ajouter un export', new_admin_p_compta_export_path(), :class => "btn btn-primary", :remote => true
|
.right= link_to 'Ajouter un export', new_admin_p_compta_export_path(), :class => "btn btn-primary", :remote => true
|
||||||
%h1
|
= breadcrumb
|
||||||
Stats
|
|
||||||
%span
|
|
||||||
Exports comptable
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to 'Ajouter une catégorie', new_admin_p_customer_cat_path(), :class => "btn btn-primary", :remote => true
|
.right= link_to 'Ajouter une catégorie', new_admin_p_customer_cat_path(), :class => "btn btn-primary", :remote => true
|
||||||
%h1
|
=breadcrumb
|
||||||
Produits
|
|
||||||
%span
|
|
||||||
Catégories
|
|
||||||
|
|
||||||
|
|
||||||
.qi_row
|
.qi_row
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
%h1
|
= breadcrumb
|
||||||
Ventes
|
|
||||||
%span
|
|
||||||
=link_to "Demandes de commande", admin_p_customer_sheets_path()
|
|
||||||
%span
|
|
||||||
Modifier une demande
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right
|
.right
|
||||||
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add"
|
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add"
|
||||||
%h1
|
= breadcrumb
|
||||||
Ventes
|
|
||||||
%span
|
|
||||||
Demandes de commande
|
|
||||||
|
|
||||||
|
|
||||||
.qi_search_row
|
.qi_search_row
|
||||||
@ -22,7 +19,7 @@
|
|||||||
|
|
||||||
%td
|
%td
|
||||||
Statut :
|
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.select(:state).group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state])
|
||||||
|
|
||||||
%td
|
%td
|
||||||
Numéro d'offre :
|
Numéro d'offre :
|
||||||
|
@ -12,12 +12,7 @@
|
|||||||
= link_to i(:pencil), edit_admin_p_customer_sheet_path(@p_customer_sheet), :remote => false
|
= link_to i(:pencil), edit_admin_p_customer_sheet_path(@p_customer_sheet), :remote => false
|
||||||
|
|
||||||
|
|
||||||
%h1
|
= breadcrumb
|
||||||
Ventes
|
|
||||||
%span
|
|
||||||
=link_to "Demande de commandes",admin_p_customer_sheets_path
|
|
||||||
%span
|
|
||||||
="#{@p_customer_sheet.com_counter}"
|
|
||||||
|
|
||||||
|
|
||||||
.qi_row
|
.qi_row
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
$('#p_customer_sheets_rows').html("<%= escape_javascript(render(@p_customer_sheets))%>");
|
<% if @p_customer_sheets %>
|
||||||
|
$('#p_customer_sheets_rows').html("<%= escape_javascript(render(@p_customer_sheets))%>");
|
||||||
|
<% end %>
|
||||||
close_pane_hover();
|
close_pane_hover();
|
@ -61,6 +61,7 @@
|
|||||||
= form.input :particular_send_id, :collection => form.object.particulars.all, :as => :select, :member_label => :address_line, :include_blank => true, :label => "Adresse de livraison :"
|
= form.input :particular_send_id, :collection => form.object.particulars.all, :as => :select, :member_label => :address_line, :include_blank => true, :label => "Adresse de livraison :"
|
||||||
|
|
||||||
|
|
||||||
|
-if false
|
||||||
=form.input :code, :label => "Code client"
|
=form.input :code, :label => "Code client"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
%h1
|
=breadcrumb record: @p_customer.name
|
||||||
Ventes
|
|
||||||
%span
|
|
||||||
=link_to "Clients", admin_p_customers_path
|
|
||||||
%span
|
|
||||||
Modifier un client
|
|
||||||
|
|
||||||
= render 'form'
|
= render 'form'
|
||||||
|
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
-if current_admin.has_permission?("customers-c")
|
-if current_admin.has_permission?("customers-c")
|
||||||
.right= link_to ic(:plus)+' Ajouter un client', new_admin_p_customer_path(), :class => "btn btn-primary btn-ap-add", :remote => false
|
.right= link_to ic(:plus)+' Ajouter un client', new_admin_p_customer_path(), :class => "btn btn-primary btn-ap-add", :remote => false
|
||||||
|
=breadcrumb
|
||||||
-else
|
-else
|
||||||
.right
|
.right
|
||||||
=link_to "< Retour aux demandes de commande", admin_p_customer_sheets_path
|
=link_to "< Retour aux commandes", admin_p_customer_sheets_path
|
||||||
|
=breadcrumb first_title: "Commandes" , first_link: admin_p_customer_sheets_path ,second_title: "Demande de commande", last_element: 'Selectioner un client', default_crud: false
|
||||||
|
|
||||||
%h1
|
|
||||||
Clients
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
%td
|
%td
|
||||||
Raison de blocage :
|
Raison de blocage :
|
||||||
=select_tag "search[disabled_raison]", options_for_select(PCustomer.group("disabled_raison").map{|p| [p.disabled_raison]}, params[:search][:disabled_raison])
|
=select_tag "search[disabled_raison]", options_for_select(PCustomer.select("disabled_raison").group("disabled_raison").map{|p| [p.disabled_raison]}, params[:search][:disabled_raison])
|
||||||
|
|
||||||
|
|
||||||
-if false
|
-if false
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
%h1
|
=breadcrumb
|
||||||
Ventes
|
|
||||||
%span
|
|
||||||
=link_to "Clients", admin_p_customers_path
|
|
||||||
%span
|
|
||||||
Créer un nouveau client
|
|
||||||
|
|
||||||
= render 'form'
|
= render 'form'
|
||||||
|
|
||||||
|
@ -3,15 +3,7 @@
|
|||||||
= link_to i(:pencil), edit_admin_p_customer_path(@p_customer), :remote => false
|
= link_to i(:pencil), edit_admin_p_customer_path(@p_customer), :remote => false
|
||||||
|
|
||||||
|
|
||||||
|
=breadcrumb record: @p_customer.name
|
||||||
%h1
|
|
||||||
Clients
|
|
||||||
%span
|
|
||||||
Détail d'un client
|
|
||||||
%span
|
|
||||||
=link_to [:admin, @p_customer] do
|
|
||||||
=@p_customer.code
|
|
||||||
=@p_customer.show_name
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
14
app/views/admin/p_fournisseur_refs/_form.html.haml
Normal file
14
app/views/admin/p_fournisseur_refs/_form.html.haml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
=semantic_form_for [:admin, @p_fournisseur_ref], :remote => true do |f|
|
||||||
|
|
||||||
|
.content
|
||||||
|
=f.inputs do
|
||||||
|
= f.input :ref, :label => f.object.label_for(:ref)
|
||||||
|
= f.input :p_product_ref, :label => f.object.label_for(:p_product_ref)
|
||||||
|
= f.input :p_fournisseur, :label => f.object.label_for(:p_fournisseur)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
%tr#p_fournisseur_ref_row{:id => p_fournisseur_ref.id}
|
||||||
|
-tr = {}
|
||||||
|
|
||||||
|
-tr[:actions] = capture do
|
||||||
|
%td.actions
|
||||||
|
= link_to i(:"trash-o"), [:admin, p_fournisseur_ref], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||||
|
= link_to i(:pencil), edit_admin_p_fournisseur_ref_path(p_fournisseur_ref), :remote => true
|
||||||
|
= link_to i(:eye), admin_p_fournisseur_ref_path(p_fournisseur_ref), :remote => true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_fournisseur_ref}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
app/views/admin/p_fournisseur_refs/create.js.erb
Normal file
2
app/views/admin/p_fournisseur_refs/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$('#p_fournisseur_refs_rows').prepend("<%= escape_javascript(render(@p_fournisseur_ref))%>");
|
||||||
|
close_pane_hover();
|
1
app/views/admin/p_fournisseur_refs/destroy.js.erb
Normal file
1
app/views/admin/p_fournisseur_refs/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
$('#p_fournisseur_ref_row_<%= @p_fournisseur_ref.id %>').remove();
|
1
app/views/admin/p_fournisseur_refs/edit.js.erb
Normal file
1
app/views/admin/p_fournisseur_refs/edit.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
16
app/views/admin/p_fournisseur_refs/index.html.haml
Normal file
16
app/views/admin/p_fournisseur_refs/index.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
.qi_header
|
||||||
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_fournisseur_ref_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
|
%h1
|
||||||
|
=PFournisseurRef.human rescue ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.qi_search_row
|
||||||
|
=form_tag "", :method => "get", :onsubmit => "" do
|
||||||
|
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_fournisseur_refs}
|
||||||
|
|
||||||
|
|
||||||
|
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @p_fournisseur_refs}
|
||||||
|
|
||||||
|
|
||||||
|
|
1
app/views/admin/p_fournisseur_refs/new.js.erb
Normal file
1
app/views/admin/p_fournisseur_refs/new.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
10
app/views/admin/p_fournisseur_refs/show.html.haml
Normal file
10
app/views/admin/p_fournisseur_refs/show.html.haml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.qi_header
|
||||||
|
%h1
|
||||||
|
|
||||||
|
%span
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.qi_row
|
||||||
|
.qi_pannel.qi_plain.padding
|
||||||
|
=debug @p_fournisseur_ref
|
2
app/views/admin/p_fournisseur_refs/update.js.erb
Normal file
2
app/views/admin/p_fournisseur_refs/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$('#p_fournisseur_ref_row_<%= @p_fournisseur_ref.id %>').replaceWith("<%= escape_javascript(render(@p_fournisseur_ref))%>");
|
||||||
|
close_pane_hover();
|
@ -1,7 +1,8 @@
|
|||||||
-@import= true
|
-if false
|
||||||
|
-@import= true
|
||||||
|
|
||||||
-i = 0
|
-i = 0
|
||||||
-@csv.each do |csv|
|
-@csv.each do |csv|
|
||||||
-i += 1
|
-i += 1
|
||||||
|
|
||||||
=csv["code"]
|
=csv["code"]
|
||||||
|
@ -2,10 +2,7 @@
|
|||||||
.right
|
.right
|
||||||
= link_to 'Ajouter un fournisseur', new_admin_p_fournisseur_path(), :class => "btn btn-primary", :remote => true
|
= link_to 'Ajouter un fournisseur', new_admin_p_fournisseur_path(), :class => "btn btn-primary", :remote => true
|
||||||
|
|
||||||
%h1
|
=breadcrumb
|
||||||
Achats
|
|
||||||
%span
|
|
||||||
Fournisseurs
|
|
||||||
|
|
||||||
|
|
||||||
.qi_row
|
.qi_row
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to 'Ajouter un type de paiement', new_admin_p_payment_type_path(), :class => "btn btn-primary", :remote => true
|
.right= link_to 'Ajouter un type de paiement', new_admin_p_payment_type_path(), :class => "btn btn-primary", :remote => true
|
||||||
%h1
|
= breadcrumb
|
||||||
Paiements
|
|
||||||
%span
|
|
||||||
Types de paiement
|
|
||||||
|
|
||||||
|
|
||||||
.qi_row
|
.qi_row
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter un paiement', new_admin_p_payment_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter un paiement', new_admin_p_payment_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
= breadcrumb
|
||||||
Paiements
|
|
||||||
%span
|
|
||||||
Liste des paiements
|
|
||||||
|
|
||||||
.qi_search_row
|
.qi_search_row
|
||||||
=form_tag "", :method => "get", :onsubmit => "" do
|
=form_tag "", :method => "get", :onsubmit => "" do
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to 'Ajouter une catégorie', new_admin_p_product_cat_path(), :class => "btn btn-primary", :remote => true
|
.right= link_to 'Ajouter une catégorie', new_admin_p_product_cat_path(), :class => "btn btn-primary", :remote => true
|
||||||
%h1
|
=breadcrumb
|
||||||
Achats
|
|
||||||
%span
|
|
||||||
Catégories produit
|
|
||||||
|
|
||||||
|
|
||||||
.qi_row
|
.qi_row
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_color_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_color_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
=breadcrumb
|
||||||
=PProductColor.human
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_power_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_power_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
= breadcrumb
|
||||||
=PProductPower.human rescue ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,15 +15,15 @@
|
|||||||
%table
|
%table
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%h4 spec :
|
%h4 Specs :
|
||||||
|
%tr
|
||||||
%td
|
%td
|
||||||
-#form.object.p_spec_type = PSpecType.new if !form.object.p_spec_type
|
-#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_value = PSpecValue.new if !form.object.p_spec_value
|
||||||
|
|
||||||
= form.input :p_spec_type_id, :label => "Type", as: :select, collection: PSpecType.all, :include_blank => false
|
= form.input :p_spec_type_id, :label => "Type", as: :select, collection: PSpecType.all, :include_blank => true,input_html: {class: "custom-select"}
|
||||||
%td
|
%td
|
||||||
= form.input :p_spec_value_id, :label => "Valeur", as: :select, collection: PSpecValue.all, :include_blank => false, :member_label => :member_label
|
= form.input :p_spec_value_id, :label => "Valeur", as: :select, collection: PSpecValue.all, :include_blank => true, :member_label => :member_label, input_html: {class: "custom-select"}
|
||||||
|
|
||||||
|
|
||||||
=#form.inputs do
|
=#form.inputs do
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_ref_spec_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_ref_spec_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
= breadcrumb
|
||||||
=PProductRefSpec.human rescue ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
=#debug form.object.errors.messages
|
=#debug form.object.errors.messages
|
||||||
=# form.input :ref, :label => "Ref :"
|
=# form.input :ref, :label => "Ref :"
|
||||||
.qi_row.field
|
.qi_row.field{id: dom_id(form.object)}
|
||||||
.qi_pannel.qi_plain.padding
|
.qi_pannel.qi_plain.padding
|
||||||
|
|
||||||
%table.form-table
|
%table.form-table
|
||||||
@ -11,6 +11,8 @@
|
|||||||
%td
|
%td
|
||||||
= form.input :ref, :label => "Réf int. :"
|
= form.input :ref, :label => "Réf int. :"
|
||||||
=#form.hidden_field :ref_id
|
=#form.hidden_field :ref_id
|
||||||
|
-if @price_line
|
||||||
|
=form.hidden_field :price_line_id, value: @price_line.id
|
||||||
|
|
||||||
%td
|
%td
|
||||||
= form.input :ct_sub_name, :label => "Désignation :"
|
= form.input :ct_sub_name, :label => "Désignation :"
|
||||||
@ -19,15 +21,16 @@
|
|||||||
= form.input :ct_price_ht, :label => "Prix vente HT :"
|
= form.input :ct_price_ht, :label => "Prix vente HT :"
|
||||||
|
|
||||||
%td
|
%td
|
||||||
=form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true
|
=form.input :p_product_color_id, :label => "Couleur :", :collection => PProductColor.all, :as => :select, :include_blank => true, input_html: {class: "custom-select"}
|
||||||
|
%td
|
||||||
|
=form.input :ean
|
||||||
|
%tr
|
||||||
%td
|
%td
|
||||||
=form.input :ct_sorecop, :label => "Sorecop personalisée :"
|
=form.input :ct_sorecop, :label => "Sorecop personalisée :"
|
||||||
%td
|
%td
|
||||||
=form.input :sorecop_comment, :label => "Type de Sorecop :"
|
=form.input :sorecop_comment, :label => "Commentaire de Sorecop :"
|
||||||
%td
|
%td
|
||||||
=form.input :ct_deee, :label => "DEEE personalisée :"
|
=form.input :ct_deee, :label => "DEEE personalisée :"
|
||||||
%td
|
|
||||||
=form.input :ean
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +47,7 @@
|
|||||||
%tr
|
%tr
|
||||||
%td{:colspan => 2}
|
%td{:colspan => 2}
|
||||||
%td{:colspan => 4}
|
%td{:colspan => 4}
|
||||||
= form.input :description, :label => "Désignation longue :" , :input_html => {:style => "height:100px;"}
|
= form.input :description, :label => "Désignation longue :" , :input_html => {rows: 1}
|
||||||
|
|
||||||
-if false
|
-if false
|
||||||
%tr
|
%tr
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
= 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;"
|
= 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
|
-else
|
||||||
= link_to i(:pencil), edit_admin_p_product_path(p_product_ref.p_product), :remote => false
|
= link_to i(:pencil), edit_admin_p_product_path(p_product_ref.p_product, anchor: dom_id(p_product_ref)), :remote => false
|
||||||
= link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false
|
= link_to i(:eye), admin_p_product_ref_path(p_product_ref), :remote => false
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
-if !@manager
|
-if !@manager
|
||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false
|
.right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false
|
||||||
%h1
|
=breadcrumb
|
||||||
Achats
|
|
||||||
%span
|
|
||||||
Références
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -16,28 +13,42 @@
|
|||||||
=hidden_field_tag :manager, params[:manager]
|
=hidden_field_tag :manager, params[:manager]
|
||||||
%table
|
%table
|
||||||
%tr
|
%tr
|
||||||
%td
|
|
||||||
Actif :
|
|
||||||
=select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled])
|
|
||||||
|
|
||||||
|
%td{style: "min-width: 500px;"}
|
||||||
|
.input-group
|
||||||
|
=text_field_tag "search[global]", params[:search][:global],:class => "form-control", :placeholder => "Marque, modèle, couleur, code..."
|
||||||
|
.input-group-append{:onclick => "$(this).prev('input').val('');"}
|
||||||
|
.btn.btn-outline-dark
|
||||||
|
=ic(:times)
|
||||||
|
|
||||||
|
%table
|
||||||
|
%tr
|
||||||
|
-if false
|
||||||
%td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code"
|
%td=text_field_tag "search[code]", params[:search][:code],:class => "form-control", :placeholder => "Code"
|
||||||
|
|
||||||
%td=text_field_tag "search[fournisseur_ref]", params[:search][:fournisseur_ref],:class => "form-control", :placeholder => "Code fournisseur"
|
%td=text_field_tag "search[fournisseur_ref]", params[:search][:fournisseur_ref],:class => "form-control", :placeholder => "Code fournisseur"
|
||||||
|
|
||||||
|
%td
|
||||||
%td=text_field_tag "search[name]", params[:search][:name],:class => "form-control", :placeholder => "Nom"
|
Actif :
|
||||||
|
%td
|
||||||
%table
|
=select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled]), class: "custom-select"
|
||||||
%tr
|
|
||||||
%td
|
%td
|
||||||
Catégorie :
|
Catégorie :
|
||||||
=select_tag "search[p_product_ref_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_ref_cat_id])
|
%td
|
||||||
|
.input-group
|
||||||
|
=select_tag "search[p_product_ref_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_ref_cat_id]), class: "custom-select"
|
||||||
|
.input-group-append{:onclick => "$(this).prev('select').val('').prop('selectedIndex',0);"}
|
||||||
|
.btn.btn-outline-dark
|
||||||
|
=ic(:times)
|
||||||
|
|
||||||
%td
|
%td
|
||||||
Marque :
|
Marque :
|
||||||
=select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id])
|
%td
|
||||||
|
.input-group
|
||||||
|
=select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id]), class: "custom-select"
|
||||||
|
.input-group-append{:onclick => "$(this).prev('select').val('').prop('selectedIndex',0);"}
|
||||||
|
.btn.btn-outline-dark
|
||||||
|
=ic(:times)
|
||||||
|
|
||||||
|
|
||||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_product_refs}
|
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_product_refs}
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right
|
.right
|
||||||
= link_to i(:pencil), edit_admin_p_product_path(@p_product_ref.p_product), :remote => false if @p_product_ref.p_product
|
= link_to i(:pencil), edit_admin_p_product_path(@p_product_ref.p_product), :remote => false if @p_product_ref.p_product
|
||||||
%h1
|
=breadcrumb record: @p_product_ref.p_product.name + " - " + @p_product_ref.ct_sub_name
|
||||||
Références produits
|
|
||||||
%span
|
|
||||||
Détail d'une référence
|
|
||||||
|
|
||||||
%span
|
|
||||||
=@p_product_ref.p_product.name
|
|
||||||
="-"
|
|
||||||
=@p_product_ref.ct_sub_name
|
|
||||||
|
|
||||||
|
|
||||||
.qi_row
|
.qi_row
|
||||||
@ -19,7 +11,7 @@
|
|||||||
%tr
|
%tr
|
||||||
%td Produit
|
%td Produit
|
||||||
%td=@p_product_ref.p_product.name #link_to @p_product_ref.p_product.name, [:admin, @p_product_ref.p_product]
|
%td=@p_product_ref.p_product.name #link_to @p_product_ref.p_product.name, [:admin, @p_product_ref.p_product]
|
||||||
|
-if false
|
||||||
%tr
|
%tr
|
||||||
%td Actif ?
|
%td Actif ?
|
||||||
%td=@p_product_ref.enabled ? "Oui" : "Non"
|
%td=@p_product_ref.enabled ? "Oui" : "Non"
|
||||||
@ -29,28 +21,14 @@
|
|||||||
%td Référence assemblée ?
|
%td Référence assemblée ?
|
||||||
%td=@p_product_ref.assembled ? "Oui" : "Non"
|
%td=@p_product_ref.assembled ? "Oui" : "Non"
|
||||||
|
|
||||||
%tr
|
|
||||||
%td Référence interne :
|
|
||||||
%td=@p_product_ref.ref
|
|
||||||
|
|
||||||
%tr
|
|
||||||
%td Désignation variante :
|
|
||||||
%td=@p_product_ref.ct_sub_name
|
|
||||||
|
|
||||||
%tr
|
|
||||||
%td Prix de vente :
|
|
||||||
%td=number_to_currency @p_product_ref.ct_price_ht
|
|
||||||
|
|
||||||
%tr
|
|
||||||
%td Unité de vente (archive) :
|
|
||||||
%td= @p_product_ref.uv
|
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%td Conditionnement de référence :
|
%td Conditionnement de référence :
|
||||||
%td
|
%td
|
||||||
-if @p_product_ref.p_product and @p_product_ref.p_product.p_product_conditioning
|
-if @p_product_ref.p_product and @p_product_ref.p_product.p_product_conditioning
|
||||||
= @p_product_ref.p_product.p_product_conditioning.name
|
= @p_product_ref.p_product.p_product_conditioning.name
|
||||||
|
%tr
|
||||||
|
%td Unité de vente (archive) :
|
||||||
|
%td= @p_product_ref.uv
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%td Conditionnement :
|
%td Conditionnement :
|
||||||
@ -58,20 +36,36 @@
|
|||||||
-if @p_product_ref.p_product_conditioning
|
-if @p_product_ref.p_product_conditioning
|
||||||
= @p_product_ref.p_product_conditioning.name
|
= @p_product_ref.p_product_conditioning.name
|
||||||
|
|
||||||
%tr
|
|
||||||
%td Quantité par rapport au conditionnement de référence :
|
|
||||||
%td
|
|
||||||
= @p_product_ref.conditioning_ref_qte
|
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%td Prix de vente à l'unité de référence
|
%td Prix de vente à l'unité de référence
|
||||||
%td
|
%td
|
||||||
=number_to_currency( @p_product_ref.ct_price_ht / @p_product_ref.conditioning_ref_qte, :precision => 3) if @p_product_ref.ct_price_ht? and @p_product_ref.conditioning_ref_qte?
|
=number_to_currency( @p_product_ref.ct_price_ht / @p_product_ref.conditioning_ref_qte, :precision => 3) if @p_product_ref.ct_price_ht? and @p_product_ref.conditioning_ref_qte?
|
||||||
="/"
|
="/"
|
||||||
= @p_product_ref.p_product.p_product_conditioning.name if @p_product_ref.p_product.p_product_conditioning
|
= @p_product_ref.p_product.p_product_conditioning.name if @p_product_ref.p_product.p_product_conditioning
|
||||||
|
%tr
|
||||||
|
%td Quantité par rapport au conditionnement de référence :
|
||||||
|
%td
|
||||||
|
= @p_product_ref.conditioning_ref_qte
|
||||||
|
|
||||||
|
%tr
|
||||||
|
%td Référence interne :
|
||||||
|
%td=@p_product_ref.ref
|
||||||
|
|
||||||
|
%tr
|
||||||
|
%td Désignation variante :
|
||||||
|
%td=@p_product_ref.ct_sub_name
|
||||||
|
|
||||||
|
%tr
|
||||||
|
%td Dernier prix d'achat :
|
||||||
|
%td=number_to_currency @p_product_ref.ct_price_ht
|
||||||
|
|
||||||
|
|
||||||
-if @p_product_ref
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-if false
|
||||||
|
|
||||||
-@line_stocks = @p_product_ref.line_stocks
|
-@line_stocks = @p_product_ref.line_stocks
|
||||||
.qi_kpi
|
.qi_kpi
|
||||||
@ -132,8 +126,13 @@
|
|||||||
sortis
|
sortis
|
||||||
|
|
||||||
.clear
|
.clear
|
||||||
|
-if false
|
||||||
|
.qi_row
|
||||||
|
.qi_pannel
|
||||||
|
%h3 Historique des prix d'achat
|
||||||
|
|
||||||
.qi_row
|
-if false
|
||||||
|
.qi_row
|
||||||
.qi_pannel
|
.qi_pannel
|
||||||
%h3 Historique des prix d'achat
|
%h3 Historique des prix d'achat
|
||||||
|
|
||||||
@ -169,4 +168,3 @@
|
|||||||
%td
|
%td
|
||||||
=number_to_currency price_line.price_u_ht
|
=number_to_currency price_line.price_u_ht
|
||||||
|
|
||||||
|
|
@ -1,2 +1,8 @@
|
|||||||
$('#p_product_ref_row_<%= @p_product_ref.id %>').replaceWith("<%= escape_javascript(render(@p_product_ref))%>");
|
$('#p_product_ref_row_<%= @p_product_ref.id %>').replaceWith("<%= escape_javascript(render(@p_product_ref))%>");
|
||||||
|
|
||||||
|
if ($('#<%= dom_id(@price_line) %>').parents('.qi_pannel.qi_plain').find('tbody').find('tr').length === 1) {
|
||||||
|
$('#<%= dom_id(@price_line) %>').parents('.qi_pannel.qi_plain').remove()
|
||||||
|
}
|
||||||
|
$('#<%= dom_id(@price_line) %>').remove();
|
||||||
|
|
||||||
close_pane_hover();
|
close_pane_hover();
|
@ -1,7 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_zone_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_product_zone_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
= breadcrumb
|
||||||
=PProductZone.human
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
=# f.input :stocked, :label => "Suivi de stock ?"
|
=# f.input :stocked, :label => "Suivi de stock ?"
|
||||||
|
|
||||||
|
.col-sm-2
|
||||||
|
=f.input :sorecop_cat, label: "Catgorie Sorecop :", :collection => SorecopCat.all, :as => :select, :include_blank => true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
%h1
|
=breadcrumb record: @p_product.code + ' - ' + @p_product.name
|
||||||
Achats
|
|
||||||
%span
|
|
||||||
=link_to "Produits", admin_p_products_path()
|
|
||||||
|
|
||||||
%span
|
|
||||||
Modifier un produit
|
|
||||||
|
|
||||||
= render 'form'
|
= render 'form'
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false
|
.right= link_to ic(:plus)+' Ajouter un produit', new_admin_p_product_path(), :class => "btn btn-primary btn-ap-add", :remote => false
|
||||||
%h1
|
=breadcrumb
|
||||||
Produits & Stocks
|
|
||||||
%span
|
|
||||||
Produits
|
|
||||||
|
|
||||||
|
|
||||||
.qi_search_row
|
.qi_search_row
|
||||||
@ -14,6 +11,14 @@
|
|||||||
|
|
||||||
%table
|
%table
|
||||||
%tr
|
%tr
|
||||||
|
%td{style: "min-width: 500px;"}
|
||||||
|
.input-group
|
||||||
|
=text_field_tag "search[global]", params[:search][:global],:class => "form-control", :placeholder => "Marque, modèle, couleur, code..."
|
||||||
|
.input-group-append{:onclick => "$(this).prev('input').val('');"}
|
||||||
|
.btn.btn-outline-dark
|
||||||
|
=ic(:times)
|
||||||
|
%tr
|
||||||
|
-if false
|
||||||
%td
|
%td
|
||||||
Actif :
|
Actif :
|
||||||
=select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled])
|
=select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled])
|
||||||
@ -27,12 +32,20 @@
|
|||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
Catégorie :
|
Catégorie :
|
||||||
=select_tag "search[p_product_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_cat_id])
|
%td
|
||||||
|
.input-group
|
||||||
|
=select_tag "search[p_product_cat_id]", options_for_select([["",""],["Aucune","null"]]+PProductCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_product_cat_id]), class: "custom-select"
|
||||||
|
.input-group-append{:onclick => "$(this).prev('select').val('').prop('selectedIndex',0);"}
|
||||||
|
.btn.btn-outline-dark
|
||||||
|
=ic(:times)
|
||||||
%td
|
%td
|
||||||
Marque :
|
Marque :
|
||||||
=select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id])
|
%td
|
||||||
|
.input-group
|
||||||
|
=select_tag "search[s_brand_id]", options_for_select([["",""]]+SBrand.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:s_brand_id]), class: "custom-select"
|
||||||
|
.input-group-append{:onclick => "$(this).prev('select').val('').prop('selectedIndex',0);"}
|
||||||
|
.btn.btn-outline-dark
|
||||||
|
=ic(:times)
|
||||||
|
|
||||||
|
|
||||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_products}
|
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_products}
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
%h1
|
=breadcrumb
|
||||||
Achats
|
|
||||||
%span
|
|
||||||
=link_to "Produits", admin_p_products_path()
|
|
||||||
|
|
||||||
%span
|
|
||||||
Ajouter un produit
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_serial_num_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_serial_num_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
= breadcrumb
|
||||||
=PSerialNumType.human rescue ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_type_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
= breadcrumb
|
||||||
=PSpecType.human rescue ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_value_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
.right= link_to ic(:plus)+' Ajouter', new_admin_p_spec_value_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||||
%h1
|
= breadcrumb
|
||||||
=PSpecValue.human rescue ""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
%h1
|
=breadcrumb second_title: "Demande de prix #{@price_document.d_number} - #{@price_document.list_designaton}", second_link: admin_price_document_path(@price_document) , last_element: "Analyse de des réponses"
|
||||||
Achats
|
|
||||||
%span
|
|
||||||
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
|
|
||||||
|
|
||||||
-unmatched_fournisseur = 0
|
-unmatched_fournisseur = 0
|
||||||
=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|
|
=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|
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
|
=breadcrumb second_title: @price_document.label, second_link: admin_price_documents_path(:price_document_type_id => @price_document.price_document_type_id), record: @price_document.d_number
|
||||||
|
|
||||||
%h1
|
|
||||||
Documents comptables
|
|
||||||
%span
|
|
||||||
Modifier un document
|
|
||||||
%span
|
|
||||||
=@price_document.label
|
|
||||||
="-"
|
|
||||||
=@price_document.d_number
|
|
||||||
|
|
||||||
|
|
||||||
.qi_row=render :partial => "form"
|
.qi_row=render :partial => "form"
|
||||||
|
@ -1,21 +1,16 @@
|
|||||||
.qi_header
|
.qi_header
|
||||||
.right
|
.right
|
||||||
-if false # params[:price_document_type_id].to_s == "5"
|
-if params[:price_document_type_id].to_i == 6 # Facture Achat
|
||||||
=link_to ic(:plus)+" Ajouter un avoir", new_admin_price_document_path, :class => "btn btn-primary bgbd-ventes"
|
|
||||||
-elsif params[:price_document_type_id].to_i == 6
|
|
||||||
= link_to 'Ajouter une facture achat', new_admin_price_document_path(:document_type => "Facture d'achat"), :class => "btn btn-primary bgbd-documents", :remote => false
|
= link_to 'Ajouter une facture achat', new_admin_price_document_path(:document_type => "Facture d'achat"), :class => "btn btn-primary bgbd-documents", :remote => false
|
||||||
|
-elsif params[:price_document_type_id].to_i == 4 # Commande Achat
|
||||||
-elsif params[:price_document_type_id].to_i == 7
|
|
||||||
= link_to 'Ajouter une commande achat', new_admin_price_document_path(:document_type => "Commande achat"), :class => "btn btn-primary bgbd-documents", :remote => false
|
= link_to 'Ajouter une commande achat', new_admin_price_document_path(:document_type => "Commande achat"), :class => "btn btn-primary bgbd-documents", :remote => false
|
||||||
|
-elsif params[:price_document_type_id].to_i == 7
|
||||||
|
|
||||||
|
|
||||||
-else
|
-else
|
||||||
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary bgbd-ventes"
|
=link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary bgbd-ventes"
|
||||||
%h1
|
|
||||||
Documents
|
-if params[:price_document_type_id]
|
||||||
%span
|
=breadcrumb second_title: PriceDocumentType.find(params[:price_document_type_id]).label
|
||||||
Liste
|
|
||||||
|
|
||||||
|
|
||||||
.qi_search_row
|
.qi_search_row
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user