suite
This commit is contained in:
parent
2291ae9f0f
commit
65201a9ccb
@ -58,9 +58,11 @@ class ImportCsv < ApplicationRecord
|
|||||||
|
|
||||||
def charge
|
def charge
|
||||||
|
|
||||||
self.import_csv_elements.each do |e|
|
if false
|
||||||
e.element.destroy if e.element
|
self.import_csv_elements.each do |e|
|
||||||
e.destroy
|
e.element.destroy if e.element
|
||||||
|
e.destroy
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
csv_text = File.read(self.file.path, :encoding => 'UTF-8')
|
csv_text = File.read(self.file.path, :encoding => 'UTF-8')
|
||||||
|
@ -73,12 +73,18 @@ class PCustomer < ApplicationRecord
|
|||||||
|
|
||||||
validates :past_id, :uniqueness => true, :if => :imported
|
validates :past_id, :uniqueness => true, :if => :imported
|
||||||
|
|
||||||
|
attr_accessor :refresh_import
|
||||||
|
|
||||||
def do_import
|
def do_import
|
||||||
if self.imp_iban? and self.imp_bic?
|
if self.imp_iban? and self.imp_bic?
|
||||||
self.m_odr_rep_ribs.create(:bic => self.imp_bic, :iban => self.imp_iban, :admin_ok => true)
|
self.m_odr_rep_ribs.create(:bic => self.imp_bic, :iban => self.imp_iban, :admin_ok => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
part = Particular.new
|
if self.particular
|
||||||
|
part = self.particular
|
||||||
|
else
|
||||||
|
part = Particular.new
|
||||||
|
end
|
||||||
part.name = self.imp_name
|
part.name = self.imp_name
|
||||||
part.firstname = self.imp_firstname
|
part.firstname = self.imp_firstname
|
||||||
part.address_2 = self.imp_address
|
part.address_2 = self.imp_address
|
||||||
@ -125,6 +131,10 @@ class PCustomer < ApplicationRecord
|
|||||||
|
|
||||||
after_create :do_import
|
after_create :do_import
|
||||||
|
|
||||||
|
after_save do
|
||||||
|
self.do_import if self.refresh_import
|
||||||
|
end
|
||||||
|
|
||||||
acts_as_csv_import :fields =>[:imported, :email, :password, :past_id,:imp_cp,:imp_country,:imp_ref,:imp_email,:imp_firstname,:imp_name,:imp_fonction,:imp_organisme,:imp_address,:imp_cp2,:imp_city,:imp_tel,:imp_portable,:imp_lien,:imp_comment,:imp_iban,:imp_bic,:imp_circuit_1,:imp_circuit_2,:imp_circuit_3,:imp_partenaire,:imp_ecran,:imp_blocage,:imp_valid,:imp_user_valid,:imp_offre,:imp_info,:imp_cgu,:imp_test,:imp_stickers,:imp_npai,:npai,:imp_relance_adresse,:imp_demande_info,:imp_creation,:imp_modification]
|
acts_as_csv_import :fields =>[:imported, :email, :password, :past_id,:imp_cp,:imp_country,:imp_ref,:imp_email,:imp_firstname,:imp_name,:imp_fonction,:imp_organisme,:imp_address,:imp_cp2,:imp_city,:imp_tel,:imp_portable,:imp_lien,:imp_comment,:imp_iban,:imp_bic,:imp_circuit_1,:imp_circuit_2,:imp_circuit_3,:imp_partenaire,:imp_ecran,:imp_blocage,:imp_valid,:imp_user_valid,:imp_offre,:imp_info,:imp_cgu,:imp_test,:imp_stickers,:imp_npai,:npai,:imp_relance_adresse,:imp_demande_info,:imp_creation,:imp_modification]
|
||||||
|
|
||||||
attr_accessor :actual_password, :valid_last_password, :valid_public, :generate_mdp, :valid_pswd_confirmation, :require_cgv
|
attr_accessor :actual_password, :valid_last_password, :valid_public, :generate_mdp, :valid_pswd_confirmation, :require_cgv
|
||||||
|
@ -12,5 +12,5 @@
|
|||||||
|
|
||||||
= f.input :bic, :label => "Bic :"
|
= f.input :bic, :label => "Bic :"
|
||||||
|
|
||||||
.actions=f.submit "sauvegarder" #, :class => "btn btn-primary"
|
%center=f.submit "sauvegarder" #, :class => "btn btn-primary"
|
||||||
|
|
@ -21,7 +21,7 @@ module ActsAsCsvImport::Hook
|
|||||||
|
|
||||||
def self.default_import_csv(list, import_csv)
|
def self.default_import_csv(list, import_csv)
|
||||||
list.each do |row|
|
list.each do |row|
|
||||||
if false
|
if row["past_id"] #false
|
||||||
if n = self.where(:past_id => row["past_id"]).first
|
if n = self.where(:past_id => row["past_id"]).first
|
||||||
else
|
else
|
||||||
n = self.new
|
n = self.new
|
||||||
|
Loading…
x
Reference in New Issue
Block a user