suite
This commit is contained in:
parent
03a728c372
commit
8a67fe944a
@ -6,6 +6,76 @@ class Admin::PProductStocksController < ApplicationController
|
|||||||
|
|
||||||
before_filter :admin_space
|
before_filter :admin_space
|
||||||
|
|
||||||
|
def export
|
||||||
|
@p_products = PProduct.where(:archived => false, :enabled => true).all
|
||||||
|
|
||||||
|
@file = ""
|
||||||
|
|
||||||
|
@headers = [
|
||||||
|
"ID Sys",
|
||||||
|
"Ref produit",
|
||||||
|
"Nom",
|
||||||
|
"Ref variante",
|
||||||
|
"Taille",
|
||||||
|
"Couleur",
|
||||||
|
"Stock Physique",
|
||||||
|
"Stock théorique (prenant en compte les commandes en cours)"
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
@csv = CSV.generate(:headers => true, :col_sep => ";") do |csv|
|
||||||
|
csv << @headers
|
||||||
|
|
||||||
|
@p_products.each do |p_product|
|
||||||
|
p_product.p_product_stocks.each do |pps|
|
||||||
|
line = []
|
||||||
|
|
||||||
|
line << p_product.id
|
||||||
|
line << p_product.code
|
||||||
|
line << p_product.name
|
||||||
|
|
||||||
|
line << pps.code
|
||||||
|
line << (pps.p_color ? pps.p_color.name : "")
|
||||||
|
line << (pps.p_size ? pps.p_size.name : "")
|
||||||
|
|
||||||
|
line << pps.stock_ok
|
||||||
|
|
||||||
|
line << pps.stock_th_ok
|
||||||
|
|
||||||
|
csv << line
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@data_to_send = @csv.encode('iso-8859-1', :undef => :replace, :replace => '')
|
||||||
|
|
||||||
|
file_path = Rails.root.join("pdf", "export.csv")
|
||||||
|
|
||||||
|
File.open(file_path, "w+") do |f|
|
||||||
|
f.write(@data_to_send)
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{
|
||||||
|
require 'csv'
|
||||||
|
|
||||||
|
csv_text = File.read(file_path).encode('utf-8')
|
||||||
|
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
||||||
|
}
|
||||||
|
format.csv {
|
||||||
|
send_file file_path, :filename => "etat-stocks.csv", :type => 'text/csv; charset=iso-8859-1; header=present'
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def import
|
def import
|
||||||
if true
|
if true
|
||||||
|
@ -10,6 +10,161 @@ class Admin::PProductsController < ApplicationController
|
|||||||
@admin_space = "ventes"
|
@admin_space = "ventes"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def export
|
||||||
|
@p_products = PProduct.where(:archived => false, :enabled => true).all
|
||||||
|
|
||||||
|
@file = ""
|
||||||
|
|
||||||
|
@headers = [
|
||||||
|
"ID Sys",
|
||||||
|
"Ref produit",
|
||||||
|
"Catégorie",
|
||||||
|
"Nom",
|
||||||
|
"Description",
|
||||||
|
"Grammage",
|
||||||
|
"Origine",
|
||||||
|
"Certifications",
|
||||||
|
"Qté/cartons",
|
||||||
|
"Ref variante",
|
||||||
|
"Taille",
|
||||||
|
"Couleur"
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
@csv = CSV.generate(:headers => true, :col_sep => ";") do |csv|
|
||||||
|
csv << @headers
|
||||||
|
|
||||||
|
@p_products.each do |p_product|
|
||||||
|
p_product.p_product_stocks.each do |pps|
|
||||||
|
line = []
|
||||||
|
|
||||||
|
line << p_product.id
|
||||||
|
line << p_product.code
|
||||||
|
line << (p_product.p_product_cat ? p_product.p_product_cat.name : "")
|
||||||
|
line << p_product.name
|
||||||
|
line << p_product.description
|
||||||
|
if p_product.p_ep
|
||||||
|
line << p_product.p_ep.ep
|
||||||
|
else
|
||||||
|
line << ""
|
||||||
|
end
|
||||||
|
if p_product.p_origine
|
||||||
|
line << p_product.p_origine.name
|
||||||
|
else
|
||||||
|
line << ""
|
||||||
|
end
|
||||||
|
line << p_product.p_certifs.all.map{|pc| pc.name}.join(",")
|
||||||
|
line << p_product.p_qtes.all.map{|pq| pq.qte}.join(",")
|
||||||
|
line << pps.code
|
||||||
|
line << (pps.p_color ? pps.p_color.name : "")
|
||||||
|
line << (pps.p_size ? pps.p_size.name : "")
|
||||||
|
|
||||||
|
csv << line
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@data_to_send = @csv.encode('iso-8859-1', :undef => :replace, :replace => '')
|
||||||
|
|
||||||
|
file_path = Rails.root.join("pdf", "export.csv")
|
||||||
|
|
||||||
|
File.open(file_path, "w+") do |f|
|
||||||
|
f.write(@data_to_send)
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{
|
||||||
|
require 'csv'
|
||||||
|
|
||||||
|
csv_text = File.read(file_path).encode('utf-8')
|
||||||
|
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
||||||
|
}
|
||||||
|
format.csv {
|
||||||
|
send_file file_path, :filename => "export-produits.csv", :type => 'text/csv; charset=iso-8859-1; header=present'
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def export_prix
|
||||||
|
@p_products = PProduct.where(:archived => false, :enabled => true).all
|
||||||
|
|
||||||
|
@file = ""
|
||||||
|
|
||||||
|
@headers = [
|
||||||
|
"ID Sys",
|
||||||
|
"Ref produit",
|
||||||
|
"Nom",
|
||||||
|
"Ref variante",
|
||||||
|
"Qte min.",
|
||||||
|
"Prix U HT"
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
@csv = CSV.generate(:headers => true, :col_sep => ";") do |csv|
|
||||||
|
csv << @headers
|
||||||
|
|
||||||
|
@p_products.each do |p_product|
|
||||||
|
p_product.p_product_stocks.each do |pps|
|
||||||
|
line = []
|
||||||
|
|
||||||
|
line << p_product.id
|
||||||
|
line << p_product.code
|
||||||
|
|
||||||
|
line << pps.code
|
||||||
|
line << 500
|
||||||
|
|
||||||
|
p_price_cat = PPriceCat.where(:name => "R0").first
|
||||||
|
|
||||||
|
p_degressifs = p_product.p_degressifs.joins(:p_price_cats).where(:p_price_cats => {:id => p_price_cat.id}).order("nbr ASC")
|
||||||
|
|
||||||
|
p_degressif = p_degressifs.first
|
||||||
|
|
||||||
|
line << ((p_degressif and p_degressif.price.to_f > 0.0) ? p_degressif.price : "")
|
||||||
|
|
||||||
|
csv << line
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@data_to_send = @csv.encode('iso-8859-1', :undef => :replace, :replace => '')
|
||||||
|
|
||||||
|
file_path = Rails.root.join("pdf", "export.csv")
|
||||||
|
|
||||||
|
File.open(file_path, "w+") do |f|
|
||||||
|
f.write(@data_to_send)
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{
|
||||||
|
require 'csv'
|
||||||
|
|
||||||
|
csv_text = File.read(file_path).encode('utf-8')
|
||||||
|
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
||||||
|
}
|
||||||
|
format.csv {
|
||||||
|
send_file file_path, :filename => "export-prix.csv", :type => 'text/csv; charset=iso-8859-1; header=present'
|
||||||
|
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@p_products = PProduct.joins(:p_product_cat).order("p_product_cats.name ASC, p_products.name ASC").all
|
@p_products = PProduct.joins(:p_product_cat).order("p_product_cats.name ASC, p_products.name ASC").all
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
%li= link_to "Commandes fournisseurs", admin_p_fournisseur_orders_path
|
%li= link_to "Commandes fournisseurs", admin_p_fournisseur_orders_path
|
||||||
|
|
||||||
|
-if false
|
||||||
%li= link_to "Cuves", admin_p_tanks_path
|
%li= link_to "Cuves", admin_p_tanks_path
|
||||||
%li= link_to "Fournisseurs", admin_p_fournisseurs_path
|
%li= link_to "Fournisseurs", admin_p_fournisseurs_path
|
||||||
%li= link_to "Facture transport", admin_p_ship_bills_path
|
%li= link_to "Facture transport", admin_p_ship_bills_path
|
||||||
|
@ -146,6 +146,26 @@
|
|||||||
$(".p_sheet_lines_tot_ttc").html(accounting.formatMoney(tot_sheet_fdp*tva))
|
$(".p_sheet_lines_tot_ttc").html(accounting.formatMoney(tot_sheet_fdp*tva))
|
||||||
#alert(tot_sheet)
|
#alert(tot_sheet)
|
||||||
|
|
||||||
|
@udpate_sheet_lines = ->
|
||||||
|
$(".p_sheet_line_field").each ->
|
||||||
|
price = parseFloat($(this).find(".price").find("input").val())
|
||||||
|
price_tot = 0
|
||||||
|
qte_tot = 0
|
||||||
|
$(this).find(".color_line").each ->
|
||||||
|
qte = 0
|
||||||
|
$(this).find("input.qte").each ->
|
||||||
|
qte += parseFloat($(this).val()) if parseFloat($(this).val())
|
||||||
|
price_color = qte * price
|
||||||
|
$(this).find(".price_color_tot").html(accounting.formatMoney(price_color))
|
||||||
|
$(this).find(".qte_color_tot").html(qte)
|
||||||
|
|
||||||
|
|
||||||
|
qte_tot += qte
|
||||||
|
|
||||||
|
$(this).find(".qte_tot").html(qte_tot)
|
||||||
|
$(this).find(".price_tot").html(accounting.formatMoney(qte_tot*price))
|
||||||
|
$(this).find(".price_tot").attr("data-price",qte_tot*price)
|
||||||
|
$(this).find(".price_tot").data("price",qte_tot*price)
|
||||||
|
|
||||||
:coffeescript
|
:coffeescript
|
||||||
|
|
||||||
|
16
app/views/admin/p_product_stocks/export.html.haml
Normal file
16
app/views/admin/p_product_stocks/export.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.qi_row
|
||||||
|
.qi_pannel.qi_plain.padding
|
||||||
|
=link_to "Técharger en CSV", params.merge(:format => :csv)
|
||||||
|
|
||||||
|
%table.table
|
||||||
|
%tr
|
||||||
|
-@csv.headers.each do |h|
|
||||||
|
%td=h
|
||||||
|
|
||||||
|
-@csv.each do |csv|
|
||||||
|
%tr
|
||||||
|
-csv.each do |t|
|
||||||
|
%td=t[1]
|
@ -8,6 +8,12 @@
|
|||||||
|
|
||||||
.qi_row
|
.qi_row
|
||||||
.qi_pannel.qi_plain.padding
|
.qi_pannel.qi_plain.padding
|
||||||
|
=link_to "Export stocks", export_admin_p_product_stocks_path, :class => "btn btn-default"
|
||||||
|
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
|
||||||
|
|
||||||
%table.table
|
%table.table
|
||||||
%tr
|
%tr
|
||||||
%th Code gén.
|
%th Code gén.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
%table.table
|
%table.table
|
||||||
%tr
|
%tr
|
||||||
%th Code
|
%th Code
|
||||||
|
16
app/views/admin/p_products/export.html.haml
Normal file
16
app/views/admin/p_products/export.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.qi_row
|
||||||
|
.qi_pannel.qi_plain.padding
|
||||||
|
=link_to "Técharger en CSV", params.merge(:format => :csv)
|
||||||
|
|
||||||
|
%table.table
|
||||||
|
%tr
|
||||||
|
-@csv.headers.each do |h|
|
||||||
|
%td=h
|
||||||
|
|
||||||
|
-@csv.each do |csv|
|
||||||
|
%tr
|
||||||
|
-csv.each do |t|
|
||||||
|
%td=t[1]
|
16
app/views/admin/p_products/export_prix.html.haml
Normal file
16
app/views/admin/p_products/export_prix.html.haml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.qi_row
|
||||||
|
.qi_pannel.qi_plain.padding
|
||||||
|
=link_to "Técharger en CSV", params.merge(:format => :csv)
|
||||||
|
|
||||||
|
%table.table
|
||||||
|
%tr
|
||||||
|
-@csv.headers.each do |h|
|
||||||
|
%td=h
|
||||||
|
|
||||||
|
-@csv.each do |csv|
|
||||||
|
%tr
|
||||||
|
-csv.each do |t|
|
||||||
|
%td=t[1]
|
@ -8,5 +8,13 @@
|
|||||||
|
|
||||||
.qi_row
|
.qi_row
|
||||||
.qi_pannel.qi_plain.padding
|
.qi_pannel.qi_plain.padding
|
||||||
|
=link_to "Export liste produits avec vente en ligne", export_admin_p_products_path, :class => "btn btn-default"
|
||||||
|
=link_to "Export liste prix produits avec vente en ligne", export_prix_admin_p_products_path, :class => "btn btn-default"
|
||||||
|
|
||||||
|
%br
|
||||||
|
%br
|
||||||
|
|
||||||
#p_product_index
|
#p_product_index
|
||||||
|
|
||||||
|
|
||||||
=render :partial => "index"
|
=render :partial => "index"
|
@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
%td.qte_color_tot.price_td
|
%td.qte_color_tot.price_td
|
||||||
%td.price.price_td{:data => {:price => form.object.price}}
|
%td.price.price_td{:data => {:price => form.object.price}}
|
||||||
=number_to_currency form.object.price
|
=#number_to_currency form.object.price
|
||||||
|
|
||||||
%td.price_color_tot.price_td
|
%td.price_color_tot.price_td
|
||||||
-elsif form.object.p_product
|
-elsif form.object.p_product
|
||||||
@ -106,8 +106,9 @@
|
|||||||
%td.qte_tot.price_td{:style => "font-weight:bold;"}
|
%td.qte_tot.price_td{:style => "font-weight:bold;"}
|
||||||
%strong=form.object.qte
|
%strong=form.object.qte
|
||||||
|
|
||||||
%td.price.price_td{:style => "font-weight:bold;", :data => {:price => form.object.price}}
|
%td.price.price_td{:style => "font-weight:bold;text-align:right;", :data => {:price => form.object.price}}
|
||||||
%strong=number_to_currency form.object.price
|
=form.input :ok_price, :label => false, :input_html => {:style => "display:inline-block;text-align:right"}
|
||||||
|
=#%strong=number_to_currency form.object.price
|
||||||
|
|
||||||
|
|
||||||
%td.price_tot.price_td{:style => "font-weight:bold;"}
|
%td.price_tot.price_td{:style => "font-weight:bold;"}
|
||||||
|
@ -132,6 +132,7 @@ Rails.application.routes.draw do
|
|||||||
namespace :admin do
|
namespace :admin do
|
||||||
resources :p_product_stocks do
|
resources :p_product_stocks do
|
||||||
collection do
|
collection do
|
||||||
|
get :export
|
||||||
get :import
|
get :import
|
||||||
get :import_prix
|
get :import_prix
|
||||||
end
|
end
|
||||||
@ -162,7 +163,10 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
|
|
||||||
resources :p_products do
|
resources :p_products do
|
||||||
|
|
||||||
collection do
|
collection do
|
||||||
|
get :export
|
||||||
|
get :export_prix
|
||||||
get :autocomplete
|
get :autocomplete
|
||||||
post :reorder
|
post :reorder
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user