ajout fonctions réduction + pas de produits etc
This commit is contained in:
parent
4493797357
commit
4419cbb607
76
app/controllers/admin/import_csv_champs_controller.rb
Normal file
76
app/controllers/admin/import_csv_champs_controller.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::ImportCsvChampsController < ApplicationController
|
||||
layout "admin"
|
||||
before_action :auth_admin
|
||||
|
||||
before_action :admin_space
|
||||
|
||||
def admin_space
|
||||
@admin_space = "default"
|
||||
end
|
||||
|
||||
def index
|
||||
@import_csv_champs = ImportCsvChamp.order(:name).all
|
||||
|
||||
@import_csv_champs = sort_by_sorting(@import_csv_champs, "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
|
||||
@import_csv_champs = @import_csv_champs.page(page).per(per_page)
|
||||
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@import_csv_champ = ImportCsvChamp.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@import_csv_champ = ImportCsvChamp.new
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@import_csv_champ = ImportCsvChamp.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@import_csv_champ = ImportCsvChamp.new(params.require(:import_csv_champ).permit!)
|
||||
|
||||
if @import_csv_champ.save
|
||||
|
||||
else
|
||||
render action: "new"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
@import_csv_champ = ImportCsvChamp.find(params[:id])
|
||||
|
||||
|
||||
if @import_csv_champ.update_attributes(params.require(:import_csv_champ).permit!)
|
||||
|
||||
else
|
||||
render action: "edit"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@import_csv_champ = ImportCsvChamp.find(params[:id])
|
||||
@import_csv_champ.destroy
|
||||
|
||||
end
|
||||
end
|
76
app/controllers/admin/import_csv_headers_controller.rb
Normal file
76
app/controllers/admin/import_csv_headers_controller.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::ImportCsvHeadersController < ApplicationController
|
||||
layout "admin"
|
||||
before_action :auth_admin
|
||||
|
||||
before_action :admin_space
|
||||
|
||||
def admin_space
|
||||
@admin_space = "default"
|
||||
end
|
||||
|
||||
def index
|
||||
@import_csv_headers = ImportCsvHeader.order(:name).all
|
||||
|
||||
@import_csv_headers = sort_by_sorting(@import_csv_headers, "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
|
||||
@import_csv_headers = @import_csv_headers.page(page).per(per_page)
|
||||
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@import_csv_header = ImportCsvHeader.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@import_csv_header = ImportCsvHeader.new
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@import_csv_header = ImportCsvHeader.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@import_csv_header = ImportCsvHeader.new(params.require(:import_csv_header).permit!)
|
||||
|
||||
if @import_csv_header.save
|
||||
|
||||
else
|
||||
render action: "new"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
@import_csv_header = ImportCsvHeader.find(params[:id])
|
||||
|
||||
|
||||
if @import_csv_header.update_attributes(params.require(:import_csv_header).permit!)
|
||||
|
||||
else
|
||||
render action: "edit"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@import_csv_header = ImportCsvHeader.find(params[:id])
|
||||
@import_csv_header.destroy
|
||||
|
||||
end
|
||||
end
|
103
app/controllers/admin/import_csvs_controller.rb
Normal file
103
app/controllers/admin/import_csvs_controller.rb
Normal file
@ -0,0 +1,103 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::ImportCsvsController < ApplicationController
|
||||
layout "admin"
|
||||
before_action :auth_admin
|
||||
|
||||
before_action :admin_space
|
||||
|
||||
def admin_space
|
||||
@admin_space = "preferences"
|
||||
end
|
||||
|
||||
def index
|
||||
@import_csvs = ImportCsv.all
|
||||
|
||||
@import_csvs = sort_by_sorting(@import_csvs, "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
|
||||
@import_csvs = @import_csvs.page(page).per(per_page)
|
||||
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@import_csv = ImportCsv.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def charge
|
||||
@import_csv = ImportCsv.find(params[:id])
|
||||
@import_csv.load
|
||||
|
||||
if @import_csv.m_odr
|
||||
redirect_to admin_m_odr_path(:id => @import_csv.m_odr, :tab => "import_csvs")
|
||||
else
|
||||
redirect_to :action => :index
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@import_csv = ImportCsv.new(:parent_id => params[:parent_id], :m_odr_id => params[:m_odr_id])
|
||||
if @import_csv.parent
|
||||
@import_csv.name = @import_csv.parent.name
|
||||
@import_csv.table_name = @import_csv.parent.table_name
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@import_csv = ImportCsv.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@import_csv = ImportCsv.new(params.require(:import_csv).permit!)
|
||||
|
||||
|
||||
|
||||
if @import_csv.save
|
||||
|
||||
if @import_csv.m_odr
|
||||
redirect_to admin_m_odr_path(:id => @import_csv.m_odr, :tab => "import_csvs")
|
||||
else
|
||||
redirect_to :action => :index
|
||||
end
|
||||
else
|
||||
render action: "new"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
@import_csv = ImportCsv.find(params[:id])
|
||||
|
||||
|
||||
if @import_csv.update_attributes(params.require(:import_csv).permit!)
|
||||
if @import_csv.m_odr
|
||||
redirect_to admin_m_odr_path(:id => @import_csv.m_odr, :tab => "import_csvs")
|
||||
else
|
||||
redirect_to :action => :index
|
||||
end
|
||||
else
|
||||
render action: "edit"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@import_csv = ImportCsv.find(params[:id])
|
||||
@import_csv.destroy
|
||||
|
||||
end
|
||||
end
|
76
app/controllers/admin/mail_type_cats_controller.rb
Normal file
76
app/controllers/admin/mail_type_cats_controller.rb
Normal file
@ -0,0 +1,76 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::MailTypeCatsController < ApplicationController
|
||||
layout "admin"
|
||||
before_action :auth_admin
|
||||
|
||||
before_action :admin_space
|
||||
|
||||
def admin_space
|
||||
@admin_space = "default"
|
||||
end
|
||||
|
||||
def index
|
||||
@mail_type_cats = MailTypeCat.all
|
||||
|
||||
@mail_type_cats = sort_by_sorting(@mail_type_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
|
||||
@mail_type_cats = @mail_type_cats.page(page).per(per_page)
|
||||
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@mail_type_cat = MailTypeCat.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@mail_type_cat = MailTypeCat.new(:m_odr_id => params[:m_odr_id])
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@mail_type_cat = MailTypeCat.find(params[:id])
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
@mail_type_cat = MailTypeCat.new(params.require(:mail_type_cat).permit!)
|
||||
|
||||
if @mail_type_cat.save
|
||||
|
||||
else
|
||||
render action: "new"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
@mail_type_cat = MailTypeCat.find(params[:id])
|
||||
|
||||
|
||||
if @mail_type_cat.update_attributes(params.require(:mail_type_cat).permit!)
|
||||
|
||||
else
|
||||
render action: "edit"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def destroy
|
||||
@mail_type_cat = MailTypeCat.find(params[:id])
|
||||
@mail_type_cat.destroy
|
||||
|
||||
end
|
||||
end
|
99
app/models/import_csv.rb
Normal file
99
app/models/import_csv.rb
Normal file
@ -0,0 +1,99 @@
|
||||
class ImportCsv < ApplicationRecord
|
||||
require "csv"
|
||||
|
||||
belongs_to :m_odr
|
||||
mount_uploader :file, FileUploader
|
||||
|
||||
has_many :import_csv_headers, :dependent => :destroy
|
||||
|
||||
has_many :import_csv_elements
|
||||
|
||||
acts_as_tree
|
||||
|
||||
validates :file, :presence => true
|
||||
validates :table_name, :presence => true
|
||||
|
||||
|
||||
has_many :import_csv_champs, :dependent => :destroy
|
||||
accepts_nested_attributes_for :import_csv_champs, :allow_destroy => true
|
||||
|
||||
acts_as_sorting :fields => {
|
||||
:id => {:name => "Id", :reorder => true},
|
||||
:created_at => {:name => "Date", :reorder => true},
|
||||
:name => {:name => "Nom", :reorder => true},
|
||||
:file => {:name => "Fichier", :reorder => true},
|
||||
:table_name => {:name => "Table", :reorder => true},
|
||||
|
||||
:nbr_headers => {:name => "Nbr champs", :reorder => true},
|
||||
:nbr_elements => {:name => "Nbr elements", :reorder => true},
|
||||
|
||||
|
||||
|
||||
:actions => {:name => "Actions", :reorder => false}
|
||||
}
|
||||
|
||||
|
||||
after_create do
|
||||
|
||||
csv_text = File.read(self.file.path, :encoding => 'UTF-8')
|
||||
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
||||
|
||||
@csv.headers.each do |header|
|
||||
self.import_csv_headers << ImportCsvHeader.new(:name => header)
|
||||
|
||||
end
|
||||
|
||||
self.table_name.classify.constantize.import_csv_fields.each do |h|
|
||||
if self.parent and c = self.parent.import_csv_champs.where(:champ => h.to_s).first
|
||||
self.import_csv_champs.new(:champ => h.to_s, :header => c.header)
|
||||
else
|
||||
self.import_csv_champs.new(:champ => h.to_s)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
self.save
|
||||
|
||||
|
||||
end
|
||||
|
||||
def charge
|
||||
|
||||
if false
|
||||
self.import_csv_elements.each do |e|
|
||||
e.element.destroy if e.element
|
||||
e.destroy
|
||||
end
|
||||
end
|
||||
|
||||
csv_text = File.read(self.file.path, :encoding => 'UTF-8')
|
||||
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
||||
r = []
|
||||
@csv.each do |row|
|
||||
line = {}
|
||||
self.import_csv_champs.each do |import_csv_champ|
|
||||
if import_csv_champ.header?
|
||||
eval "line['#{import_csv_champ.champ}'] = row[\"#{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
|
||||
|
||||
def load
|
||||
self.table_name.classify.constantize.import_csv(self.charge, self, self.m_odr_id)
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
3
app/models/import_csv_champ.rb
Normal file
3
app/models/import_csv_champ.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class ImportCsvChamp < ApplicationRecord
|
||||
belongs_to :import_csv
|
||||
end
|
5
app/models/import_csv_element.rb
Normal file
5
app/models/import_csv_element.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class ImportCsvElement < ApplicationRecord
|
||||
belongs_to :import_csv
|
||||
|
||||
belongs_to :element, :polymorphic => true
|
||||
end
|
3
app/models/import_csv_header.rb
Normal file
3
app/models/import_csv_header.rb
Normal file
@ -0,0 +1,3 @@
|
||||
class ImportCsvHeader < ApplicationRecord
|
||||
belongs_to :import_csv
|
||||
end
|
@ -1,7 +1,7 @@
|
||||
class MOdr < ApplicationRecord
|
||||
belongs_to :p_customer
|
||||
|
||||
|
||||
has_many :import_csvs
|
||||
belongs_to :background_image_file , :class_name => "ImageFile"
|
||||
belongs_to :banner_image_file, :class_name => "ImageFile"
|
||||
belongs_to :logo_image_file, :class_name => "ImageFile"
|
||||
@ -43,6 +43,8 @@ class MOdr < ApplicationRecord
|
||||
has_many :mail_types, :dependent => :destroy
|
||||
accepts_nested_attributes_for :mail_types, :allow_destroy => true
|
||||
|
||||
has_many :mail_type_cats, :dependent => :destroy
|
||||
|
||||
has_many :m_odr_product_remises, :through => :m_odr_products
|
||||
|
||||
|
||||
|
@ -7,4 +7,6 @@ class MOdrPlace < ApplicationRecord
|
||||
:actions => "Actions"
|
||||
}
|
||||
|
||||
acts_as_csv_import :fields => [:name, :enseigne, :email, :tel, :cp, :city, :country]
|
||||
|
||||
end
|
||||
|
@ -30,19 +30,31 @@ class MOdrRep < ApplicationRecord
|
||||
|
||||
validates :m_odr_product_cat_id, :presence => true, :if => :product_cat_needed?
|
||||
|
||||
validates :qte, :presence => true
|
||||
validates :m_odr_product_id, :presence => true
|
||||
validates :qte, :presence => true, :if => :product_needed?
|
||||
validates :m_odr_product_id, :presence => true, :if => :product_needed?
|
||||
validates :m_odr_place_id, :presence => true
|
||||
|
||||
validates :rgpd, :presence => true, :if => :rgpd_needed?
|
||||
|
||||
validates :reduc_code, :presence => true, length: { in: 6..6 }, :if => :reduc_code_needed?
|
||||
|
||||
|
||||
validates :reduc, :presence => true, :if => :reduc_needed?
|
||||
|
||||
belongs_to :m_odr_tracker
|
||||
|
||||
belongs_to :m_odr_product_cat
|
||||
|
||||
|
||||
def reduc_needed?
|
||||
if self.m_odr.reduc_needed
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def reduc_code_needed?
|
||||
if self.m_odr.reduc_code_needed
|
||||
true
|
||||
@ -51,6 +63,15 @@ class MOdrRep < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def product_needed?
|
||||
if self.m_odr.product_needed
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def product_cat_needed?
|
||||
if self.m_odr.m_odr_product_cats.count > 0
|
||||
true
|
||||
@ -311,7 +332,10 @@ file_admin_ok remise particular_civilite particular_name particular_firstname pa
|
||||
|
||||
|
||||
def ca_remise
|
||||
if self.qte and self.m_odr_product
|
||||
if self.reduc?
|
||||
self.reduc
|
||||
|
||||
elsif self.qte and self.m_odr_product
|
||||
|
||||
if self.m_odr_product and remise = self.m_odr_product.m_odr_product_remises.where(:qte => self.qte).first
|
||||
remise.amount
|
||||
|
@ -1,15 +1,16 @@
|
||||
class MailType < ApplicationRecord
|
||||
has_many :mail_contents
|
||||
belongs_to :mail_type_reference, :class_name => "MailType"
|
||||
|
||||
|
||||
belongs_to :mail_type_cat
|
||||
|
||||
belongs_to :m_odr
|
||||
|
||||
acts_as_sorting :fields => {
|
||||
|
||||
:slug => {:name => "Réf", :reorder => true},
|
||||
:default_title => {:name => "Sujet", :reorder => true},
|
||||
:default_message => {:name => "Contenu", :reorder => true},
|
||||
|
||||
:mail_type_cat_id => {:name => "Catégorie", :reorder => true},
|
||||
|
||||
:actions => "Actions",
|
||||
}
|
||||
|
||||
|
12
app/models/mail_type_cat.rb
Normal file
12
app/models/mail_type_cat.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class MailTypeCat < ApplicationRecord
|
||||
has_many :mail_types
|
||||
|
||||
acts_as_sorting :fields => {
|
||||
|
||||
:name => {:name => "Nom", :reorder => true},
|
||||
:slug => {:name => "Réf", :reorder => true},
|
||||
|
||||
:actions => "Actions",
|
||||
}
|
||||
|
||||
end
|
11
app/views/admin/import_csv_champs/_form.html.haml
Normal file
11
app/views/admin/import_csv_champs/_form.html.haml
Normal file
@ -0,0 +1,11 @@
|
||||
%tr.m_odr_product_remise_form.field
|
||||
%td{:style => "width:200px;"}= form.input :champ, :label => false, :as => :select, :collection => @import_csv.table_name.classify.constantize.import_csv_fields.map{|a| a.to_s}
|
||||
|
||||
|
||||
-if !form.object.header? and @import_csv.import_csv_headers.all.map{|a| a.name}.include?(form.object.champ)
|
||||
-form.object.header = form.object.champ
|
||||
|
||||
%td{:style => "width:200px;"}= form.input :header, :label => false, :as => :select, :collection => @import_csv.import_csv_headers.all.map{|a| a.name}
|
||||
%td{:style => "width:200px;"}= form.input :value, :label => false, :placeholder => "Valeure fixe"
|
||||
|
||||
%td=link_to_remove_fields ic(:"trash-o"), form
|
15
app/views/admin/import_csv_headers/_form.html.haml
Normal file
15
app/views/admin/import_csv_headers/_form.html.haml
Normal file
@ -0,0 +1,15 @@
|
||||
=semantic_form_for [:admin, @import_csv_header], :remote => true do |f|
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.input :import_csv, :label => "import_csv :"
|
||||
= f.input :name, :label => "name :"
|
||||
= f.input :champ, :label => "champ :"
|
||||
= f.input :custom, :label => "custom :"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
|
@ -0,0 +1,16 @@
|
||||
%tr#import_csv_header_row{:id => import_csv_header.id}
|
||||
-tr = {}
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, import_csv_header], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
= link_to i(:pencil), edit_admin_import_csv_header_path(import_csv_header), :remote => true
|
||||
= link_to i(:eye), admin_import_csv_header_path(import_csv_header), :remote => true
|
||||
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => import_csv_header}
|
||||
|
||||
|
||||
|
||||
|
2
app/views/admin/import_csv_headers/create.js.erb
Normal file
2
app/views/admin/import_csv_headers/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#import_csv_headers_rows').prepend("<%= escape_javascript(render(@import_csv_header))%>");
|
||||
close_pane_hover();
|
1
app/views/admin/import_csv_headers/destroy.js.erb
Normal file
1
app/views/admin/import_csv_headers/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
||||
$('#import_csv_header_row_<%= @import_csv_header.id %>').remove();
|
1
app/views/admin/import_csv_headers/edit.js.erb
Normal file
1
app/views/admin/import_csv_headers/edit.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
15
app/views/admin/import_csv_headers/index.html.haml
Normal file
15
app/views/admin/import_csv_headers/index.html.haml
Normal file
@ -0,0 +1,15 @@
|
||||
.qi_header
|
||||
.right= link_to ic(:plus)+' Ajouter', new_admin_import_csv_header_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||
%h1
|
||||
|
||||
|
||||
|
||||
.qi_search_row
|
||||
=form_tag "", :method => "get", :onsubmit => "" do
|
||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @import_csv_headers}
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @import_csv_headers}
|
||||
|
||||
|
||||
|
1
app/views/admin/import_csv_headers/new.js.erb
Normal file
1
app/views/admin/import_csv_headers/new.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
10
app/views/admin/import_csv_headers/show.html.haml
Normal file
10
app/views/admin/import_csv_headers/show.html.haml
Normal file
@ -0,0 +1,10 @@
|
||||
.qi_header
|
||||
%h1
|
||||
|
||||
%span
|
||||
|
||||
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
=debug @import_csv_header
|
2
app/views/admin/import_csv_headers/update.js.erb
Normal file
2
app/views/admin/import_csv_headers/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#import_csv_header_row_<%= @import_csv_header.id %>').replaceWith("<%= escape_javascript(render(@import_csv_header))%>");
|
||||
close_pane_hover();
|
29
app/views/admin/import_csvs/_form.html.haml
Normal file
29
app/views/admin/import_csvs/_form.html.haml
Normal file
@ -0,0 +1,29 @@
|
||||
=semantic_form_for [:admin, @import_csv], :remote => false, :multipart => true do |f|
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.hidden_field :parent_id
|
||||
|
||||
= f.hidden_field :m_odr_id
|
||||
|
||||
= f.input :name, :label => "Nom de l'import :"
|
||||
= f.input :file, :label => "file :"
|
||||
|
||||
= f.input :table_name, :label => "Table :" , :as => :select, :collection => ["m_odr_places"]
|
||||
|
||||
-if f.object.id
|
||||
%table.import_csv_champs_form
|
||||
-if f.object.import_csv_champs.count == 0
|
||||
-@import_csv.table_name.classify.constantize.import_csv_fields.each do |h|
|
||||
-f.object.import_csv_champs.new(:champ => h.to_s)
|
||||
|
||||
=f.semantic_fields_for :import_csv_champs do |form|
|
||||
=render :partial => "admin/import_csv_champs/form", :locals => {:form => form}
|
||||
|
||||
=#%p= link_to_add_fields ic(:plus)+" Ajouter une correspondance", f, :import_csv_champs
|
||||
|
||||
|
||||
|
||||
|
||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
|
31
app/views/admin/import_csvs/_import_csv.html.haml
Normal file
31
app/views/admin/import_csvs/_import_csv.html.haml
Normal file
@ -0,0 +1,31 @@
|
||||
%tr#import_csv_row{:id => import_csv.id}
|
||||
-tr = {}
|
||||
|
||||
-tr[:file] = capture do
|
||||
%td
|
||||
=File.basename import_csv.file.path
|
||||
|
||||
-tr[:nbr_headers] = capture do
|
||||
%td
|
||||
= import_csv.import_csv_headers.count
|
||||
|
||||
-tr[:nbr_elements] = capture do
|
||||
%td
|
||||
= import_csv.import_csv_elements.count
|
||||
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, import_csv], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
= link_to i(:pencil), edit_admin_import_csv_path(import_csv), :remote => true
|
||||
= link_to i(:eye), admin_import_csv_path(import_csv), :remote => true
|
||||
= link_to i(:refresh), charge_admin_import_csv_path(import_csv) if import_csv.import_csv_elements.count == 0 or current_admin.id == 1
|
||||
= link_to i(:copy), new_admin_import_csv_path(:parent_id => import_csv.id)
|
||||
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => import_csv}
|
||||
|
||||
|
||||
|
||||
|
2
app/views/admin/import_csvs/create.js.erb
Normal file
2
app/views/admin/import_csvs/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#import_csvs_rows').prepend("<%= escape_javascript(render(@import_csv))%>");
|
||||
close_pane_hover();
|
1
app/views/admin/import_csvs/destroy.js.erb
Normal file
1
app/views/admin/import_csvs/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
||||
$('#import_csv_row_<%= @import_csv.id %>').remove();
|
1
app/views/admin/import_csvs/edit.js.erb
Normal file
1
app/views/admin/import_csvs/edit.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
12
app/views/admin/import_csvs/index.html.haml
Normal file
12
app/views/admin/import_csvs/index.html.haml
Normal file
@ -0,0 +1,12 @@
|
||||
.qi_header
|
||||
.right= link_to ic(:plus)+' Ajouter', new_admin_import_csv_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||
%h1
|
||||
|
||||
|
||||
|
||||
.qi_search_row
|
||||
=form_tag "", :method => "get", :onsubmit => "" do
|
||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @import_csvs}
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @import_csvs}
|
10
app/views/admin/import_csvs/new.html.haml
Normal file
10
app/views/admin/import_csvs/new.html.haml
Normal file
@ -0,0 +1,10 @@
|
||||
.qi_header
|
||||
%h1
|
||||
Nouvel import
|
||||
%span
|
||||
|
||||
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
=render :partial => "form"
|
1
app/views/admin/import_csvs/new.js.erb
Normal file
1
app/views/admin/import_csvs/new.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
10
app/views/admin/import_csvs/show.html.haml
Normal file
10
app/views/admin/import_csvs/show.html.haml
Normal file
@ -0,0 +1,10 @@
|
||||
.qi_header
|
||||
%h1
|
||||
|
||||
%span
|
||||
|
||||
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
=debug @import_csv
|
2
app/views/admin/import_csvs/update.js.erb
Normal file
2
app/views/admin/import_csvs/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#import_csv_row_<%= @import_csv.id %>').replaceWith("<%= escape_javascript(render(@import_csv))%>");
|
||||
close_pane_hover();
|
@ -15,10 +15,12 @@
|
||||
=f.input :m_odr_product_id, :label => "Pneu :", :as => :select, :collection => f.object.m_odr.m_odr_products.order("m_odr_brand_id ASC, m_odr_products.name"), :member_label => :member_label, :include_blank => true
|
||||
|
||||
|
||||
=f.input :qte, :label => "Nombre de pneus :", :as => :select, :collection => [1,2], :include_blank => true
|
||||
=f.input :qte, :label => "Nombre de pneus :", :as => :select, :collection => f.object.m_odr.m_odr_product_remises.group(:qte).order("qte").map{|a| a.qte}, :include_blank => true
|
||||
|
||||
|
||||
=f.input :m_odr_place, :label => "Point de vente :", :as => :select, :collection => f.object.m_odr.m_odr_places.order(:name), :include_blank => true
|
||||
|
||||
=f.input :reduc, :label => "Remise manuelle :"
|
||||
|
||||
|
||||
|
||||
|
@ -80,7 +80,13 @@ Fichier
|
||||
|
||||
%td
|
||||
Envoyer un mail de notification :
|
||||
-[["facture-illisible", "Facture illisible"]].each do |key|
|
||||
|
||||
-if mail_type_cat = @m_odr_rep.m_odr.mail_type_cats.where(:slug => "refus-facture").first
|
||||
-slugs = mail_type_cat.mail_types.map{|u| [u.slug, u.slug]}
|
||||
-else
|
||||
-slugs = [["facture-illisible", "Facture illisible"]]
|
||||
|
||||
-slugs.each do |key|
|
||||
%br
|
||||
=link_to ic(:envelope)+" #{key[1]}", send_mail_admin_m_odr_file_path(file, :slug => key[0]), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;"
|
||||
|
||||
@ -143,7 +149,18 @@ RIB :
|
||||
-if @m_odr_rep.state == "Refusée"
|
||||
.red Demande refusée
|
||||
Envoyer un mail de notification :
|
||||
-[["document-non-valide", "Document non valide"], ["mauvais-titulaire", "Mauvais titulaire"], ["achat-hors-delais", "Achat hors délais"],["pneus-non-porteurs-de-l-offre", "Pneus invalides"],["dossier-deja-enregistre", "Dossier déjà enregistré"]].each do |key|
|
||||
|
||||
|
||||
-if mail_type_cat = @m_odr_rep.m_odr.mail_type_cats.where(:slug => "refus-demande").first
|
||||
-slugs = mail_type_cat.mail_types.map{|u| [u.slug, u.slug]}
|
||||
-else
|
||||
-slugs = [["document-non-valide", "Document non valide"], ["mauvais-titulaire", "Mauvais titulaire"], ["achat-hors-delais", "Achat hors délais"],["pneus-non-porteurs-de-l-offre", "Pneus invalides"],["dossier-deja-enregistre", "Dossier déjà enregistré"]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-slugs.each do |key|
|
||||
%br
|
||||
=link_to ic(:envelope)+" #{key[1]}", send_mail_admin_m_odr_rep_path(@m_odr_rep, :slug => key[0]), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;"
|
||||
|
||||
@ -156,7 +173,8 @@ RIB :
|
||||
=link_to "Générer le virement", generate_virement_admin_m_odr_rep_path(@m_odr_rep), :class => "btn btn-primary"
|
||||
|
||||
-if @m_odr_rep.m_odr.ba_generation
|
||||
|
||||
%br
|
||||
%br
|
||||
- @m_odr_rep.generate_ba
|
||||
=link_to "Voir le bon d'achat", @m_odr_rep.ba_url, :class => "btn btn-primary"
|
||||
|
||||
|
@ -71,9 +71,16 @@
|
||||
= f.input :reduc_code_process, :label => "Code de réduction ?"
|
||||
= f.input :reduc_code_needed, :label => "Obligatoire ?"
|
||||
|
||||
= f.input :reduc_process, :label => "Réduction saisie par le client ?"
|
||||
= f.input :reduc_needed, :label => "Obligatoire ?"
|
||||
|
||||
= f.input :confirm_case_needed, :label => "Case de confirmation obligatoire ?"
|
||||
|
||||
|
||||
= f.input :product_process, :label => "Produit ?"
|
||||
= f.input :product_needed, :label => "Obligatoire ?"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -88,6 +95,7 @@
|
||||
= f.input :product_label, :label => "Label produit :"
|
||||
= f.input :qte_label, :label => "Label quantité :"
|
||||
= f.input :place_label, :label => "Label lieu de vente :"
|
||||
= f.input :reduc_label, :label => "Label case réduction :"
|
||||
|
||||
|
||||
.qi_row
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
=#%li{:class => ("active" if params[:tab] == "mail_hists")}=link_to "Historique des mails envoyés", "?tab=mail_hists"
|
||||
|
||||
- tabs = [["m_odr_file_types", "Fichiers demandés"],["m_odr_brands", "Marques concernées"],["m_odr_product_cats", "Catégories produit"],["m_odr_products", "Produits"],["m_odr_places", "Revendeurs"],["m_odr_trackers", "Trackers"],["mail_types", "Mails"]]
|
||||
- tabs = [["m_odr_file_types", "Fichiers demandés"],["m_odr_brands", "Marques concernées"],["m_odr_product_cats", "Catégories produit"],["m_odr_products", "Produits"],["m_odr_places", "Revendeurs"],["m_odr_trackers", "Trackers"],["mail_types", "Mails"],["mail_type_cats", "Catégories mails"],["import_csvs", "Imports CSV"]]
|
||||
- tabs.each do |tab|
|
||||
%li{:class => ("active" if params[:tab] == tab[0])}=link_to tab[1], "?tab=#{tab[0]}"
|
||||
|
||||
@ -127,8 +127,9 @@
|
||||
|
||||
.qi_tab_header
|
||||
.right{:style => "text-align:right;"}
|
||||
= link_to 'Importer un fichier CSV', new_admin_import_csv_path(:m_odr_id => @m_odr.id), :class => "btn btn-primary", :remote => true
|
||||
= link_to 'Ajouter', new_admin_m_odr_place_path(:m_odr_id => @m_odr.id), :class => "btn btn-primary", :remote => true
|
||||
|
||||
.clear
|
||||
-params[:search][:per_page] = params[:search][:per_page] || 50
|
||||
-per_page = params[:search][:per_page]
|
||||
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
|
||||
@ -173,6 +174,51 @@
|
||||
-@mail_types = @mail_types.page(page).per(per_page)
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @mail_types}
|
||||
|
||||
|
||||
%p
|
||||
Mails importants :
|
||||
confirmation-inscription,
|
||||
erreur-coordonnees-bancaire,
|
||||
succes
|
||||
|
||||
|
||||
-if params[:tab] == "mail_type_cats"
|
||||
#offres
|
||||
|
||||
.qi_tab_header
|
||||
.right{:style => "text-align:right;"}
|
||||
= link_to 'Ajouter', new_admin_mail_type_cat_path(:m_odr_id => @m_odr.id), :class => "btn btn-primary", :remote => true
|
||||
|
||||
-params[:search][:per_page] = params[:search][:per_page] || 50
|
||||
-per_page = params[:search][:per_page]
|
||||
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
|
||||
-@mail_type_cats =@m_odr.mail_type_cats
|
||||
-@mail_type_cats = sort_by_sorting(@mail_type_cats, "created_at DESC")
|
||||
-@mail_type_cats = @mail_type_cats.page(page).per(per_page)
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @mail_type_cats}
|
||||
|
||||
%p
|
||||
Catégories importantes :
|
||||
refus-facture,
|
||||
refus-demande
|
||||
|
||||
|
||||
-if params[:tab] == "import_csvs"
|
||||
#offres
|
||||
|
||||
.qi_tab_header
|
||||
|
||||
.clear
|
||||
-params[:search][:per_page] = params[:search][:per_page] || 50
|
||||
-per_page = params[:search][:per_page]
|
||||
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
|
||||
-@import_csvs =@m_odr.import_csvs
|
||||
-@import_csvs = sort_by_sorting(@import_csvs, "created_at DESC")
|
||||
-@import_csvs = @import_csvs.page(page).per(per_page)
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @import_csvs}
|
||||
|
||||
|
||||
-if params[:tab] == "mail_hists"
|
||||
|
17
app/views/admin/mail_type_cats/_form.html.haml
Normal file
17
app/views/admin/mail_type_cats/_form.html.haml
Normal file
@ -0,0 +1,17 @@
|
||||
=semantic_form_for [:admin, @mail_type_cat], :remote => true do |f|
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.hidden_field :m_odr_id
|
||||
|
||||
|
||||
= f.input :name, :label => "Nom :"
|
||||
|
||||
= f.input :slug, :label => "Référence :"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
|
16
app/views/admin/mail_type_cats/_mail_type_cat.html.haml
Normal file
16
app/views/admin/mail_type_cats/_mail_type_cat.html.haml
Normal file
@ -0,0 +1,16 @@
|
||||
%tr#mail_type_cat_row{:id => mail_type_cat.id}
|
||||
-tr = {}
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, mail_type_cat], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
= link_to i(:pencil), edit_admin_mail_type_cat_path(mail_type_cat), :remote => true
|
||||
= link_to i(:eye), admin_mail_type_cat_path(mail_type_cat), :remote => true
|
||||
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => mail_type_cat}
|
||||
|
||||
|
||||
|
||||
|
2
app/views/admin/mail_type_cats/create.js.erb
Normal file
2
app/views/admin/mail_type_cats/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#mail_type_cats_rows').prepend("<%= escape_javascript(render(@mail_type_cat))%>");
|
||||
close_pane_hover();
|
1
app/views/admin/mail_type_cats/destroy.js.erb
Normal file
1
app/views/admin/mail_type_cats/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
||||
$('#mail_type_cat_row_<%= @mail_type_cat.id %>').remove();
|
1
app/views/admin/mail_type_cats/edit.js.erb
Normal file
1
app/views/admin/mail_type_cats/edit.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
15
app/views/admin/mail_type_cats/index.html.haml
Normal file
15
app/views/admin/mail_type_cats/index.html.haml
Normal file
@ -0,0 +1,15 @@
|
||||
.qi_header
|
||||
.right= link_to ic(:plus)+' Ajouter', new_admin_mail_type_cat_path(), :class => "btn btn-primary btn-ap-add", :remote => true
|
||||
%h1
|
||||
|
||||
|
||||
|
||||
.qi_search_row
|
||||
=form_tag "", :method => "get", :onsubmit => "" do
|
||||
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @mail_type_cats}
|
||||
|
||||
|
||||
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @mail_type_cats}
|
||||
|
||||
|
||||
|
1
app/views/admin/mail_type_cats/new.js.erb
Normal file
1
app/views/admin/mail_type_cats/new.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
10
app/views/admin/mail_type_cats/show.html.haml
Normal file
10
app/views/admin/mail_type_cats/show.html.haml
Normal file
@ -0,0 +1,10 @@
|
||||
.qi_header
|
||||
%h1
|
||||
|
||||
%span
|
||||
|
||||
|
||||
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
=debug @mail_type_cat
|
2
app/views/admin/mail_type_cats/update.js.erb
Normal file
2
app/views/admin/mail_type_cats/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#mail_type_cat_row_<%= @mail_type_cat.id %>').replaceWith("<%= escape_javascript(render(@mail_type_cat))%>");
|
||||
close_pane_hover();
|
@ -3,7 +3,8 @@
|
||||
.content
|
||||
= form.hidden_field :m_odr_id
|
||||
|
||||
|
||||
= form.input :mail_type_cat, :label => "Catégorie mail type :", :collection => @mail_type.m_odr.mail_type_cats, :include_blank => true
|
||||
|
||||
=# form.input :mail_type_cat, :label => "Catégorie mail type :"
|
||||
=form.input :slug, :label => "Référence mail :"
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
%tr#mail_type_row{:id => mail_type.id}
|
||||
-tr = {}
|
||||
|
||||
|
||||
-tr[:mail_type_cat_id] = capture do
|
||||
%td
|
||||
=mail_type.mail_type_cat.name if mail_type.mail_type_cat
|
||||
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, mail_type], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
|
@ -134,15 +134,20 @@
|
||||
=f.input :m_odr_product_cat_id, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.product_cat_label? ? @m_odr_rep.m_odr.product_cat_label : "Types :")), :as => :select, :collection => f.object.m_odr.m_odr_product_cats.order("id ASC"), :member_label => :name, :include_blank => true, :prompt => (@m_odr_rep.m_odr.product_cat_label? ? @m_odr_rep.m_odr.product_cat_label : "Nombre de pneus")
|
||||
|
||||
|
||||
=f.inputs do
|
||||
=f.input :m_odr_product_id, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.product_label? ? @m_odr_rep.m_odr.product_label : "Pneu :")), :as => :select, :collection => f.object.m_odr.m_odr_products.where(:m_odr_brand_id => f.object.m_odr.m_odr_brands.where("(start_at is null or start_at <= ?) and (public_end is null or public_end >= ?)", Date.today,Date.today) ).order("m_odr_brand_id ASC, m_odr_products.name"), :member_label => :member_label, :include_blank => true, :prompt => (@m_odr_rep.m_odr.product_label? ? @m_odr_rep.m_odr.product_label : "Pneu")
|
||||
-if @m_odr_rep.m_odr.product_process
|
||||
=f.inputs do
|
||||
=f.input :m_odr_product_id, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.product_label? ? @m_odr_rep.m_odr.product_label : "Pneu :")), :as => :select, :collection => f.object.m_odr.m_odr_products.where(:m_odr_brand_id => f.object.m_odr.m_odr_brands.where("(start_at is null or start_at <= ?) and (public_end is null or public_end >= ?)", Date.today,Date.today) ).order("m_odr_brand_id ASC, m_odr_products.name"), :member_label => :member_label, :include_blank => true, :prompt => (@m_odr_rep.m_odr.product_label? ? @m_odr_rep.m_odr.product_label : "Pneu")
|
||||
|
||||
=f.inputs do
|
||||
=f.input :qte, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.qte_label? ? @m_odr_rep.m_odr.qte_label : "Nombre de pneus :")), :as => :select, :collection => f.object.m_odr.m_odr_product_remises.group(:qte).order("qte").map{|a| a.qte}, :include_blank => true, :prompt => (@m_odr_rep.m_odr.qte_label? ? @m_odr_rep.m_odr.qte_label : "Nombre de pneus")
|
||||
=f.inputs do
|
||||
=f.input :qte, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.qte_label? ? @m_odr_rep.m_odr.qte_label : "Nombre de pneus :")), :as => :select, :collection => f.object.m_odr.m_odr_product_remises.group(:qte).order("qte").map{|a| a.qte}, :include_blank => true, :prompt => (@m_odr_rep.m_odr.qte_label? ? @m_odr_rep.m_odr.qte_label : "Nombre de pneus")
|
||||
|
||||
=f.inputs do
|
||||
=f.input :m_odr_place, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.place_label? ? @m_odr_rep.m_odr.place_label : "Point de vente :")), :as => :select, :collection => f.object.m_odr.m_odr_places.order(:name), :include_blank => true, :prompt => (@m_odr_rep.m_odr.place_label? ? @m_odr_rep.m_odr.place_label : "Point de vente :")
|
||||
|
||||
-if @m_odr_rep.m_odr.reduc_process
|
||||
=f.input :reduc, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.reduc_label? ? @m_odr_rep.m_odr.reduc_label : "Réduction :")), :include_blank => true, :placeholder => (@m_odr_rep.m_odr.reduc_label? ? @m_odr_rep.m_odr.reduc_label : "Réduction (€)")
|
||||
|
||||
|
||||
-if @m_odr_rep.m_odr.reduc_code_process
|
||||
=f.input :reduc_code, :label => (!@m_odr_rep.m_odr.placeholder? ? false : "Code promotionnel :"), :placeholder => (@m_odr_rep.m_odr.placeholder? ? false : "Code promotionnel")
|
||||
|
||||
|
@ -4,6 +4,43 @@ Rails.application.routes.draw do
|
||||
|
||||
|
||||
namespace :admin do
|
||||
resources :import_csv_champs do
|
||||
member do
|
||||
|
||||
end
|
||||
collection do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
resources :import_csv_headers do
|
||||
member do
|
||||
|
||||
end
|
||||
collection do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
resources :import_csvs do
|
||||
member do
|
||||
get :charge
|
||||
end
|
||||
collection do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
namespace :admin do
|
||||
|
||||
resources :mail_type_cats
|
||||
resources :mail_types
|
||||
|
||||
resources :m_odr_product_cats do
|
||||
|
14
db/migrate/20200513194543_create_import_csvs.rb
Normal file
14
db/migrate/20200513194543_create_import_csvs.rb
Normal file
@ -0,0 +1,14 @@
|
||||
class CreateImportCsvs < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :import_csvs do |t|
|
||||
t.references :m_odr
|
||||
t.string :file
|
||||
t.text :notes
|
||||
t.boolean :imported, :default => false
|
||||
t.string :table_name
|
||||
t.datetime :imported_at
|
||||
t.string :token
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
12
db/migrate/20200513200458_create_import_csv_headers.rb
Normal file
12
db/migrate/20200513200458_create_import_csv_headers.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class CreateImportCsvHeaders < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :import_csv_headers do |t|
|
||||
t.references :import_csv, foreign_key: true
|
||||
t.string :name
|
||||
t.string :champ
|
||||
t.boolean :custom, :default => :boolean
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
12
db/migrate/20200513202721_create_import_csv_champs.rb
Normal file
12
db/migrate/20200513202721_create_import_csv_champs.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class CreateImportCsvChamps < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :import_csv_champs do |t|
|
||||
t.string :champ
|
||||
t.string :header
|
||||
t.string :value
|
||||
t.references :import_csv, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
11
db/migrate/20200513210453_create_import_csv_elements.rb
Normal file
11
db/migrate/20200513210453_create_import_csv_elements.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateImportCsvElements < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :import_csv_elements do |t|
|
||||
t.references :import_csv, foreign_key: true
|
||||
t.string :element_type
|
||||
t.integer :element_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
class AddParentIdToImportCsvs < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :import_csvs, :parent_id, :integer
|
||||
add_column :import_csvs, :name, :string
|
||||
add_column :import_csvs, :description, :text
|
||||
end
|
||||
end
|
11
db/migrate/20200703080325_create_mail_type_cats.rb
Normal file
11
db/migrate/20200703080325_create_mail_type_cats.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class CreateMailTypeCats < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
create_table :mail_type_cats do |t|
|
||||
t.string :name
|
||||
t.references :m_odr
|
||||
t.string :slug
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddMailTypeCatToMailTypes < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :mail_types, :mail_type_cat_id, :integer
|
||||
end
|
||||
end
|
9
db/migrate/20200730084759_add_reduc_process_to_m_odr.rb
Normal file
9
db/migrate/20200730084759_add_reduc_process_to_m_odr.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class AddReducProcessToMOdr < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :m_odrs, :reduc_process, :boolean, :default => false
|
||||
add_column :m_odrs, :reduc_needed, :boolean, :default => false
|
||||
add_column :m_odrs, :product_process, :boolean, :default => true
|
||||
add_column :m_odrs, :product_needed, :boolean, :default => true
|
||||
add_column :m_odrs, :reduc_label, :string
|
||||
end
|
||||
end
|
5
db/migrate/20200730084942_add_reduc_to_m_odr_reps.rb
Normal file
5
db/migrate/20200730084942_add_reduc_to_m_odr_reps.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddReducToMOdrReps < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :m_odr_reps, :reduc, :decimal, :precision => 14, :scale => 2
|
||||
end
|
||||
end
|
66
db/schema.rb
66
db/schema.rb
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_07_03_080324) do
|
||||
ActiveRecord::Schema.define(version: 2020_07_30_084942) do
|
||||
|
||||
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "name"
|
||||
@ -517,6 +517,51 @@ ActiveRecord::Schema.define(version: 2020_07_03_080324) do
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
||||
create_table "import_csv_champs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "champ"
|
||||
t.string "header"
|
||||
t.string "value"
|
||||
t.bigint "import_csv_id"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["import_csv_id"], name: "index_import_csv_champs_on_import_csv_id"
|
||||
end
|
||||
|
||||
create_table "import_csv_elements", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.bigint "import_csv_id"
|
||||
t.string "element_type"
|
||||
t.integer "element_id"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["import_csv_id"], name: "index_import_csv_elements_on_import_csv_id"
|
||||
end
|
||||
|
||||
create_table "import_csv_headers", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.bigint "import_csv_id"
|
||||
t.string "name"
|
||||
t.string "champ"
|
||||
t.boolean "custom", default: true
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["import_csv_id"], name: "index_import_csv_headers_on_import_csv_id"
|
||||
end
|
||||
|
||||
create_table "import_csvs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.bigint "m_odr_id"
|
||||
t.string "file"
|
||||
t.text "notes"
|
||||
t.boolean "imported", default: false
|
||||
t.string "table_name"
|
||||
t.datetime "imported_at"
|
||||
t.string "token"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.integer "parent_id"
|
||||
t.string "name"
|
||||
t.text "description"
|
||||
t.index ["m_odr_id"], name: "index_import_csvs_on_m_odr_id"
|
||||
end
|
||||
|
||||
create_table "lang_articles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.datetime "published_at"
|
||||
t.string "title"
|
||||
@ -781,6 +826,7 @@ ActiveRecord::Schema.define(version: 2020_07_03_080324) do
|
||||
t.bigint "m_odr_product_cat_id"
|
||||
t.string "reduc_code"
|
||||
t.date "buy_at"
|
||||
t.decimal "reduc", precision: 14, scale: 2
|
||||
t.index ["m_odr_id"], name: "index_m_odr_reps_on_m_odr_id"
|
||||
t.index ["m_odr_place_id"], name: "index_m_odr_reps_on_m_odr_place_id"
|
||||
t.index ["m_odr_product_cat_id"], name: "index_m_odr_reps_on_m_odr_product_cat_id"
|
||||
@ -907,6 +953,11 @@ ActiveRecord::Schema.define(version: 2020_07_03_080324) do
|
||||
t.integer "ba_place_x"
|
||||
t.integer "ba_place_y"
|
||||
t.integer "ba_image_file_id"
|
||||
t.boolean "reduc_process", default: false
|
||||
t.boolean "reduc_needed", default: false
|
||||
t.boolean "product_process", default: true
|
||||
t.boolean "product_needed", default: true
|
||||
t.string "reduc_label"
|
||||
t.index ["p_customer_id"], name: "index_m_odrs_on_p_customer_id"
|
||||
end
|
||||
|
||||
@ -978,6 +1029,15 @@ ActiveRecord::Schema.define(version: 2020_07_03_080324) do
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
||||
create_table "mail_type_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.bigint "m_odr_id"
|
||||
t.string "slug"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["m_odr_id"], name: "index_mail_type_cats_on_m_odr_id"
|
||||
end
|
||||
|
||||
create_table "mail_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
|
||||
t.string "slug"
|
||||
t.string "default_title"
|
||||
@ -988,6 +1048,7 @@ ActiveRecord::Schema.define(version: 2020_07_03_080324) do
|
||||
t.bigint "m_odr_id"
|
||||
t.text "tags"
|
||||
t.bigint "file_tunel_id"
|
||||
t.integer "mail_type_cat_id"
|
||||
t.index ["file_tunel_id"], name: "index_mail_types_on_file_tunel_id"
|
||||
t.index ["m_odr_id"], name: "index_mail_types_on_m_odr_id"
|
||||
t.index ["mail_type_reference_id"], name: "index_mail_types_on_mail_type_reference_id"
|
||||
@ -2602,6 +2663,9 @@ ActiveRecord::Schema.define(version: 2020_07_03_080324) do
|
||||
add_foreign_key "i_task_projects", "admins"
|
||||
add_foreign_key "i_tasks", "admins"
|
||||
add_foreign_key "i_tasks", "i_task_projects"
|
||||
add_foreign_key "import_csv_champs", "import_csvs"
|
||||
add_foreign_key "import_csv_elements", "import_csvs"
|
||||
add_foreign_key "import_csv_headers", "import_csvs"
|
||||
add_foreign_key "m_odr_brands", "m_odrs"
|
||||
add_foreign_key "m_odr_coupons", "m_odrs"
|
||||
add_foreign_key "m_odr_file_types", "m_odrs"
|
||||
|
@ -8,20 +8,22 @@ module ActsAsCsvImport::Hook
|
||||
@csv_options[:fields]
|
||||
end
|
||||
|
||||
def self.import_csv(list, import_csv)
|
||||
def self.import_csv(list, import_csv, m_odr_id=nil)
|
||||
puts self.instance_methods
|
||||
|
||||
if self.methods.include?(:custom_csv_import)
|
||||
custom_csv_import(list, import_csv)
|
||||
custom_csv_import(list, import_csv, m_odr_id)
|
||||
else
|
||||
default_import_csv(list, import_csv)
|
||||
default_import_csv(list, import_csv, m_odr_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def self.default_import_csv(list, import_csv)
|
||||
def self.default_import_csv(list, import_csv, m_odr_id=nil)
|
||||
list.each do |row|
|
||||
n = self.new
|
||||
|
||||
n.m_odr_id = m_odr_id if m_odr_id
|
||||
|
||||
row.each do |key, value|
|
||||
eval "n.#{key} = value"
|
||||
|
Loading…
x
Reference in New Issue
Block a user