Compare commits

..

52 Commits

Author SHA1 Message Date
Nicolas Bally
2a6fc4cce6 Merge remote-tracking branch 'origin/master' 2022-02-13 20:25:50 +01:00
Nicolas Bally
91b5537924 New nginx config 2022-02-13 20:25:40 +01:00
d2d186724c Remove sass-cache 2022-02-02 09:54:06 +01:00
Nicolas Bally
8a252602af Données 2022 2022-01-11 18:10:09 +01:00
Nicolas Bally
8e8abdcf76 Suite 2021-10-07 22:28:00 +02:00
Nicolas Bally
128dc118c4 Problème nombre de primes 2021-07-30 09:58:21 +02:00
Nicolas Bally
9c36df619b Résolution problème stats 2021-07-07 23:19:04 +02:00
Nicolas Bally
e444d3f0c4 Suite 2021-07-01 12:09:41 +02:00
Nicolas Bally
3c0b028157 Bugfix stats 2021-07-01 12:06:22 +02:00
Nicolas Bally
1a63ef9f44 mise à jour stickers 2021-05-06 13:50:39 +02:00
Nicolas Bally
318bffc203 responsive 2021-03-30 17:00:22 +02:00
Nicolas Bally
0438ecf52e imports val de vienne 2021-03-23 15:48:01 +01:00
Nicolas Bally
6649167bee suite 2021-03-03 18:22:47 +01:00
Nicolas Bally
52acb2094f améliorations diverses 2021-03-03 16:12:04 +01:00
Nicolas Bally
4a3c92af46 suite 2021-03-03 15:17:13 +01:00
Nicolas Bally
abed8c9111 suite date 2021-03-03 15:04:52 +01:00
Nicolas Bally
26ab4bbf93 remonter factures 2021-02-09 18:35:26 +01:00
Nicolas Bally
9dbbb093a1 validation factures 2021-02-09 18:34:21 +01:00
Nicolas Bally
8c5c5ca0cc lien ambassadeur 2021-02-09 18:13:32 +01:00
Nicolas Bally
43ede8de94 ambassadeurs 2021-02-09 18:06:16 +01:00
Nicolas Bally
0848b6ef2e suite 2021-02-09 17:39:42 +01:00
Nicolas Bally
e5b04f41cf suite 2021-02-02 15:33:36 +01:00
Nicolas Bally
02c7748571 ordre circuits 2021-01-28 00:30:48 +01:00
Nicolas Bally
fa8ed3576c suppression message bonnes fêtes 2021-01-13 23:58:03 +01:00
Nicolas Bally
e2e2f6cab3 message fêtes 2020-12-21 16:24:55 +01:00
Nicolas Bally
4ffcbc1159 export organisateurs 2020-12-21 16:24:49 +01:00
Nicolas Bally
b77c13cf36 problème téléphone 2020-11-25 15:58:52 +01:00
Nicolas Bally
7c71bcda55 date de roulage 2020-11-18 10:22:26 +01:00
Nicolas Bally
3fde739862 modifs ergonomie 2020-09-29 00:50:57 +02:00
Nicolas Bally
c9b2379531 Bugfixes : erreur sur virement 2020-09-24 20:14:30 +02:00
Nicolas Bally
a9d5755886 Export XLSX 2020-09-18 08:59:28 +02:00
Nicolas Bally
9f8ecec536 décocher stickers envoyés lors de la levée NPAI 2020-09-17 16:07:15 +02:00
Nicolas Bally
a3568f1262 suite 2020-09-14 16:14:53 +02:00
Nicolas Bally
345fd6d572 csv 2020-09-14 15:27:34 +02:00
Nicolas Bally
78d0355224 bugfix :encoding problem 2020-09-14 15:21:02 +02:00
Nicolas Bally
7ff2f312f7 suite 2020-09-11 00:17:29 +02:00
Nicolas Bally
a4170d531d suite 2020-07-23 15:52:22 +02:00
Nicolas Bally
fb5eac464a ajustement stats 2020-07-23 13:09:42 +02:00
Nicolas Bally
ee42f7c0f6 suite 2020-07-23 12:46:54 +02:00
Nicolas Bally
71350f9b8c suite 2020-07-23 12:41:50 +02:00
Nicolas Bally
f4ccdc82dc suite 2020-07-23 11:17:11 +02:00
Nicolas Bally
e6260010a4 diverses modifs mineures 2020-07-23 00:04:14 +02:00
Nicolas Bally
dbcab11c01 suite 2020-07-22 15:50:47 +02:00
Nicolas Bally
3fecbf7e7f modification nombre d'inscrits dans le mail
ajout grandes régions
2020-07-22 11:12:11 +02:00
Nicolas Bally
0c53f506e7 suite 2020-07-22 10:04:40 +02:00
Nicolas Bally
647e71e8d6 fonctions pour export des utilisateurs en CSV 2020-07-22 00:20:43 +02:00
Nicolas Bally
fe24493d07 suite 2020-07-15 15:43:09 +02:00
Nicolas Bally
5a3eb40c61 suite 2020-07-15 15:36:45 +02:00
Nicolas Bally
9fa5bd6646 drapeaux 2020-07-15 14:31:05 +02:00
Nicolas Bally
91722c7262 suite 2020-07-15 13:53:09 +02:00
Nicolas Bally
7a1ea4f4c1 SEO 2020-07-09 15:04:46 +02:00
Nicolas Bally
56fc2b17d3 Bug envoi de primes lorsque RIB saisi après la génération de la prime 2020-07-09 15:04:41 +02:00
134 changed files with 3935 additions and 598 deletions

1
.gitignore vendored
View File

@ -42,5 +42,6 @@ yarn-debug.log*
/pdf/* /pdf/*
/.sass_cache/* /.sass_cache/*
/.sass-cache/*
/test* /test*

View File

@ -110,3 +110,6 @@ gem 'axlsx_rails'
gem 'iban-tools' gem 'iban-tools'
gem "mailjet" gem "mailjet"
gem "roo"

View File

@ -224,7 +224,9 @@ GEM
mime-types (3.3.1) mime-types (3.3.1)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009) mime-types-data (3.2019.1009)
mimemagic (0.3.5) mimemagic (0.3.10)
nokogiri (~> 1)
rake
mini_magick (4.10.1) mini_magick (4.10.1)
mini_mime (1.0.2) mini_mime (1.0.2)
mini_portile2 (2.4.0) mini_portile2 (2.4.0)
@ -286,6 +288,9 @@ GEM
mime-types (>= 1.16, < 4.0) mime-types (>= 1.16, < 4.0)
netrc (~> 0.8) netrc (~> 0.8)
rmagick (4.0.0) rmagick (4.0.0)
roo (2.8.2)
nokogiri (~> 1)
rubyzip (>= 1.2.1, < 2.0.0)
ruby-vips (2.0.17) ruby-vips (2.0.17)
ffi (~> 1.9) ffi (~> 1.9)
ruby_dep (1.5.0) ruby_dep (1.5.0)
@ -409,6 +414,7 @@ DEPENDENCIES
rails (= 6.0.3) rails (= 6.0.3)
rails_autolink rails_autolink
rmagick rmagick
roo
sass-rails (~> 5) sass-rails (~> 5)
searchkick searchkick
selenium-webdriver selenium-webdriver

View File

@ -120,12 +120,6 @@ $(document).ready ->
@resize = () -> @resize = () ->
petition_margin = (($(".petition_3 .bandeau").height()-$(".petition_3 .petition").height())/ 2 - 30)
if petition_margin < 0
petition_margin = 0
$(".petition_3 .petition").css('margin-top': petition_margin+'px')
top = $("#menu_top_container").outerHeight() top = $("#menu_top_container").outerHeight()

View File

@ -34,6 +34,8 @@
.numbers{ .numbers{
background-color: #cc4b14; background-color: #cc4b14;
padding: 30px 0px; padding: 30px 0px;
} }
.center_programme { .center_programme {
@ -273,5 +275,16 @@
} }
.numbers { .numbers {
padding: 30px 20px; padding: 30px 20px;
text-align:center;
.chiffre{
font-size:25px ;
}
.label-chiffre{
font-size:20px ;
padding-left:3px !important;
}
} }
} }

View File

@ -8450,8 +8450,8 @@ img{
} }
.right_intro{ .right_intro{
text-align:left;
padding:5px 30px; padding:0;
} }
@ -8567,6 +8567,124 @@ img{
} }
} }
.inline_check_boxes{
span{
display:block;
}
strong{
display:block;
margin-bottom:5px;
}
}
.row_home, .right_intro{
text-align:center;
}
.row1{
.block_intro:last-child{
padding-bottom:0 !important;
}
}
.row2{
.block_intro:first-child{
padding-top:0 !important;
}
}
.circuit{
h3{
text-align:center;
display:block;
}
.absolute_logo{
float: none;
text-align:center;
margin: 10px auto;
display: block;
position: static;
height: 100px;
margin-top: 20px;
padding:0;
img{
vertical-align: middle;
}
}
.block_info{
display:block;
text-align:center;
padding-bottom:5px;
margin-right:0;
}
}
.circuit_show{
.localisation{
display:block;
text-align:center;
span{
display:block;
}
}
.circuit_img{
width:auto;
float:none;
margin-bottom:20px;
}
.info_lien{
margin-bottom:0;
}
.block_info{
display:block;
text-align:center;
padding-bottom:5px;
margin-right:0;
}
.right{
float:none;
text-align:center;
}
}
.primes{
.render_block{
padding:0 15px;
.new_btn{
margin-bottom:10px;
}
img{
width:auto !important;
margin:0 !important;
}
}
}
.m_event{
.right_roulage{
text-align:center;
float:none;
}
}
} }
.country_icon{ .country_icon{

View File

@ -0,0 +1,76 @@
# -*- encoding : utf-8 -*-
class Admin::CircuitRegionCatsController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "default"
end
def index
@circuit_region_cats = CircuitRegionCat.all
@circuit_region_cats = sort_by_sorting(@circuit_region_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
@circuit_region_cats = @circuit_region_cats.page(page).per(per_page)
}
end
end
def show
@circuit_region_cat = CircuitRegionCat.find(params[:id])
end
def new
@circuit_region_cat = CircuitRegionCat.new
end
def edit
@circuit_region_cat = CircuitRegionCat.find(params[:id])
end
def create
@circuit_region_cat = CircuitRegionCat.new(params.require(:circuit_region_cat).permit!)
if @circuit_region_cat.save
else
render action: "new"
end
end
def update
@circuit_region_cat = CircuitRegionCat.find(params[:id])
if @circuit_region_cat.update_attributes(params.require(:circuit_region_cat).permit!)
else
render action: "edit"
end
end
def destroy
@circuit_region_cat = CircuitRegionCat.find(params[:id])
@circuit_region_cat.destroy
end
end

View File

@ -12,7 +12,7 @@ class Admin::CircuitsController < ApplicationController
def index def index
@circuits = Circuit.all @circuits = Circuit.all
@circuits = sort_by_sorting(@circuits, "name DESC") @circuits = sort_by_sorting(@circuits, "name ASC")
respond_to do |format| respond_to do |format|
format.html{ format.html{

View File

@ -79,8 +79,12 @@ class Admin::MEventsController < ApplicationController
end end
def new def new
@m_event = MEvent.new(:m_event_type_title => "Roulage libre")
if params[:parent_id]
@m_event = MEvent.find(params[:parent_id]).dup
else
@m_event = MEvent.new(:m_event_type_title => "Roulage libre")
end
end end
def edit def edit
@ -120,4 +124,14 @@ class Admin::MEventsController < ApplicationController
@m_event.destroy @m_event.destroy
end end
def autocomplete
@m_events = MEvent.order("start_at").where("start_at <= ? and end_at >= ?", Date.parse(params[:date]), Date.parse(params[:date]))
respond_to do |format|
format.json { render json: @m_events.map{|me| {:id => me.id, :member_label => me.member_label}} }
end
end
end end

View File

@ -11,7 +11,13 @@ class Admin::MOdrFilesController < ApplicationController
end end
def index def index
@m_odr_files = MOdrFile.all @m_odr_files = MOdrFile.joins(:p_customer).all
if params[:search][:name].to_s != ""
@m_odr_files = @m_odr_files.joins(:particular).where("particulars.organisation LIKE ? or particulars.name LIKE ? or particulars.firstname LIKE ?", "%#{params[:search][:name]}%", "%#{params[:search][:name]}%", "%#{params[:search][:name]}%")
end
@m_odr_files = sort_by_sorting(@m_odr_files, "id DESC") @m_odr_files = sort_by_sorting(@m_odr_files, "id DESC")
respond_to do |format| respond_to do |format|
@ -34,12 +40,20 @@ class Admin::MOdrFilesController < ApplicationController
def new def new
@m_odr_file = MOdrFile.new(:m_odr_file_type_id => params[:m_odr_file_type_id], :p_customer_id => params[:p_customer_id]) @m_odr_file = MOdrFile.new(:m_odr_file_type_id => params[:m_odr_file_type_id], :p_customer_id => params[:p_customer_id])
if params[:m_odr_file_type_id] == "1"
@m_odr_file.m_odr_file_roulages.build
else
@m_odr_file.m_odr_file_products.build(:admin_form => true)
end
end end
def edit def edit
@m_odr_file = MOdrFile.find(params[:id]) @m_odr_file = MOdrFile.find(params[:id])
@m_odr_file.m_odr_file_products.each do |mofp|
mofp.admin_form = true
end
end end

View File

@ -74,4 +74,20 @@ class Admin::MOdrPlacesController < ApplicationController
@m_odr_place.destroy @m_odr_place.destroy
end end
def autocomplete
search = params[:search]
@m_odr_places = MOdrPlace.where("name LIKE ? or city LIKE ? or cp LIKE ? or enseigne LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%")
@m_odr_places = @m_odr_places.distinct.limit(50)
respond_to do |format|
format.json { render json: @m_odr_places.map{|a| {:id => a.id, :member_label => a.member_label}} }
end
end
end end

View File

@ -11,7 +11,17 @@ class Admin::MOdrPrimesController < ApplicationController
end end
def index def index
@m_odr_primes = MOdrPrime.all @m_odr_primes = MOdrPrime.joins(:p_customer).joins(:m_odr_file_roulage).all
if params[:search][:state].to_s != ""
@m_odr_primes = @m_odr_primes.where(:state => params[:search][:state])
end
if params[:search][:name].to_s != ""
@m_odr_primes = @m_odr_primes.joins(:particular).where("particulars.organisation LIKE ? or particulars.name LIKE ? or particulars.firstname LIKE ?", "%#{params[:search][:name]}%", "%#{params[:search][:name]}%", "%#{params[:search][:name]}%")
end
@m_odr_primes = sort_by_sorting(@m_odr_primes, "id DESC") @m_odr_primes = sort_by_sorting(@m_odr_primes, "id DESC")
respond_to do |format| respond_to do |format|
@ -23,6 +33,71 @@ class Admin::MOdrPrimesController < ApplicationController
@m_odr_primes = @m_odr_primes.page(page).per(per_page) @m_odr_primes = @m_odr_primes.page(page).per(per_page)
} }
format.csv {
@headers = []
@columns = []
MOdrPrime.qi_table_order.each do |key, value|
if value.instance_of? Hash
name = value[:name]
else
name = value
end
if name != "Actions"
@headers << name.to_s
@columns << key
end
end
xlsx_package = Axlsx::Package.new
wb = xlsx_package.workbook
wb.add_worksheet(name: "import") do |sheet|
sheet.add_row @headers
@m_odr_primes.each do |m_odr_prime|
line = []
@columns.each do |column|
if (m_odr_prime.respond_to?("csv_"+column.to_s))
line << m_odr_prime.send("csv_"+column.to_s)
elsif (m_odr_prime.respond_to?(column))
if m_odr_prime.send(column.to_s).class.to_s == "BigDecimal"
line << m_odr_prime.send(column.to_s).to_s.gsub('.', ',')
else
line << m_odr_prime.send(column.to_s)
end
else
line << column.to_s
end
end
sheet.add_row line, types: line.map{|t| self.cell_type_from_value(t)}
end
end
@final_file = "#{Rails.root}/private_medias/export-primes-#{Time.now.to_s.to_slug}.xlsx"
xlsx_package.serialize(@final_file)
send_file @final_file
}
end end
end end
@ -100,5 +175,13 @@ class Admin::MOdrPrimesController < ApplicationController
redirect_back(fallback_location:"/") redirect_back(fallback_location:"/")
end end
def attente_roulage
@m_odr_prime = MOdrPrime.find(params[:id])
@m_odr_prime.change_state("En attente de roulage")
redirect_back(fallback_location:"/")
end
end end

View File

@ -52,6 +52,8 @@ class Admin::MOdrRemisesController < ApplicationController
m_odr_virement.m_odr_prime.change_state("Virement envoyé") if m_odr_virement.m_odr_prime m_odr_virement.m_odr_prime.change_state("Virement envoyé") if m_odr_virement.m_odr_prime
m_odr_virement.save m_odr_virement.save
m_odr_virement.m_odr_prime.save
#m_odr_virement.m_odr_prime.send_mail_type("succes", m_odr_virement) #m_odr_virement.m_odr_prime.send_mail_type("succes", m_odr_virement)
end end

View File

@ -13,7 +13,7 @@ class Admin::MOdrRepRibsController < ApplicationController
def index def index
@m_odr_rep_ribs = MOdrRepRib.all @m_odr_rep_ribs = MOdrRepRib.all
@m_odr_rep_ribs = sort_by_sorting(@m_odr_rep_ribs, "id DESC") @m_odr_rep_ribs = sort_by_sorting(@m_odr_rep_ribs, "admin_ok ASC")
respond_to do |format| respond_to do |format|
format.html{ format.html{
@ -72,11 +72,20 @@ class Admin::MOdrRepRibsController < ApplicationController
def send_mail def send_mail
@m_odr_rep_rib = MOdrRepRib.find(params[:id]) @m_odr_rep_rib = MOdrRepRib.find(params[:id])
@m_odr_rep = @m_odr_rep_rib.m_odr_rep
@m_odr_rep.send_mail_type("erreur-coordonnees-bancaire", @m_odr_rep_rib) @m_odr_rep_rib.mail_sended = true
@m_odr_rep_rib.save
redirect_to [:admin, @m_odr_rep] @p_customer = @m_odr_rep_rib.p_customer
mail_hist = MailHist.auto_generate_mail(:fr, params[:slug].to_s, @p_customer.email, {:arguments => {}, :p_customer => @p_customer, :element => @m_odr_rep_rib})
#redirect_to [:admin, @m_odr_rep]
end end

View File

@ -18,6 +18,11 @@ class Admin::MOdrVirementsController < ApplicationController
@m_odr_virements = @m_odr_virements.where(:m_odr_id => params[:search][:m_odr_id]) @m_odr_virements = @m_odr_virements.where(:m_odr_id => params[:search][:m_odr_id])
end end
if params[:search][:name].to_s != ""
@m_odr_virements = @m_odr_virements.joins(:p_customer).where("p_customers.cc_particular_name LIKE ? or p_customers.cc_particular_firstname LIKE ? ", "%#{params[:search][:name]}%", "%#{params[:search][:name]}%")
end
@m_odr_virements = sort_by_sorting(@m_odr_virements, "created_at DESC") @m_odr_virements = sort_by_sorting(@m_odr_virements, "created_at DESC")

View File

@ -13,7 +13,7 @@ class Admin::OrganisateursController < ApplicationController
def index def index
@organisateurs = Organisateur.all @organisateurs = Organisateur.all
@organisateurs = sort_by_sorting(@organisateurs, "name DESC") @organisateurs = sort_by_sorting(@organisateurs, "name ASC")
respond_to do |format| respond_to do |format|
format.html{ format.html{
@ -23,6 +23,71 @@ class Admin::OrganisateursController < ApplicationController
@organisateurs = @organisateurs.page(page).per(per_page) @organisateurs = @organisateurs.page(page).per(per_page)
} }
format.csv {
@headers = []
@columns = []
Organisateur.qi_table_order.each do |key, value|
if value.instance_of? Hash
name = value[:name]
else
name = value
end
if name != "Actions"
@headers << name.to_s
@columns << key
end
end
xlsx_package = Axlsx::Package.new
wb = xlsx_package.workbook
wb.add_worksheet(name: "import") do |sheet|
sheet.add_row @headers
@organisateurs.each do |p_customer|
line = []
@columns.each do |column|
if (p_customer.respond_to?("csv_"+column.to_s))
line << p_customer.send("csv_"+column.to_s)
elsif (p_customer.respond_to?(column))
if p_customer.send(column.to_s).class.to_s == "BigDecimal"
line << p_customer.send(column.to_s).to_s.gsub('.', ',')
else
line << p_customer.send(column.to_s)
end
else
line << column.to_s
end
end
sheet.add_row line, types: line.map{|t| self.cell_type_from_value(t)}
end
end
@final_file = "#{Rails.root}/private_medias/export-organisateurs-#{Time.now.to_s.to_slug}.xlsx"
xlsx_package.serialize(@final_file)
send_file @final_file
}
end end
end end

View File

@ -7,11 +7,46 @@ class Admin::PCustomersController < ApplicationController
before_action :admin_space before_action :admin_space
def update_tel
PCustomer.find_each do |pc|
if !pc.tel?
if pc.imp_tel?
pc.tel = pc.imp_tel
pc.save
elsif pc.imp_portable
pc.tel = pc.imp_portable
pc.save
end
end
end
end
def send_mail
@p_customer = PCustomer.find(params[:id])
if params[:slug] == "stickers-manque-adresse"
@p_customer.particular_mail_sended = true
@p_customer.save
end
mail_hist = MailHist.auto_generate_mail(:fr, params[:slug].to_s, @p_customer.email, {:arguments => {}, :p_customer => @p_customer, :element => @p_customer})
end
def archive_import def archive_import
@p_customer = PCustomer.find(params[:id]) @p_customer = PCustomer.find(params[:id])
end end
def import3 def import3
if false #params[:force] if false #params[:force]
require "csv" require "csv"
@ -198,6 +233,36 @@ class Admin::PCustomersController < ApplicationController
#params[:search][:enabled] = "Oui" if !params[:search][:enabled]
if params[:search][:enabled].to_s == "Oui"
@p_customers = @p_customers.where(:enabled => true)
elsif params[:search][:enabled].to_s == "Non"
@p_customers = @p_customers.where(:enabled => false)
end
params[:search][:test_user] = "Non" if !params[:search][:test_user]
if params[:search][:test_user].to_s == "Oui"
@p_customers = @p_customers.where(:test_user => true)
elsif params[:search][:test_user].to_s == "Non"
@p_customers = @p_customers.where(:test_user => false)
end
if params[:search][:npai].to_s == "Oui"
@p_customers = @p_customers.where(:npai => true)
elsif params[:search][:npai].to_s == "Non"
@p_customers = @p_customers.where(:npai => false)
end
if params[:search][:sticker].to_s == "Oui"
@p_customers = @p_customers.where(:sticker => true)
elsif params[:search][:sticker].to_s == "Non"
@p_customers = @p_customers.where(:sticker => false)
end
if params[:code].to_s != "" if params[:code].to_s != ""
@p_customers = @p_customers.where("p_customers.code LIKE ?","#{params[:code]}%") @p_customers = @p_customers.where("p_customers.code LIKE ?","#{params[:code]}%")
end end
@ -206,6 +271,10 @@ class Admin::PCustomersController < ApplicationController
@p_customers = @p_customers.joins(:particulars).where("p_customers.code LIKE ? or particulars.organisation LIKE ? or particulars.name LIKE ? or particulars.firstname LIKE ?","%#{params[:name]}%", "%#{params[:name]}%", "%#{params[:name]}%", "%#{params[:name]}%") @p_customers = @p_customers.joins(:particulars).where("p_customers.code LIKE ? or particulars.organisation LIKE ? or particulars.name LIKE ? or particulars.firstname LIKE ?","%#{params[:name]}%", "%#{params[:name]}%", "%#{params[:name]}%", "%#{params[:name]}%")
end end
if params[:email].to_s != ""
@p_customers = @p_customers.where("p_customers.email LIKE ?","%#{params[:email]}%")
end
if params[:city].to_s != "" if params[:city].to_s != ""
@p_customers = @p_customers.joins(:particulars).where("particulars.cp LIKE ? or particulars.city LIKE ?","%#{params[:city]}%", "%#{params[:city]}%") @p_customers = @p_customers.joins(:particulars).where("particulars.cp LIKE ? or particulars.city LIKE ?","%#{params[:city]}%", "%#{params[:city]}%")
end end
@ -298,16 +367,95 @@ class Admin::PCustomersController < ApplicationController
@p_customers = @p_customers.distinct @p_customers = @p_customers.distinct
@p_customers = @p_customers.limit(50)
params[:per_page] = params[:per_page] || 50
per_page = params[:per_page]
page = (params[:page] and params[:page] != "") ? params[:page] : 1
@p_customers = @p_customers.page(page).per(per_page) respond_to do |format|
format.html{
params[:per_page] = params[:per_page] || 50
per_page = params[:per_page]
page = (params[:page] and params[:page] != "") ? params[:page] : 1
@p_customers = @p_customers.page(page).per(per_page)
}
format.csv {
@headers = []
@columns = []
PCustomer.qi_table_order.each do |key, value|
if value.instance_of? Hash
name = value[:name]
else
name = value
end
if name != "Actions"
@headers << name.to_s
@columns << key
end
end
xlsx_package = Axlsx::Package.new
wb = xlsx_package.workbook
wb.add_worksheet(name: "import") do |sheet|
sheet.add_row @headers
@p_customers.each do |p_customer|
line = []
@columns.each do |column|
if (p_customer.respond_to?("csv_"+column.to_s))
line << p_customer.send("csv_"+column.to_s)
elsif (p_customer.respond_to?(column))
if p_customer.send(column.to_s).class.to_s == "BigDecimal"
line << p_customer.send(column.to_s).to_s.gsub('.', ',')
else
line << p_customer.send(column.to_s)
end
else
line << column.to_s
end
end
sheet.add_row line, types: line.map{|t| self.cell_type_from_value(t)}
end
end
@final_file = "#{Rails.root}/private_medias/export-inscrits-#{Time.now.to_s.to_slug}.xlsx"
xlsx_package.serialize(@final_file)
send_file @final_file
}
end
end end
end end
def show def show
@p_customer = PCustomer.find(params[:id]) @p_customer = PCustomer.find(params[:id])
@ -330,6 +478,41 @@ class Admin::PCustomersController < ApplicationController
@p_customer = PCustomer.find(params[:id]) @p_customer = PCustomer.find(params[:id])
end end
def npai
@p_customer = PCustomer.find(params[:id])
end
def toggle_npai
@p_customer = PCustomer.find(params[:id])
if @p_customer.npai
@p_customer.npai = false
@p_customer.sticker = false
message = "NPAI levé"
mail_hist = MailHist.auto_generate_mail(:fr, "stickers-npai-a-jour", @p_customer.email, {:arguments => {}, :p_customer => @p_customer, :element => @p_customer})
else
@p_customer.npai = true
message = "NPAI signalé"
mail_hist = MailHist.auto_generate_mail(:fr, "stickers-npai", @p_customer.email, {:arguments => {}, :p_customer => @p_customer, :element => @p_customer})
end
@p_customer.save
@p_customer.particular.generate_hist(message) if @p_customer.particular
redirect_back(fallback_location:"/")
end
def create def create
@p_customer = PCustomer.new(params.require(:p_customer).permit!) @p_customer = PCustomer.new(params.require(:p_customer).permit!)
@ -487,6 +670,30 @@ class Admin::PCustomersController < ApplicationController
end
def update_stickers
if params[:file]
data = Roo::Spreadsheet.open(params[:file].tempfile.path, extension: :xlsx) # open spreadsheet
headers = data.row(1) # get header row
@data = []
data.each_with_index do |row, idx|
next if idx == 0 # skip header
# create hash from headers and cells
user_data = Hash[[headers, row].transpose]
@data << user_data
end
end
end end

View File

@ -22,8 +22,10 @@ class Admin::PStatsController < ApplicationController
if params[:start] and params[:start] =~ date_regex if params[:start] and params[:start] =~ date_regex
@start = Date.parse(params[:start]).beginning_of_day @start = Date.parse(params[:start]).beginning_of_day
else elsif !params[:start]
@start = Date.today.beginning_of_month @start = Date.today.beginning_of_year
else
@start = Date.parse("2000-01-01")
end end
params[:start]= @start.strftime('%d/%m/%Y') params[:start]= @start.strftime('%d/%m/%Y')
@ -45,6 +47,100 @@ class Admin::PStatsController < ApplicationController
@finished = @p_customer_sheets.where(:state => ["livrée","facturée"]) @finished = @p_customer_sheets.where(:state => ["livrée","facturée"])
params[:search][:per_page] = params[:search][:per_page] || 500000
per_page = params[:search][:per_page]
page = (params[:page] and params[:page] != "") ? params[:page] : 1
@m_odr_primes = MOdrPrime.where("m_odr_primes.created_at >= ? and m_odr_primes.created_at < ?",@start.beginning_of_year, @stop).where(:state => ["Virement envoyé"])
@m_odr_primes = @m_odr_primes.joins(:p_customer)
@m_odr_primes = @m_odr_primes.where("m_odr_primes.created_at >= ?", @start)
@m_odr_primes = sort_by_sorting(@m_odr_primes, "m_odr_primes.cc_virement_date DESC")
@all_m_odr_primes = @m_odr_primes
@m_odr_primes = @m_odr_primes.page(page).per(per_page)
respond_to do |format|
format.html{
params[:per_page] = params[:per_page] || 50
per_page = params[:per_page]
page = (params[:page] and params[:page] != "") ? params[:page] : 1
@m_odr_primes = @m_odr_primes.page(page).per(per_page)
}
format.csv {
@headers = []
@columns = []
MOdrPrime.qi_table_order.each do |key, value|
if value.instance_of? Hash
name = value[:name]
else
name = value
end
if name != "Actions"
@headers << name.to_s
@columns << key
end
end
xlsx_package = Axlsx::Package.new
wb = xlsx_package.workbook
wb.add_worksheet(name: "import") do |sheet|
sheet.add_row @headers
@m_odr_primes.each do |m_odr_prime|
line = []
@columns.each do |column|
if (m_odr_prime.respond_to?("csv_"+column.to_s))
line << m_odr_prime.send("csv_"+column.to_s)
elsif (m_odr_prime.respond_to?(column))
if m_odr_prime.send(column.to_s).class.to_s == "BigDecimal"
line << m_odr_prime.send(column.to_s).to_s.gsub('.', ',')
else
line << m_odr_prime.send(column.to_s)
end
else
line << column.to_s
end
end
sheet.add_row line, types: line.map{|t| self.cell_type_from_value(t)}
end
end
@final_file = "#{Rails.root}/private_medias/export-primes-#{Time.now.to_s.to_slug}.xlsx"
xlsx_package.serialize(@final_file)
send_file @final_file
}
end
end end

View File

@ -0,0 +1,76 @@
# -*- encoding : utf-8 -*-
class Admin::ParticularHistsController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "default"
end
def index
@particular_hists = ParticularHist.all
@particular_hists = sort_by_sorting(@particular_hists, "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
@particular_hists = @particular_hists.page(page).per(per_page)
}
end
end
def show
@particular_hist = ParticularHist.find(params[:id])
end
def new
@particular_hist = ParticularHist.new
end
def edit
@particular_hist = ParticularHist.find(params[:id])
end
def create
@particular_hist = ParticularHist.new(params.require(:particular_hist).permit!)
if @particular_hist.save
else
render action: "new"
end
end
def update
@particular_hist = ParticularHist.find(params[:id])
if @particular_hist.update_attributes(params.require(:particular_hist).permit!)
else
render action: "edit"
end
end
def destroy
@particular_hist = ParticularHist.find(params[:id])
@particular_hist.destroy
end
end

View File

@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
require "csv"
before_action :set_locale before_action :set_locale
@ -162,6 +162,29 @@ class ApplicationController < ActionController::Base
end end
def cell_type_from_value(v)
if v.is_a?(Date)
:date
elsif v.is_a?(String)
:string
elsif v.is_a?(Time)
:time
elsif v.is_a?(TrueClass) || v.is_a?(FalseClass)
:boolean
elsif v.to_s =~ /\A[+-]?\d+?\Z/ #numeric
:integer
elsif v.to_s =~ /\A[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\Z/ #float
:float
# \A(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])
# T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?
# (Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?\Z
elsif v.to_s =~/\A(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?\Z/
:iso_8601
else
:string
end
end
@ -240,5 +263,7 @@ class ApplicationController < ActionController::Base
helper_method :current_admin, :get_specific_pref, :sort_by_sorting, :current_p_customer helper_method :current_admin, :get_specific_pref, :sort_by_sorting, :current_p_customer
end end

View File

@ -6,6 +6,8 @@ class Public::MEventsController < ApplicationController
def index def index
@m_events = MEvent.all @m_events = MEvent.all
@m_events = @m_events.joins(:organisateur).where(:organisateurs => {:public => true})
params[:search] = params[:search] || [] params[:search] = params[:search] || []
@m_events = @m_events.where("start_at >= ? or end_at >= ?", Date.today.beginning_of_day, Date.today.beginning_of_day) @m_events = @m_events.where("start_at >= ? or end_at >= ?", Date.today.beginning_of_day, Date.today.beginning_of_day)

View File

@ -55,6 +55,9 @@ class Public::MOdrRepRibsController < ApplicationController
@m_odr_rep = @m_odr_rep_rib.m_odr_rep @m_odr_rep = @m_odr_rep_rib.m_odr_rep
if @m_odr_rep_rib.update_attributes(params.require(:m_odr_rep_rib).permit!) if @m_odr_rep_rib.update_attributes(params.require(:m_odr_rep_rib).permit!)
@m_odr_rep_rib.admin_ok = nil
@m_odr_rep_rib.mail_sended = false
@m_odr_rep_rib.save
redirect_to public_my_account_path, :notice => "Votre RIB a bien été modifié" redirect_to public_my_account_path, :notice => "Votre RIB a bien été modifié"
else else
render action: "edit" render action: "edit"

View File

@ -4,7 +4,7 @@ class Public::OrganisateursController < ApplicationController
def index def index
@organisateurs = Organisateur.order(:name).all @organisateurs = Organisateur.order(:name).where(:public => true).all
@organisateurs_active = true @organisateurs_active = true
@ -35,9 +35,7 @@ class Public::OrganisateursController < ApplicationController
def show def show
@organisateurs_active = true @organisateurs_active = true
if @organisateur = Organisateur.where(:id => params[:id]).first if @organisateur = Organisateur.where(:slug => params[:id]).first
elsif @organisateur = Organisateur.where(:slug => params[:id]).first
else else
redirect_to public_organisateurs_path redirect_to public_organisateurs_path

View File

@ -13,7 +13,7 @@ class Public::PCustomerAuthsController < ApplicationController
@p_customer.save @p_customer.save
mail_hist = MailHist.auto_generate_mail(:fr, "confirmation-inscription", @p_customer.email, {:arguments => {:nbr_inscrits => PCustomer.count}, :p_customer => @p_customer}) mail_hist = MailHist.auto_generate_mail(:fr, "confirmation-inscription", @p_customer.email, {:arguments => {:nbr_inscrits => PCustomer.where(:enabled => true, :test_user => false).count}, :p_customer => @p_customer})
end end

View File

@ -6,6 +6,12 @@ class Public::PCustomersController < ApplicationController
@p_customer = PCustomer.new() @p_customer = PCustomer.new()
if params[:a] and parent = PCustomer.where(:mlm_token => params[:a].to_s.upcase).first
@p_customer.parent_code = parent.mlm_token
parent.update_token_count
end
@p_customer.particulars << Particular.new(:pro => false, :skip_validation => true) @p_customer.particulars << Particular.new(:pro => false, :skip_validation => true)
@p_customer.valid_public = true @p_customer.valid_public = true
end end
@ -30,7 +36,7 @@ class Public::PCustomersController < ApplicationController
cookies[:p_customer_auth_token] = @p_customer.auth_token cookies[:p_customer_auth_token] = @p_customer.auth_token
mail_hist = MailHist.auto_generate_mail(:fr, "confirmer-inscription", @p_customer.email, {:arguments => {:lien => valid_account_public_p_customer_auths_url(:token => @p_customer.mlm_token) }, :p_customer => @p_customer}) mail_hist = MailHist.auto_generate_mail(:fr, "confirmer-inscription", @p_customer.email, {:arguments => {:lien => "<a href='#{valid_account_public_p_customer_auths_url(:token => @p_customer.mlm_token)}' >#{valid_account_public_p_customer_auths_url(:token => @p_customer.mlm_token)}</a>" }, :p_customer => @p_customer})
#mail_hist = MailHist.generate_mail(:fr, MailType.find_or_create("new_account"), @p_customer.email, {:arguments => {:email => @p_customer.email}, :p_customer => @p_customer, :element => @p_customer}) #mail_hist = MailHist.generate_mail(:fr, MailType.find_or_create("new_account"), @p_customer.email, {:arguments => {:email => @p_customer.email}, :p_customer => @p_customer, :element => @p_customer})

View File

@ -48,11 +48,26 @@ class Public::ParticularsController < ApplicationController
def update def update
allready_fill = current_p_customer.particular_fill?
@particular = current_p_customer.particulars.find(params[:id]) @particular = current_p_customer.particulars.find(params[:id])
if @particular.update_attributes(params.require(:particular).permit!) if @particular.update_attributes(params.require(:particular).permit!)
if !allready_fill and pc = PCustomer.find(current_p_customer.id) and pc.particular_fill? and !pc.particular_thankable
mail_hist = MailHist.auto_generate_mail(:fr, "utilisateur-remerciement-infos", current_p_customer.email, {:arguments => {}, :p_customer => current_p_customer, :element => current_p_customer})
current_p_customer.particular_thankable = true
current_p_customer.save
end
redirect_to public_my_account_path redirect_to public_my_account_path

View File

@ -7,7 +7,10 @@ module DocumentLineHelper
end end
def link_to_add_fields(name, f, association, options={}) def link_to_add_fields(name, f, association, options={})
new_object = f.object.class.reflect_on_association(association).klass.new()
options[:attributes] = options[:attributes] || {}
new_object = f.object.class.reflect_on_association(association).klass.new(options[:attributes])
if association == :product_options if association == :product_options

View File

@ -59,7 +59,7 @@ class Circuit < ApplicationRecord
before_save do before_save do
self.slug = "#{self.name} #{self.cp} #{self.city}".to_slug if !self.slug self.slug = "#{self.name} #{self.cp} #{self.city}".to_slug if !self.slug?
end end
end end

View File

@ -1,6 +1,7 @@
class CircuitRegion < ApplicationRecord class CircuitRegion < ApplicationRecord
acts_as_csv_import :fields => [:name] acts_as_csv_import :fields => [:name]
belongs_to :circuit_region_cat
acts_as_sorting :fields => { acts_as_sorting :fields => {
:name => {:name => "Nom",:reorder => true}, :name => {:name => "Nom",:reorder => true},
:actions => {:name => "Actions"} :actions => {:name => "Actions"}

View File

@ -0,0 +1,10 @@
class CircuitRegionCat < ApplicationRecord
has_many :circuit_regions, -> { order("name") }
acts_as_sorting fields: {
name: { name: "Nom", reorder: true },
position: { name: "Position", reorder: true },
actions: "Actions"
}
end

View File

@ -6,6 +6,8 @@ class ImportCsv < ApplicationRecord
has_many :import_csv_elements has_many :import_csv_elements
has_many :elements, :through => :import_csv_elements
acts_as_tree acts_as_tree
validates :file, :presence => true validates :file, :presence => true
@ -41,10 +43,10 @@ class ImportCsv < ApplicationRecord
end end
self.table_name.classify.constantize.import_csv_fields.each do |h| self.table_source.classify.constantize.import_csv_fields.each do |h|
if self.parent and c = self.parent.import_csv_champs.where(:champ => h.to_s).first 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) self.import_csv_champs.new(:champ => h.to_s, :header => c.header, :value => c.value)
else elsif !self.parent
self.import_csv_champs.new(:champ => h.to_s) self.import_csv_champs.new(:champ => h.to_s)
end end
@ -56,6 +58,15 @@ class ImportCsv < ApplicationRecord
end end
def table_source
if self.table_name == "val_de_vienne"
name = "p_customer"
else
name = self.table_name
end
end
def charge def charge
if false if false
@ -87,7 +98,7 @@ class ImportCsv < ApplicationRecord
end end
def load def load
self.table_name.classify.constantize.import_csv(self.charge, self) self.table_source.classify.constantize.import_csv(self.charge, self)

View File

@ -22,7 +22,7 @@ class MEvent < ApplicationRecord
belongs_to :image_file belongs_to :image_file
def member_label def member_label
self.start_at.to_date.to_s+" - "+self.title.to_s+" - "+(self.organisateur.name if self.organisateur).to_s self.start_at.to_date.to_s+" - "+(self.end_at.to_date.to_s+" - " if self.start_at.to_date != self.end_at.to_date).to_s+self.title.to_s+" - "+(self.organisateur.name if self.organisateur).to_s
end end

View File

@ -5,24 +5,54 @@ class MOdrFile < ApplicationRecord
belongs_to :m_odr_place belongs_to :m_odr_place
belongs_to :m_event belongs_to :m_event
has_one :particular, :through => :p_customer
has_many :mail_hists has_many :mail_hists
has_many :m_odr_file_products, :dependent => :destroy has_many :m_odr_file_products, :dependent => :destroy
accepts_nested_attributes_for :m_odr_file_products, :allow_destroy => true accepts_nested_attributes_for :m_odr_file_products, :allow_destroy => true
validates_associated :m_odr_file_products
has_many :m_odr_file_roulages, :dependent => :destroy has_many :m_odr_file_roulages, :dependent => :destroy
accepts_nested_attributes_for :m_odr_file_roulages, :allow_destroy => true accepts_nested_attributes_for :m_odr_file_roulages, :allow_destroy => true
mount_uploader :file, OdrUploader mount_uploader :file, OdrUploader
validates :file, :presence => true validates :file, :presence => true, :if => :file_needed?
before_create { generate_token() } before_create { generate_token() }
validates :buy_at, :presence => true, :if => :buy_at_needed? validates :buy_at, :presence => true, :if => :buy_at_needed?
acts_as_caching :fields => [:doc_date]
def file_needed?
true if !self.id
end
def ca_doc_date
if self.m_odr_file_type_id == 1
if m_odr_file_roulage = self.m_odr_file_roulages.order("date DESC").first
m_odr_file_roulage.date
else
self.created_at
end
elsif self.m_odr_file_type_id == 2
if self.buy_at
self.buy_at
else
self.created_at
end
end
end
def buy_at_needed? def buy_at_needed?
true if self.m_odr_file_type_id == 2 true if self.m_odr_file_type_id == 2
end end
@ -62,13 +92,24 @@ class MOdrFile < ApplicationRecord
self.nbr_primes_not_useds = self.nbr_primes - nbr_primes_useds self.nbr_primes_not_useds = self.nbr_primes - nbr_primes_useds
elsif self.m_odr_file_type_id == 2 elsif self.m_odr_file_type_id == 2
nbr_pneus = 0 self.nbr_pneus = 0
self.m_odr_file_products.each do |mofp| self.m_odr_file_products.each do |mofp|
nbr_pneus += mofp.qte.to_i self.nbr_pneus += mofp.qte.to_i
end
if self.nbr_pneus > 2
self.nbr_pneus = 2
end end
self.nbr_pneus = nbr_pneus
self.nbr_pneus_not_useds = self.nbr_pneus - self.nbr_pneus_useds.to_i self.nbr_pneus_not_useds = self.nbr_pneus - self.nbr_pneus_useds.to_i
end end
end end
@ -104,7 +145,7 @@ class MOdrFile < ApplicationRecord
acts_as_sorting :fields => { acts_as_sorting :fields => {
:id => {:name => "Id", :reorder => true}, :id => {:name => "Id", :reorder => true},
:created_at => {:name => "Date de téléchargement", :reorder => true}, :created_at => {:name => "Date de téléchargement", :reorder => true},
:p_customer => {:name => "Utilisateur"}, :p_customer => {:name => "Utilisateur", :reorder => true, :sort_name => "p_customers.cc_show_name"},
:m_odr_file_type => {:name => "Type de document"}, :m_odr_file_type => {:name => "Type de document"},
:admin_ok => {:name => "Décision", :reorder => true}, :admin_ok => {:name => "Décision", :reorder => true},
:reject_reason => {:name => "Raison du rejet", :reorder => true}, :reject_reason => {:name => "Raison du rejet", :reorder => true},

View File

@ -5,6 +5,26 @@ class MOdrFileProduct < ApplicationRecord
#validates :qte, :presence => true, numericality: { greater_than: 0} #validates :qte, :presence => true, numericality: { greater_than: 0}
attr_accessor :admin_form
validates :qte, :presence => true, :if => :is_tire_admin_form?
validates :price, :presence => true, :if => :is_tire_admin_form?
validates :m_odr_product_size_id, :presence => true, :if => :is_tire_admin_form?
def is_tire_admin_form?
if self.m_odr_file and self.m_odr_file.m_odr_file_type_id == 2
if self.admin_form
true
else
false
end
else
false
end
end
before_save do before_save do
if self.m_odr_product_size if self.m_odr_product_size

View File

@ -15,37 +15,41 @@ class MOdrFileRoulage < ApplicationRecord
def generate_prime def generate_prime
prime_ids = [] prime_ids = []
if nbr_primes_to_use = self.nbr_primes_not_useds and nbr_primes_to_use > 0
if self.m_odr_file.p_customer.m_odr_primes.where("created_at > ?", Date.today.beginning_of_year).count < 5
if nbr_primes_to_use = self.nbr_primes_not_useds and nbr_primes_to_use > 0
if achats = MOdrFile.where(:admin_ok => true, :p_customer_id => self.m_odr_file.p_customer_id,:m_odr_file_type_id => 2).where("buy_at <= ? and nbr_pneus_not_useds > 0", self.date) and (achats.sum(:nbr_pneus_not_useds) > 0) if achats = MOdrFile.where(:admin_ok => true, :p_customer_id => self.m_odr_file.p_customer_id,:m_odr_file_type_id => 2).where("buy_at <= ? and nbr_pneus_not_useds > 0 and buy_at >= ? and buy_at <= ?", self.date, self.date.beginning_of_year, self.date.end_of_year) and (achats.sum(:nbr_pneus_not_useds) > 0)
state = "A traiter" state = "A traiter"
prime = MOdrPrime.new(:state => state, :m_odr_file_roulage => self, :p_customer_id => self.m_odr_file.p_customer_id) prime = MOdrPrime.new(:state => state, :m_odr_file_roulage => self, :p_customer_id => self.m_odr_file.p_customer_id)
n_tot = 0 n_tot = 0
achats.each do |a| achats.each do |a|
if n_tot < nbr_primes_to_use if n_tot < nbr_primes_to_use
if (nbr_primes_to_use - n_tot) <= a.nbr_pneus_not_useds if (nbr_primes_to_use - n_tot) <= a.nbr_pneus_not_useds
n = (nbr_primes_to_use - n_tot) n = (nbr_primes_to_use - n_tot)
else else
n = a.nbr_pneus_not_useds n = a.nbr_pneus_not_useds
end
prime.m_odr_prime_files.build(:m_odr_file => a, :nbr_pneus => n, :amount => n*15.0)
a.nbr_pneus_useds = a.nbr_pneus_useds.to_i + n
prime.save
a.save
prime_ids << prime.id
n_tot = n_tot + n
self.nbr_primes_useds = self.nbr_primes_useds.to_i + n
self.save
end end
prime.m_odr_prime_files.build(:m_odr_file => a, :nbr_pneus => n, :amount => n*15.0)
a.nbr_pneus_useds = a.nbr_pneus_useds.to_i + n
prime.save
a.save
prime_ids << prime.id
n_tot = n_tot + n
self.nbr_primes_useds = self.nbr_primes_useds.to_i + n
self.save
end end
end end
end end

View File

@ -2,24 +2,77 @@ class MOdrPrime < ApplicationRecord
belongs_to :p_customer belongs_to :p_customer
belongs_to :m_odr_file_roulage belongs_to :m_odr_file_roulage
has_one :particular, :through => :p_customer
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
include ActionView::Helpers::TranslationHelper include ActionView::Helpers::TranslationHelper
include ActionView::Helpers::UrlHelper include ActionView::Helpers::UrlHelper
has_many :m_odr_prime_files #, :dependent => :destroy has_many :m_odr_prime_files #, :dependent => :destroy
has_many :m_odr_files, :through => :m_odr_prime_files
has_many :m_odr_places, :through => :m_odr_files
has_many :m_odr_file_products, :through => :m_odr_files
has_many :m_odr_products, :through => :m_odr_file_products
has_many :mail_hists has_many :mail_hists
has_many :m_odr_virements has_many :m_odr_virements
acts_as_sorting :fields => { acts_as_sorting :fields => {
:id => {:name => "Id", :reorder => true}, :id => {:name => "Id", :reorder => true},
:p_customer => {:name => "Client"}, #:p_customer => {:name => "Client", :reorder => true, :sort_name => "p_customers.cc_show_name"},
:p_customer_created_at => {:name => "Inscription", :reorder => true, :sort_name => "p_customers.created_at"},
:particular_name => {:name => "Nom", :reorder => true, :sort_name => "p_customers.cc_particular_name"},
:particular_firstname => {:name => "Prénom", :reorder => true, :sort_name => "p_customers.cc_particular_firstname"},
:amount => {:name => "Montant", :as => :currency},
:created_at => {:name => "Date"},
:pneu_gamme => {:name => "Gamme"},
#:pneu_tailles => {:name => "Tailles"},
:m_odr_place_name => {:name => "Revendeur - Nom"},
:m_odr_place_cp=> {:name => "Revendeur - CP"},
:m_odr_place_city => {:name => "Revendeur - Ville"},
:organisateur_name => {:name => "Organisateur"},
:date_roulage => {:name => "Date de roulage", :reorder => true, :sort_name => "m_odr_file_roulages.date"},
:state => {:name => "Statut", :reorder => true}, :state => {:name => "Statut", :reorder => true},
:amount => {:name => "Montant"}, #:date_virement => {:name => "Date de virement"},
:cc_virement_date => {:name => "Date de virement", :reorder => true},
:actions => {:name => "Actions", :reorder => true}, :actions => {:name => "Actions", :reorder => true},
} }
acts_as_caching :fields => [:virement_date]
def ca_virement_date
virement = self.m_odr_virements.where(:refused => 0, :sended => 1).order('id DESC').first
if virement and virement.m_odr_remise
virement.m_odr_remise.created_at
else
nil
end
end
before_validation do before_validation do
@ -95,4 +148,69 @@ class MOdrPrime < ApplicationRecord
end end
def csv_particular_name
self.particular.name if self.particular
end
def csv_particular_firstname
self.particular.firstname if self.particular
end
def csv_p_customer_created_at
self.p_customer.created_at if self.p_customer
end
def csv_state
self.state
end
def csv_date_roulage
self.m_odr_file_roulage.date if self.m_odr_file_roulage
end
def csv_pneu_gamme
self.m_odr_products.uniq.map{ |u| (u.name)}.join(" | ")
end
def csv_m_odr_place_name
self.m_odr_places.uniq.map{ |u| u.name}.join(" | ")
end
def csv_m_odr_place_cp
self.m_odr_places.uniq.map{ |u| u.cp}.join(" | ")
end
def csv_m_odr_place_city
self.m_odr_places.uniq.map{ |u| u.city}.join(" | ")
end
def csv_organisateur_name
self.m_odr_file_roulage.m_event.organisateur.name if self.m_odr_file_roulage and self.m_odr_file_roulage.m_event and self.m_odr_file_roulage.m_event.organisateur
end
def csv_date_virement
virement = self.m_odr_virements.where(:refused => 0, :sended => 1).order('id DESC').first
if virement and virement.m_odr_remise
virement.m_odr_remise.created_at
end
end
end end

View File

@ -4,6 +4,7 @@ class MOdrProduct < ApplicationRecord
belongs_to :m_odr belongs_to :m_odr
has_many :m_odr_product_sizes has_many :m_odr_product_sizes
accepts_nested_attributes_for :m_odr_product_sizes, :allow_destroy => true
has_many :m_odr_product_remises, :dependent => :destroy has_many :m_odr_product_remises, :dependent => :destroy
accepts_nested_attributes_for :m_odr_product_remises, :allow_destroy => true accepts_nested_attributes_for :m_odr_product_remises, :allow_destroy => true

View File

@ -3,6 +3,8 @@ class MOdrProductSize < ApplicationRecord
acts_as_csv_import :fields => [:name, :m_odr_product_id, :position, :sap] acts_as_csv_import :fields => [:name, :m_odr_product_id, :position, :sap]
default_scope { order(name: :asc) }
def member_label def member_label
if self.m_odr_product if self.m_odr_product
"#{self.m_odr_product.name} - #{self.name} - #{self.position}" "#{self.m_odr_product.name} - #{self.name} - #{self.position}"

View File

@ -24,6 +24,8 @@ class MOdrRepRib < ApplicationRecord
:admin_ok => {:name => "Décision", :reorder => true}, :admin_ok => {:name => "Décision", :reorder => true},
:reject_reason => {:name => "Raison du rejet", :reorder => true}, :reject_reason => {:name => "Raison du rejet", :reorder => true},
:reject_reason_description => {:name => "Raison du rejet : commentaire", :reorder => true}, :reject_reason_description => {:name => "Raison du rejet : commentaire", :reorder => true},
:updated_at => {:name => "Date de modification", :reorder => true},
:actions => {:name => "Actions", :reorder => true}, :actions => {:name => "Actions", :reorder => true},
} }

View File

@ -5,6 +5,7 @@ class MOdrVirement < ApplicationRecord
belongs_to :m_odr_prime belongs_to :m_odr_prime
belongs_to :m_odr_remise belongs_to :m_odr_remise
has_one :p_customer, :through => :m_odr_prime

View File

@ -43,7 +43,7 @@ class Organisateur < ApplicationRecord
end end
before_save do before_save do
self.slug = "#{self.name} #{self.cp} #{self.city}".to_slug if !self.slug self.slug = "#{self.name} #{self.cp} #{self.city}".to_slug if !self.slug?
end end
end end

View File

@ -2,6 +2,8 @@ class PCustomer < ApplicationRecord
acts_as_tree acts_as_tree
has_many :particular_hists
has_many :price_documents has_many :price_documents
has_many :particulars, :as => :owner, :dependent => :destroy has_many :particulars, :as => :owner, :dependent => :destroy
@ -71,7 +73,10 @@ class PCustomer < ApplicationRecord
validates :cgv, :presence => true, :if => :require_cgv validates :cgv, :presence => true, :if => :require_cgv
#validates :rgpd, :presence => true, :if => :require_cgv #validates :rgpd, :presence => true, :if => :require_cgv
validates :past_id, :uniqueness => true, :if => :imported #validates :past_id, :uniqueness => true, :if => :imported
acts_as_caching :fields => [:show_name, :particular_name, :particular_firstname]
attr_accessor :refresh_import attr_accessor :refresh_import
@ -122,15 +127,15 @@ class PCustomer < ApplicationRecord
self.sticker = true self.sticker = true
end end
if circuit = Circuit.where(:past_id => self.imp_circuit_1).first if self.imp_circuit_1? and circuit = Circuit.where(:past_id => self.imp_circuit_1).first
self.circuit_1_id = circuit.id self.circuit_1_id = circuit.id
end end
if circuit = Circuit.where(:past_id => self.imp_circuit_2).first if self.imp_circuit_2? and circuit = Circuit.where(:past_id => self.imp_circuit_2).first
self.circuit_2_id = circuit.id self.circuit_2_id = circuit.id
end end
if circuit = Circuit.where(:past_id => self.imp_circuit_3).first if self.imp_circuit_3? and circuit = Circuit.where(:past_id => self.imp_circuit_3).first
self.circuit_3_id = circuit.id self.circuit_3_id = circuit.id
end end
@ -155,7 +160,12 @@ class PCustomer < ApplicationRecord
self.do_import if self.refresh_import == "true" self.do_import if self.refresh_import == "true"
end 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, :refresh_import]
before_validation do
self.generate_mdp = true if !self.id and self.import_name == "val"
end
acts_as_csv_import :fields =>[:generate_mdp, :imported,:import_name,:unlimited, :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, :refresh_import]
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
@ -197,7 +207,13 @@ class PCustomer < ApplicationRecord
before_validation do before_validation do
if !self.id and self.import_name = "val"
if p = PCustomer.where(:email => self.email).first
p.unlimited = true
p.import_name = "val"
p.save
end
end
if self.valid_last_password and !PCustomer.find(self.id).authenticate(self.actual_password) if self.valid_last_password and !PCustomer.find(self.id).authenticate(self.actual_password)
@ -234,9 +250,12 @@ class PCustomer < ApplicationRecord
self.generate_mdp = false self.generate_mdp = false
if self.save if self.save
#GeneralMailer.send_qi_mail("fr", "generation_mdp", self.email, {"mdp" => ps}).deliver #GeneralMailer.send_qi_mail("fr", "generation_mdp", self.email, {"mdp" => ps}).deliver
if self.import_name.to_s == "val"
mail_hist = MailHist.generate_mail(:fr, MailType.find_by_slug("import_val_de_vienne"), self.email, {:arguments => {:mdp => ps, :civilite => self.particular.civilite, :nom => self.particular.name, :prenom => self.particular.firstname }, :p_customer => self, :element => self})
else
mail_hist = MailHist.generate_mail(:fr, MailType.find_by_slug("generation_mdp"), self.email, {:arguments => {:mdp => ps, :civilite => self.particular.civilite, :nom => self.particular.name, :prenom => self.particular.firstname }, :p_customer => self, :element => self}) mail_hist = MailHist.generate_mail(:fr, MailType.find_by_slug("generation_mdp"), self.email, {:arguments => {:mdp => ps, :civilite => self.particular.civilite, :nom => self.particular.name, :prenom => self.particular.firstname }, :p_customer => self, :element => self})
end
else else
end end
@ -245,15 +264,37 @@ class PCustomer < ApplicationRecord
end end
def update_token_count
self.link_token_count = self.link_token_count.to_i + 1
self.save
end
def self.qi_table_order def self.qi_table_order
{ {
:created_at => {:name => "Date de création", :reorder => true, :as => :date}, :created_at => {:name => "Date de création", :reorder => true, :as => :date},
:show_name => "Nom", :name => {:name => "Nom", :reorder => true, :sort_name => "particulars.name"},
:firstname => {:name => "Prénom", :reorder => true, :sort_name => "particulars.firstname"},
:mlm_token => {:name => "Code ambassadeur", :reorder => true}, :mlm_token => {:name => "Code ambassadeur", :reorder => true},
:enabled => "Actif ?", :enabled => "Actif ?",
:test_user => "Utilisateur test ?",
:npai => "NPAI ?",
:sticker => "Stickers envoyés ?",
:particular_fill => "Adresse remplie ?",
:parent => "Ambassadeur", :parent => "Ambassadeur",
:particular => "Ville",
:particular_address_2 => "Adresse",
:particular_address_3 => "Adresse (suite)",
:particular_cp => "Code postal",
:particular_city => "Ville",
:particular_country => "Pays",
:email => "Email",
:particular_tel => "Téléphone",
:link_token_count => {:name => "Nbr. aff. lien amb.", :reorder => true},
:actions => "Actions" :actions => "Actions"
} }
@ -262,11 +303,15 @@ class PCustomer < ApplicationRecord
def self.valid_sort def self.valid_sort
["code", "created_at", "cache_encours_th", "cache_encours", "cache_payments_th", "cache_payments", "cache_payments_tot", "cache_ca"] ["code", "cc_show_name","particulars.firstname","particulars.name", "created_at", "cache_encours_th", "cache_encours", "cache_payments_th", "cache_payments", "cache_payments_tot", "cache_ca"]
end end
def particular_fill?
true if self.particular.firstname? and self.particular.name? and self.particular.address_2? and self.particular.cp? and self.particular.city?
end
before_destroy do before_destroy do
if self.p_customer_sheets.count > 0 or self.p_payments.count > 0 if self.p_customer_sheets.count > 0 or self.p_payments.count > 0
false false
@ -470,17 +515,30 @@ class PCustomer < ApplicationRecord
end end
def show_name def ca_show_name
if self.particular if self.particular
n = "" n = ""
n += self.particular.organisation+" " if self.particular.organisation? n += self.particular.organisation+" " if self.particular.organisation?
n += self.particular.firstname+" " if self.particular.firstname?
n += self.particular.name+" " if self.particular.name? n += self.particular.name+" " if self.particular.name?
n += self.particular.firstname+" " if self.particular.firstname?
return n return n
end end
end end
def ca_particular_name
if self.particular
self.particular.name+" " if self.particular.name?
end
end
def ca_particular_firstname
if self.particular
self.particular.firstname+" " if self.particular.firstname?
end
end
def show_name_extend def show_name_extend
if self.particular if self.particular
@ -547,4 +605,57 @@ class PCustomer < ApplicationRecord
end end
def csv_parent
if self.parent
self.parent.mlm_token.to_s+" - "+self.show_name.to_s
end
end
def csv_mlm_token
self.mlm_token if self.ambassadeur
end
def csv_tel
self.particular.tel if self.particular
end
def csv_name
self.particular.name if self.particular
end
def csv_firstname
self.particular.firstname if self.particular
end
def csv_particular_address_2
self.particular.address_2 if self.particular
end
def csv_particular_address_3
self.particular.address_3 if self.particular
end
def csv_particular_cp
self.particular.cp if self.particular
end
def csv_particular_city
self.particular.city if self.particular
end
def csv_particular_country
self.particular.country if self.particular
end
def csv_particular_tel
self.particular.tel if self.particular
end
end end

View File

@ -100,4 +100,28 @@ class Particular < ApplicationRecord
end end
after_save do
self.generate_hist
end
def generate_hist(message = "Changement des coordonnées")
if self.owner_type == "PCustomer"
particular_hist = ParticularHist.new(:p_customer_id => self.owner_id, :particular_id => self.id)
[:civilite, :name, :firstname, :address_2, :address_3, :cp, :city, :country, :tel, :email].each do |att|
eval "particular_hist.#{att.to_s} = self.#{att.to_s}"
end
particular_hist.description = message
particular_hist.email = self.owner.email
particular_hist.npai = self.owner.npai
particular_hist.save
end
end
end end

View File

@ -0,0 +1,29 @@
class ParticularHist < ApplicationRecord
belongs_to :particular
belongs_to :p_customer
acts_as_sorting :fields => {
:id => {:name => "Id", :reorder => true},
# :p_customer => {:name => "Client", :reorder => true, :sort_name => "p_customers.cc_show_name"},
:created_at => {:name => "Date", :reorder => true},
:npai => {:name => "NPAI ?", :reorder => true, :as => :boolean},
:description => {:name => "Evenement", :reorder => true},
:civilite => {:name => "Civilité", :reorder => true},
:name => {:name => "Nom", :reorder => true},
:firstname => {:name => "Nom", :reorder => true},
#:address_1 => {:name => "Nom", :reorder => true},
:address_2 => {:name => "Adresse", :reorder => true},
:address_3 => {:name => "Adresse suite", :reorder => true},
:cp => {:name => "Code postal", :reorder => true},
:city => {:name => "Ville", :reorder => true},
:country => {:name => "Pays", :reorder => true},
:tel => {:name => "Tel", :reorder => true},
:email => {:name => "Email", :reorder => true},
#:actions => {:name => "Actions", :reorder => true},
}
end

View File

@ -17,7 +17,7 @@
.qi_kpi .qi_kpi
.kpi .kpi
.number .number
=PCustomer.where(:test_user => false).where("created_at >= ?", Date.today.beginning_of_day).count =PCustomer.where(:test_user => false, :enabled => true).where("created_at >= ?", Date.today.beginning_of_day).count
.label .label
Inscriptions Inscriptions
@ -27,7 +27,7 @@
.kpi .kpi
.number .number
=PCustomer.where(:test_user => false).where("created_at >= ? and created_at < ?",(Date.today.beginning_of_day-1.day), Date.today.beginning_of_day).count =PCustomer.where(:test_user => false, :enabled => true).where("created_at >= ? and created_at < ?",(Date.today.beginning_of_day-1.day), Date.today.beginning_of_day).count
.label .label
Inscriptions Inscriptions
@ -38,7 +38,7 @@
.kpi .kpi
.number .number
=PCustomer.where(:test_user => false).where("created_at >= ?", (Date.today - 7.day).beginning_of_day).count =PCustomer.where(:test_user => false, :enabled => true).where("created_at >= ?", (Date.today - 7.day).beginning_of_day).count
.label .label
Inscriptions Inscriptions
@ -47,7 +47,7 @@
.kpi .kpi
.number .number
=PCustomer.where(:test_user => false).where("created_at >= ?", (Date.today).beginning_of_year.beginning_of_day).count =PCustomer.where(:test_user => false, :enabled => true).where("created_at >= ?", (Date.today).beginning_of_year.beginning_of_day).count
.label .label
Inscriptions Inscriptions
@ -57,7 +57,7 @@
.kpi .kpi
.number .number
=PCustomer.where(:test_user => false).count =PCustomer.where(:test_user => false, :enabled => true).count
.label .label
Utilisateurs Utilisateurs

View File

@ -1,2 +1,2 @@
%li= link_to "Stats générales", admin_p_stats_path %li= link_to "Stats générales", admin_p_stats_path
%li= link_to "Export compta", admin_p_compta_exports_path -#%li= link_to "Export compta", admin_p_compta_exports_path

View File

@ -0,0 +1,16 @@
%tr#circuit_region_cat_row{:id => circuit_region_cat.id}
-tr = {}
-tr[:actions] = capture do
%td.actions
= link_to i(:"trash-o"), [:admin, circuit_region_cat], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
= link_to i(:pencil), edit_admin_circuit_region_cat_path(circuit_region_cat), :remote => true
= link_to i(:eye), admin_circuit_region_cat_path(circuit_region_cat), :remote => true
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => circuit_region_cat}

View File

@ -0,0 +1,13 @@
=semantic_form_for [:admin, @circuit_region_cat], :remote => true do |f|
.content
=f.inputs do
= f.input :name, :label => "name :"
= f.input :position, :label => "position :"
.actions=f.submit "sauvegarder", :class => "btn btn-primary"

View File

@ -0,0 +1,2 @@
$('#circuit_region_cats_rows').prepend("<%= escape_javascript(render(@circuit_region_cat))%>");
close_pane_hover();

View File

@ -0,0 +1 @@
$('#circuit_region_cat_row_<%= @circuit_region_cat.id %>').remove();

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -0,0 +1,15 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_circuit_region_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 => @circuit_region_cats}
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @circuit_region_cats}

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -0,0 +1,10 @@
.qi_header
%h1
%span
.qi_row
.qi_pannel.qi_plain.padding
=debug @circuit_region_cat

View File

@ -0,0 +1,2 @@
$('#circuit_region_cat_row_<%= @circuit_region_cat.id %>').replaceWith("<%= escape_javascript(render(@circuit_region_cat))%>");
close_pane_hover();

View File

@ -2,6 +2,7 @@
.content .content
=f.inputs do =f.inputs do
= f.input :circuit_region_cat, :label => "Grande région :"
= f.input :name, :label => "name :" = f.input :name, :label => "name :"

View File

@ -1,5 +1,5 @@
%tr.m_odr_product_remise_form.field %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} %td{:style => "width:200px;"}= form.input :champ, :label => false, :as => :select, :collection => @import_csv.table_source.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) -if !form.object.header? and @import_csv.import_csv_headers.all.map{|a| a.name}.include?(form.object.champ)

View File

@ -6,12 +6,12 @@
= 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 => ["p_customers", "circuits", "organisateurs", "m_odr_product_sizes", "m_odr_places", "circuit_regions", "m_events", "departement_frances"] = f.input :table_name, :label => "Table :" , :as => :select, :collection => ["p_customers", "circuits", "organisateurs", "m_odr_product_sizes", "m_odr_places", "circuit_regions", "m_events", "departement_frances", "val_de_vienne"]
-if f.object.id -if f.object.id
%table.import_csv_champs_form %table.import_csv_champs_form
-if f.object.import_csv_champs.count == 0 -if f.object.import_csv_champs.count == 0
-@import_csv.table_name.classify.constantize.import_csv_fields.each do |h| -@import_csv.table_source.classify.constantize.import_csv_fields.each do |h|
-f.object.import_csv_champs.new(:champ => h.to_s) -f.object.import_csv_champs.new(:champ => h.to_s)
=f.semantic_fields_for :import_csv_champs do |form| =f.semantic_fields_for :import_csv_champs do |form|

View File

@ -8,3 +8,7 @@
.qi_row .qi_row
.qi_pannel.qi_plain.padding .qi_pannel.qi_plain.padding
=debug @import_csv =debug @import_csv
%table
-@import_csv.import_csv_elements.all.each do |el|
=render el.element if el.element

View File

@ -9,8 +9,8 @@
=render :partial => "qi/autocomplete", :locals => {:form => f, :field => :organisateur, :label => "Organisateur :"} =render :partial => "qi/autocomplete", :locals => {:form => f, :field => :organisateur, :label => "Organisateur :"}
=# f.input :organisateur, :label => "Organisateur :", :member_label => :member_label, :collection => Organisateur.order("name").all =# f.input :organisateur, :label => "Organisateur :", :member_label => :member_label, :collection => Organisateur.order("name").all
= f.input :start_at, :label => "Date de début :", :as => :date = f.input :start_at, :label => "Date de début :", :as => :date, :input_html => {:id => "start_at_input"}
= f.input :end_at, :label => "Date de fin :" , :as => :date = f.input :end_at, :label => "Date de fin :" , :as => :date, :input_html => {:id => "end_at_input"}
= f.input :title, :label => "Titre :" = f.input :title, :label => "Titre :"
= f.input :link, :label => "Lien réservation :" = f.input :link, :label => "Lien réservation :"
= f.input :description, :label => "Description :" , :input_html => {:class => "redactor_textarea"} = f.input :description, :label => "Description :" , :input_html => {:class => "redactor_textarea"}
@ -27,6 +27,10 @@
:coffeescript
$("#start_at_input").focusout ->
if $("#end_at_input").val() == ""
$("#end_at_input").val($(this).val())
:javascript :javascript
$(".redactor_textarea").redactor({ $(".redactor_textarea").redactor({

View File

@ -11,6 +11,8 @@
-tr[:actions] = capture do -tr[:actions] = capture do
%td.actions %td.actions
=link_to i(:copy), new_admin_m_event_path(:parent_id => m_event.id), :remote => true
= link_to i(:"trash-o"), [:admin, m_event], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true = link_to i(:"trash-o"), [:admin, m_event], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
= link_to i(:pencil), edit_admin_m_event_path(m_event), :remote => true = link_to i(:pencil), edit_admin_m_event_path(m_event), :remote => true
= link_to i(:eye), admin_m_event_path(m_event), :remote => true = link_to i(:eye), admin_m_event_path(m_event), :remote => true

View File

@ -1,6 +1,9 @@
%tr.m_odr_file_product_form.field %tr.m_odr_file_product_form.field
%td %td
= form.input :admin_form, :as => :hidden
= form.input :m_odr_product_size_id, :label => "Produit :", :collection => option_groups_from_collection_for_select(MOdrProduct.all, :m_odr_product_sizes, :name, :id, :name, form.object.m_odr_product_size_id), :as => :select, :include_blank => false, :member_label => :member_label, :include_blank => "Choisissez le profil et la dimension" = form.input :m_odr_product_size_id, :label => "Produit :", :collection => option_groups_from_collection_for_select(MOdrProduct.all, :m_odr_product_sizes, :name, :id, :name, form.object.m_odr_product_size_id), :as => :select, :include_blank => false, :member_label => :member_label, :include_blank => "Choisissez le profil et la dimension"

View File

@ -1,11 +1,23 @@
%tr.m_odr_file_roulage_form.field %tr.m_odr_file_roulage_form.field
%td= form.input :date, :label => "date :" , :as => :date %td.td_roulage_date_input= form.input :date, :label => "date :" , :as => :date, :input_html => {:class => "roulage_date_input"}
-if form.object.date? -if form.object.date?
%td= form.input :m_event_id, :label => "Journée de roulage :", :as => :date, :collection => MEvent.order("start_at").where("start_at <= ? and end_at >= ?", form.object.date, form.object.date).all, :member_label => :member_label, :as => :select %td= form.input :m_event_id, :label => "Journée de roulage :", :as => :date, :collection => MEvent.order("start_at").where("start_at <= ? and end_at >= ?", form.object.date, form.object.date).all, :member_label => :member_label, :as => :select, :input_html => {:class => "select_date_input"}
-else -else
%td= form.input :m_event_id, :label => "Journée de roulage :", :as => :date, :collection => MEvent.all, :member_label => :member_label, :as => :select %td= form.input :m_event_id, :label => "Journée de roulage :", :as => :date, :collection => [], :member_label => :member_label, :as => :select, :input_html => {:class => "select_date_input"}
=#%td= form.input :m_event_id, :label => "Journée de roulage :", :as => :date, :collection => MEvent.all, :member_label => :member_label, :as => :select
%td.actions=link_to_remove_fields ic(:"trash-o"), form %td.actions=link_to_remove_fields ic(:"trash-o"), form
:coffeescript
$("body").on "change", ".td_roulage_date_input input", ->
obj = $(this)
$.getJSON "/admin/m_events/autocomplete.json?date="+$(this).val(), (data) ->
obj.closest(".field").find(".select_date_input").html("")
$.each data, ->
obj.closest(".field").find(".select_date_input").append '<option value="' + @id + '">' + @member_label + '</option>'

View File

@ -20,11 +20,13 @@
-if f.object.m_odr_file_type_id == 2 -if f.object.m_odr_file_type_id == 2
%table.m_odr_file_products_form.form-table %table.m_odr_file_products_form.form-table
= f.input :buy_at, :label => "Date de l'achat", :as => :date = f.input :buy_at, :label => "Date de l'achat", :as => :date
= f.input :m_odr_place, :label => "Revendeur :", :as => :date, :collection => MOdrPlace.order("enseigne ASC, name ASC, city ASC").all, :member_label => :member_label, :as => :select
=render :partial => "qi/autocomplete", :locals => {:form => f, :field => :m_odr_place, :label => "Revendeur :"}
=f.semantic_fields_for :m_odr_file_products do |form| =f.semantic_fields_for :m_odr_file_products do |form|
=render :partial => "admin/m_odr_file_products/form", :locals => {:form => form} =render :partial => "admin/m_odr_file_products/form", :locals => {:form => form}
%p= link_to_add_fields ic(:plus)+" Ajouter un produit", f, :m_odr_file_products %p= link_to_add_fields ic(:plus)+" Ajouter un produit", f, :m_odr_file_products, {:attributes => {:admin_form => true}}
-else -else

View File

@ -9,6 +9,21 @@
%hr
Historique des factures
-params[:search][:per_page] = params[:search][:per_page] || 50
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@m_odr_files = @m_odr_file.p_customer.m_odr_files.where("id != ?", @m_odr_file.id).where(:m_odr_file_type_id => @m_odr_file.m_odr_file_type_id )
-@m_odr_files = @m_odr_files.where("created_at >= ? and created_at <= ?", @m_odr_file.created_at.beginning_of_year, @m_odr_file.created_at.end_of_year)
-@m_odr_files = sort_by_sorting(@m_odr_files, "created_at DESC")
-@m_odr_files = @m_odr_files.page(page).per(per_page)
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_files}
.clear
.left{:style => "float:left;width:30%;"} .left{:style => "float:left;width:30%;"}
=render :partial => "form" =render :partial => "form"
@ -28,3 +43,6 @@
#image_previ{:style => "width:100%;height:800px;border:1px solid gray;overflow:auto;"} #image_previ{:style => "width:100%;height:800px;border:1px solid gray;overflow:auto;"}
=render :partial => "admin/m_odr_files/image", :locals => {:file => @m_odr_file} =render :partial => "admin/m_odr_files/image", :locals => {:file => @m_odr_file}

View File

@ -16,7 +16,8 @@
-params[:search] =params[:search] || {} -params[:search] =params[:search] || {}
%table %table
%tr %tr
%td %td=text_field_tag "search[name]", params[:search][:name],:class => "form-control", :placeholder => "Nom"
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @m_odr_files} =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @m_odr_files}

View File

@ -12,7 +12,19 @@
Historique des factures
-params[:search][:per_page] = params[:search][:per_page] || 50
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@m_odr_files = @m_odr_file.p_customer.m_odr_files.where("id != ?", @m_odr_file.id).where(:m_odr_file_type_id => @m_odr_file.m_odr_file_type_id )
-@m_odr_files = @m_odr_files.where("created_at >= ? and created_at <= ?", @m_odr_file.created_at.beginning_of_year, @m_odr_file.created_at.end_of_year)
-@m_odr_files = sort_by_sorting(@m_odr_files, "created_at DESC")
-@m_odr_files = @m_odr_files.page(page).per(per_page)
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_files}
%hr
.left{:style => "float:left;width:30%;"} .left{:style => "float:left;width:30%;"}
.qi_row .qi_row
@ -20,7 +32,7 @@
%table.table %table.table
%tr %tr
%td Utilisateur %td Utilisateur
%td=@m_odr_file.p_customer.show_name if @m_odr_file.p_customer %td=link_to @m_odr_file.p_customer.show_name, [:admin, @m_odr_file.p_customer] if @m_odr_file.p_customer
%tr %tr
%td Date de la facture %td Date de la facture
@ -65,8 +77,16 @@
%td %td
=m_odr_file_roulage.m_event.title if m_odr_file_roulage.m_event =m_odr_file_roulage.m_event.title if m_odr_file_roulage.m_event
-if @m_odr_file.m_odr_file_type_id == 2 -if @m_odr_file.admin_ok == true
=link_to ic(:envelope)+"Envoyer un mail demandant la facture de roulage", send_mail_admin_m_odr_file_path(@m_odr_file, :slug => "achat-manque-roulage"), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;" -if @m_odr_file.m_odr_file_type_id == 2
=link_to ic(:envelope)+"Envoyer un mail demandant la facture de roulage", send_mail_admin_m_odr_file_path(@m_odr_file, :slug => "achat-manque-roulage"), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;"
-else
-slugs = MailType.where(:mail_type_cat_id => 4).map{|m| m.slug}
-slugs.each do |slug|
%br
=link_to ic(:envelope)+" #{slug}", send_mail_admin_m_odr_file_path(@m_odr_file, :slug => slug), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;"
-if @m_odr_file.admin_ok == false -if @m_odr_file.admin_ok == false
@ -85,6 +105,7 @@
#show{:style => "margin-left:31%;"} #show{:style => "margin-left:31%;"}
=link_to ic(:download)+" Télécharger le document", download_admin_m_odr_file_path(@m_odr_file, :disposition => "attachment") =link_to ic(:download)+" Télécharger le document", download_admin_m_odr_file_path(@m_odr_file, :disposition => "attachment")
@ -113,3 +134,6 @@ Historique des mails envoyés
-@mail_hists = @mail_hists.page(page).per(per_page) -@mail_hists = @mail_hists.page(page).per(per_page)
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @mail_hists} =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @mail_hists}
.clear

View File

@ -1,14 +1,62 @@
%tr#m_odr_prime_row{:id => m_odr_prime.id} %tr#m_odr_prime_row{:id => m_odr_prime.id}
-tr = {} -tr = {}
-tr[:p_customer] = capture do -tr[:particular_name] = capture do
%td %td
=link_to m_odr_prime.p_customer.show_name, [:admin, m_odr_prime.p_customer] if m_odr_prime.p_customer =link_to m_odr_prime.particular.name, [:admin, m_odr_prime.p_customer] if m_odr_prime.particular
-tr[:particular_firstname] = capture do
%td
=link_to m_odr_prime.particular.firstname, [:admin, m_odr_prime.p_customer] if m_odr_prime.particular
-tr[:p_customer_created_at] = capture do
%td
=l m_odr_prime.p_customer.created_at if m_odr_prime.p_customer
-tr[:state] = capture do -tr[:state] = capture do
%td %td
=state_helper(m_odr_prime.state) =state_helper(m_odr_prime.state)
-tr[:date_roulage] = capture do
%td
=l m_odr_prime.m_odr_file_roulage.date if m_odr_prime.m_odr_file_roulage
-tr[:pneu_gamme] = capture do
%td
=m_odr_prime.m_odr_products.uniq.map{ |u| (u.name)}.join(" | ")
-tr[:m_odr_place_name] = capture do
%td
=m_odr_prime.m_odr_places.uniq.map{ |u| u.name}.join(" | ")
-tr[:m_odr_place_cp] = capture do
%td
=m_odr_prime.m_odr_places.uniq.map{ |u| u.cp}.join(" | ")
-tr[:m_odr_place_city] = capture do
%td
=m_odr_prime.m_odr_places.uniq.map{ |u| u.city}.join(" | ")
-tr[:organisateur_name] = capture do
%td
=m_odr_prime.m_odr_file_roulage.m_event.organisateur.name if m_odr_prime.m_odr_file_roulage and m_odr_prime.m_odr_file_roulage.m_event and m_odr_prime.m_odr_file_roulage.m_event.organisateur
-tr[:date_virement] = capture do
%td
-virement = m_odr_prime.m_odr_virements.where(:refused => 0, :sended => 1).order('id DESC').first
-if virement and virement.m_odr_remise
=l virement.m_odr_remise.created_at, :format => :date
-tr[:actions] = capture do -tr[:actions] = capture do
%td.actions %td.actions

View File

@ -9,7 +9,20 @@
.qi_search_row .qi_search_row
=form_tag "", :method => "get", :onsubmit => "" do =form_tag "", :method => "get", :onsubmit => "" do
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @m_odr_primes} =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @m_odr_primes, :csv => true}
-params[:search] =params[:search] || {}
%table
%tr
%td=text_field_tag "search[name]", params[:search][:name],:class => "form-control", :placeholder => "Nom"
%td
Statut :
=select_tag "search[state]", options_for_select([["",""]]+MOdrPrime.group(:state).order(:state).all.map{|a| [a.state, a.state]}, params[:search][:state])
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_primes} =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_primes}
@ -22,8 +35,8 @@
-if true -if true
-#MOdrPrime.reset_primes -#MOdrPrime.reset_primes
-PCustomer.all.each do |p_customer| -#PCustomer.all.each do |p_customer|
-p_customer.generate_prime -#p_customer.generate_prime

View File

@ -11,6 +11,21 @@
.qi_row .qi_row
.qi_pannel.qi_plain.padding .qi_pannel.qi_plain.padding
Dernières primes versées au client
-params[:search][:per_page] = params[:search][:per_page] || 50
-per_page = params[:search][:per_page]
-page = (params[:page] and params[:page] != "") ? params[:page] : 1
-@m_odr_primes = @m_odr_prime.p_customer.m_odr_primes.where("id != ? ", @m_odr_prime.id)
-@m_odr_primes = sort_by_sorting(@m_odr_primes, "created_at DESC")
-@m_odr_primes = @m_odr_primes.page(page).per(per_page)
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_primes}
%hr
#head=render :partial => "admin/m_odr_primes/head" #head=render :partial => "admin/m_odr_primes/head"
%h3 %h3
@ -73,15 +88,20 @@
%td %td
= link_to i(:pencil), edit_admin_m_odr_file_path(m_odr_prime_file.m_odr_file), :remote => false = link_to i(:pencil), edit_admin_m_odr_file_path(m_odr_prime_file.m_odr_file), :remote => false
-if @m_odr_prime.state == "Erreur sur virement" and @m_odr_prime.m_odr_virements.where(:refused => false).count == 0
=link_to "Générer le virement", generate_virement_admin_m_odr_prime_path(@m_odr_prime), :class => "btn btn-primary"
-if @m_odr_prime.state == "A traiter" and @m_odr_prime.m_odr_virements.where(:refused => false).count == 0 -if @m_odr_prime.state == "A traiter" or @m_odr_prime.state == "Validé" or @m_odr_prime.state == "En attente de roulage" and @m_odr_prime.m_odr_virements.where(:refused => false).count == 0
-if @m_odr_prime.m_odr_file_roulage.date? and @m_odr_prime.m_odr_file_roulage.date <= Date.today -if @m_odr_prime.m_odr_file_roulage.date? and @m_odr_prime.m_odr_file_roulage.date <= Date.today
=link_to "Générer le virement", generate_virement_admin_m_odr_prime_path(@m_odr_prime), :class => "btn btn-primary" =link_to "Générer le virement", generate_virement_admin_m_odr_prime_path(@m_odr_prime), :class => "btn btn-primary"
-else -else
%span.btn.btn-default
Vous pourrez générer le virement une fois la date de roulage passée.
-if @m_odr_prime.state == "En attente de roulage"
%span.btn.btn-default
Vous pourrez générer le virement une fois la date de roulage passée.
-else
=link_to 'Valider et passer au statut "en attente de roulage"', attente_roulage_admin_m_odr_prime_path(@m_odr_prime), :class => "btn btn-primary"
%hr %hr
Virements Virements
@ -113,3 +133,5 @@

View File

@ -2,4 +2,4 @@
%td= form.input :qte, :label => "Qté :" %td= form.input :qte, :label => "Qté :"
%td= form.input :amount, :label => "Montant :" %td= form.input :amount, :label => "Montant :"
%td.actions=link_to_remove_fields ic(:"trash-o"), form %td=link_to_remove_fields ic(:"trash-o"), form

View File

@ -1,15 +1,7 @@
=semantic_form_for [:admin, @m_odr_product_size], :remote => true do |f|
.content
=f.inputs do
= f.input :name, :label => "name :"
= f.input :position, :label => "position :"
= f.input :m_odr_product, :label => "m_odr_product :"
= f.input :sap, :label => "sap :"
%tr.m_odr_product_remise_form.field
%td{:style => "width:400px"}= form.input :name, :label => "Nom :"
%td= form.input :sap, :label => "SAP :"
%td=link_to_remove_fields ic(:"trash-o"), form
.actions=f.submit "sauvegarder", :class => "btn btn-primary"

View File

@ -13,6 +13,14 @@
%p= link_to_add_fields ic(:plus)+" Ajouter une remise", f, :m_odr_product_remises %p= link_to_add_fields ic(:plus)+" Ajouter une remise", f, :m_odr_product_remises
%table.m_odr_product_sizes_form
=f.semantic_fields_for :m_odr_product_sizes do |form|
=render :partial => "admin/m_odr_product_sizes/form", :locals => {:form => form}
%p= link_to_add_fields ic(:plus)+" Ajouter une taille", f, :m_odr_product_sizes
.actions=f.submit "sauvegarder", :class => "btn btn-primary" .actions=f.submit "sauvegarder", :class => "btn btn-primary"

View File

@ -18,6 +18,13 @@
=state_helper("Refusé") =state_helper("Refusé")
-if !m_odr_rep_rib.mail_sended
-slug = "erreur-coordonnees-bancaire"
=link_to ic(:envelope)+" #{slug}", send_mail_admin_m_odr_rep_rib_path(m_odr_rep_rib, :slug => slug), :remote => true, :class => "btn btn-primary"
-tr[:actions] = capture do -tr[:actions] = capture do
%td.actions %td.actions
= link_to i(:"trash-o"), [:admin, m_odr_rep_rib], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true = link_to i(:"trash-o"), [:admin, m_odr_rep_rib], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true

View File

@ -0,0 +1,2 @@
$('#m_odr_rep_rib_row_<%= @m_odr_rep_rib.id %>').replaceWith("<%= escape_javascript(render(@m_odr_rep_rib))%>");
close_pane_hover();

View File

@ -12,6 +12,9 @@
-params[:search] =params[:search] || {} -params[:search] =params[:search] || {}
%table %table
%tr %tr
%td=text_field_tag "search[name]", params[:search][:name],:class => "form-control", :placeholder => "Nom"
%td %td
Statut : Statut :
=select_tag "search[state]", options_for_select([["",""]]+MOdrRep.group(:state).order(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]) =select_tag "search[state]", options_for_select([["",""]]+MOdrRep.group(:state).order(:state).all.map{|a| [a.state, a.state]}, params[:search][:state])

View File

@ -18,6 +18,13 @@
= form.input :message = form.input :message
= form.hidden_field :lang_site_id = form.hidden_field :lang_site_id
-if current_admin.id == 1
= form.input :tags
-else
%p
-form.object.tags.split(",").each do |t|
="[#{t}]"
.actions=form.submit "sauvegarder", :class => "btn btn-primary" .actions=form.submit "sauvegarder", :class => "btn btn-primary"

View File

@ -3,6 +3,8 @@
.content .content
=f.inputs do =f.inputs do
= f.input :public, :label => "Organisateur référencé ?"
= f.input :logo_id, :label => "Logo :", :as => :qi_image_select = f.input :logo_id, :label => "Logo :", :as => :qi_image_select
= f.input :image_file_id, :label => "Image :" , :as => :qi_image_select = f.input :image_file_id, :label => "Image :" , :as => :qi_image_select

View File

@ -7,7 +7,7 @@
.qi_search_row .qi_search_row
=form_tag "", :method => "get", :onsubmit => "" do =form_tag "", :method => "get", :onsubmit => "" do
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @organisateurs} =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @organisateurs, :csv => true}
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @organisateurs} =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @organisateurs}

View File

@ -40,9 +40,20 @@
%br %br
= form.input :test_user, :label => "Client test ?", :as => :boolean = form.input :test_user, :label => "Client test ?", :as => :boolean
.row.qi_cancel_margins
.col-sm-4
%br
= form.input :unlimited, :label => "Nbr de primes déplafonné ?", :as => :boolean
.col-sm-4
= form.object.import_name
.col-sm-4
=l form.object.import_date if form.object.import_date
= form.input :tel, :label => "Tel :"
=# form.input :tel, :label => "Tel :"
= form.input :email, :label => "Email (login) :" = form.input :email, :label => "Email (login) :"
= form.input :generate_mdp, :label => "Forcer la génération d'un nouveau mot de passe ? (un mail sera envoyé au client)", :as => :boolean = form.input :generate_mdp, :label => "Forcer la génération d'un nouveau mot de passe ? (un mail sera envoyé au client)", :as => :boolean

View File

@ -6,6 +6,11 @@
-if p_customer.enabled -if p_customer.enabled
Oui Oui
-tr[:test_user] = capture do
%td
-if p_customer.test_user
Oui
-tr[:parent] = capture do -tr[:parent] = capture do
%td %td
-if p_customer.parent -if p_customer.parent
@ -19,6 +24,12 @@
=p_customer.mlm_token =p_customer.mlm_token
-tr[:particular_tel] = capture do
%td
-if p_customer.particular
=p_customer.particular.tel
-tr[:p_commercial] = capture do -tr[:p_commercial] = capture do
%td %td
@ -27,12 +38,65 @@
-tr[:p_customer_cat] = capture do -tr[:p_customer_cat] = capture do
%td= p_customer.p_customer_cat.name if p_customer.p_customer_cat %td= p_customer.p_customer_cat.name if p_customer.p_customer_cat
-tr[:particular] = capture do -tr[:particular_country] = capture do
%td
-if p_customer.particular
= p_customer.particular.country
-tr[:particular_address_2] = capture do
%td
-if p_customer.particular
= p_customer.particular.address_2
-tr[:particular_address_3] = capture do
%td
-if p_customer.particular
= p_customer.particular.address_3
-tr[:particular_cp] = capture do
%td %td
-if p_customer.particular -if p_customer.particular
= p_customer.particular.cp = p_customer.particular.cp
-tr[:particular_city] = capture do
%td
-if p_customer.particular
= p_customer.particular.city = p_customer.particular.city
= p_customer.particular.country
-tr[:name] = capture do
%td
-if p_customer.particular
= p_customer.particular.name
-tr[:firstname] = capture do
%td
-if p_customer.particular
= p_customer.particular.firstname
-tr[:particular_fill] = capture do
%td
-if p_customer.particular_fill?
Oui
-elsif p_customer.particular_mail_sended == false
-slug = "stickers-manque-adresse"
=link_to ic(:envelope)+" #{slug}", send_mail_admin_p_customer_path(p_customer, :slug => slug), :remote => true, :class => "btn btn-primary"
-else
Non (mail déjà envoyé)
-tr[:actions] = capture do -tr[:actions] = capture do
%td.actions %td.actions
@ -47,8 +111,10 @@
-else -else
-if current_admin.has_permission?("customers-d") -if current_admin.has_permission?("customers-d")
= link_to i(:"trash-o"), [:admin, p_customer], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer ce client ? ' } , :remote => true if p_customer.can_destroy? = link_to i(:"trash-o"), [:admin, p_customer], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer ce client ? ' } , :remote => true if p_customer.can_destroy?
-if current_admin.has_permission?("customers-d") -if current_admin.has_permission?("customers-u")
= 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
-if current_admin.has_permission?("customers-npai")
= link_to "NPAI", npai_admin_p_customer_path(p_customer), :remote => false
-if current_admin.has_permission?("customers-s") -if current_admin.has_permission?("customers-s")
= link_to i(:eye), admin_p_customer_path(p_customer) = link_to i(:eye), admin_p_customer_path(p_customer)

View File

@ -23,8 +23,13 @@
%td=text_field_tag :code, params[:code],:class => "form-control", :placeholder => "Code client" %td=text_field_tag :code, params[:code],:class => "form-control", :placeholder => "Code client"
%td=text_field_tag :name, params[:name],:class => "form-control", :placeholder => "Nom" %td=text_field_tag :name, params[:name],:class => "form-control", :placeholder => "Nom"
%td=text_field_tag :email, params[:email],:class => "form-control", :placeholder => "Email"
%td=text_field_tag :city, params[:city],:class => "form-control", :placeholder => "Ville" %td=text_field_tag :city, params[:city],:class => "form-control", :placeholder => "Ville"
%td=text_field_tag :tel, params[:tel],:class => "form-control", :placeholder => "Tel" %td=text_field_tag :tel, params[:tel],:class => "form-control", :placeholder => "Tel"
@ -50,15 +55,22 @@
%table %table
%tr %tr
%td
Actif :
=select_tag "search[enabled]", options_for_select([[""], "Oui", "Non"], params[:search][:enabled])
%td %td
Catégorie : Utilisateur test ?
=select_tag "search[p_customer_cat_id]", options_for_select([["",""],["Aucune","null"]]+PCustomerCat.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:p_customer_cat_id]) =select_tag "search[test_user]", options_for_select([[""], "Oui", "Non"], params[:search][:test_user])
%td
NPAI ?
=select_tag "search[npai]", options_for_select([[""], "Oui", "Non"], params[:search][:npai])
%td
Stickers envoyés ?
=select_tag "search[sticker]", options_for_select([[""], "Oui", "Non"], params[:search][:sticker])
-if !current_admin.p_commercial
%td
Commercial :
=select_tag "search[p_commercial_id]", options_for_select([["",""],["Aucun","null"]]+PCommercial.order(:name).all.map{|a| [a.member_label, a.id]}, params[:search][:p_commercial_id])
@ -113,16 +125,8 @@
=link_to ic(:search)+" Rechercher", "#", :class => "btn btn-default btn-qi-search", :onclick => "$(this).closest('form').submit();$(this).html('...');return false;"
=render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_customers, :csv => true}
.results_count
="(#{@p_customers.total_count}) résultat(s)"
="-"
=select_tag "search[per_page]", options_for_select([50,100,200,500], params[:search][:per_page])
résultats par page

View File

@ -0,0 +1,48 @@
.qi_header
.right{:style => "text-align:right;"}
= link_to i(:pencil), edit_admin_p_customer_path(@p_customer), :remote => false
%h1
Utilisateurs
%span
Historique des changements de coordonnées
%span
=@p_customer.code
=@p_customer.show_name
%br
.qi_tab_header.qi_padding
.right{:style => "text-align:right;"}
-if @p_customer.npai
= link_to "Lever le NPAI", toggle_npai_admin_p_customer_path(@p_customer), :remote => false, :class => "btn btn-success"
-else
= link_to "Signaler le NPAI", toggle_npai_admin_p_customer_path(@p_customer), :remote => false, :class => "btn btn-danger"
.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
-@particular_hists =@p_customer.particular_hists
-@particular_hists = sort_by_sorting(@particular_hists, "created_at DESC")
-@particular_hists = @particular_hists.page(page).per(per_page)
=#debug MailHist.qi_ordered_table_name
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @particular_hists}

View File

@ -0,0 +1,2 @@
$('#p_customer_<%= @p_customer.id %>').replaceWith("<%= escape_javascript(render(@p_customer))%>");
close_pane_hover();

View File

@ -23,6 +23,10 @@
Code ambassadeur : Code ambassadeur :
=@p_customer.mlm_token =@p_customer.mlm_token
%p
Lien ambassadeur :
=link_to new_public_p_customer_url(:a => @p_customer.mlm_token, :lang => "fr"), new_public_p_customer_url(:a => @p_customer.mlm_token, :lang => "fr"), :target => "_blank"
%p %p
Email : Email :
=@p_customer.email =@p_customer.email

View File

@ -0,0 +1,34 @@
.qi_row
.qi_pannel.qi_plain.padding
=form_tag "", multipart: true do
=file_field_tag :file
%br
=submit_tag "Mettre à jour les stickers", :class => "btn btn-primary"
-if @data
%table.table
-@data.each do |d|
%tr
%td
=d["Nom"]
%td
=d["Prénom"]
-if p_customers = PCustomer.where("cc_particular_name = ? and cc_particular_firstname = ?", d["Nom"],d["Prénom"]) and p_customers.count == 1 and p_customer = p_customers.first
%td
=p_customer.cc_particular_name
%td
=p_customer.cc_particular_firstname
-p_customer.sticker = true
-p_customer.save
-else
%td{:style => "color:red;font-weight:bold;"}
=ic(:warning)
Utilisateur introuvable
%td

View File

@ -46,183 +46,70 @@
=link_to "Mois suivant >","?start=#{CGI.escape((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y'))}&stop=#{CGI.escape((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}", :class => "btn btn-default" =link_to "Mois suivant >","?start=#{CGI.escape((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y'))}&stop=#{CGI.escape((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}", :class => "btn btn-default"
%p
-if @start and @stop
=link_to "< Année précédente","?start=#{CGI.escape((@start - 1.year).beginning_of_month.strftime('%d/%m/%Y'))}&stop=#{CGI.escape((@stop - 1.year).end_of_month.strftime('%d/%m/%Y'))}", :class => "btn btn-default"
-if @start and @stop
=link_to "Année suivante >","?start=#{CGI.escape((@start + 1.year).beginning_of_month.strftime('%d/%m/%Y'))}&stop=#{CGI.escape((@stop + 1.year).end_of_month.strftime('%d/%m/%Y'))}", :class => "btn btn-default"
%hr %hr
%table.table.table-stripped
%h2
=#raw("#{l(@start_at, :format => '%B %Y')}")
%table.table
%tr %tr
%td{:style => "width:50%;"} %th
=l @start %th Nombre
%td{:style => "width:50%;"} %th Montant
=l @stop %th Nbr pneus
%tr
%th Motards
%td
=PCustomer.where(:test_user => false, :enabled => true).where("created_at < ?", @stop).count
%td
%td
%tr
%th Organisateurs
%td
=Organisateur.where("created_at < ?", @stop).count
%td
%td
%tr
%th Circuits
%td
=Circuit.where("created_at < ?", @stop).count
%td
%td
%p %tr
Nombre de commandes finalisées : %th Dates
%td
-r = 0
-MEvent.where("start_at >= ? and start_at < ? and created_at >= ? and created_at < ?",@start.beginning_of_year, @stop.end_of_year, @start.beginning_of_year, @stop).all.each do |m_event|
-r+=(m_event.end_at - m_event.start_at ).to_i / (24 * 60 * 60) +1
=r
%td
%td
=orders_ok = @finished.count %tr
-if false %th
%table Primes
%td
=@all_m_odr_primes.count
%td
=number_to_currency @all_m_odr_primes.sum(:amount)
-@finished.each do |ps| %td
%tr = @all_m_odr_primes.sum(:nbr_pneus)
%td
=ps.a_ok_total
%td
=ps.a_total_cost_ok
%br
%br %br
%strong=number_to_percentage ((@finished.count*100)/@p_customer_sheets.count), :precision => 2 if @p_customer_sheets.count > 0
%p
Nombre de commandes non finalisées :
=orders_not_ok = (@p_customer_sheets.count - @finished.count)
%p
CA HT :
%strong=number_to_currency @finished.sum(:a_ok_total)
-if @sans_marges.count > 0
%p{:style => "color:red;"}
Attention : le calcul des marges est faussé car certaines factures fournisseurs semblent ne pas être saisies, et donc certaines commandes n'ont pas pu être attribuées.
%p
Coût estimé HT :
-cout = @finished.sum(:a_total_cost_ok)
%strong=number_to_currency cout
%p
Marge estimée HT :
-marge = @finished.sum(:a_ok_total) - @finished.sum(:a_total_cost_ok)
%strong=number_to_currency(marge)
%br
%strong=number_to_percentage ((@finished.sum(:a_ok_total) - @finished.sum(:a_total_cost_ok))/@finished.sum(:a_ok_total)*100), :precision => 2 if @finished.sum(:a_ok_total) > 0.0
%div{:style => "width:350px;display:inline-block;"}
<canvas id="ordersChart" width="400" height="400"></canvas>
:javascript =link_to "Export Excel", params.permit!.merge({:format => :csv})
var myPieChart = new Chart("ordersChart",{
type: 'pie',
data: {
labels: ["Finalisées", "Non finalisées"],
datasets: [{
label: '# of Votes',
data: [#{orders_ok},#{orders_not_ok}],
backgroundColor: [
'#4BC0C0',
'#FF6384',
], =#debug MailHist.qi_ordered_table_name
borderColor: [ =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_primes}
'white',
'white',
],
borderWidth: 2
}]
},
options: {
title: {
display: true,
text: 'Finalisation des commandes'
}
}
// options: options
});
%div{:style => "width:350px;display:inline-block;"}
<canvas id="margeChart" width="400" height="400"></canvas>
:javascript
var myPieChart = new Chart("margeChart",{
type: 'pie',
data: {
labels: ["Marge", "Cout"],
datasets: [{
label: '# of Votes',
data: [#{marge},#{cout}],
backgroundColor: [
'#4BC0C0',
'#FF6384',
],
borderColor: [
'white',
'white',
],
borderWidth: 2
}]
},
options: {
title: {
display: true,
text: 'Marges'
}
}
// options: options
});
-if false
<canvas id="myChart" width="400" height="200"></canvas>
:javascript
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 0
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});

View File

@ -0,0 +1,28 @@
=semantic_form_for [:admin, @particular_hist], :remote => true do |f|
.content
=f.inputs do
= f.input :particular, :label => "particular :"
= f.input :p_customer, :label => "p_customer :"
= f.input :description, :label => "description :"
= f.input :name, :label => "name :"
= f.input :firstname, :label => "firstname :"
= f.input :address_1, :label => "address_1 :"
= f.input :address_2, :label => "address_2 :"
= f.input :address_3, :label => "address_3 :"
= f.input :address_4, :label => "address_4 :"
= f.input :address_5, :label => "address_5 :"
= f.input :cp, :label => "cp :"
= f.input :city, :label => "city :"
= f.input :country, :label => "country :"
= f.input :tel, :label => "tel :"
= f.input :email, :label => "email :"
= f.input :civilite, :label => "civilite :"
= f.input :npai, :label => "npai :"
.actions=f.submit "sauvegarder", :class => "btn btn-primary"

View File

@ -0,0 +1,16 @@
%tr#particular_hist_row{:id => particular_hist.id}
-tr = {}
-tr[:actions] = capture do
%td.actions
= link_to i(:"trash-o"), [:admin, particular_hist], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
= link_to i(:pencil), edit_admin_particular_hist_path(particular_hist), :remote => true
= link_to i(:eye), admin_particular_hist_path(particular_hist), :remote => true
=render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => particular_hist}

View File

@ -0,0 +1,2 @@
$('#particular_hists_rows').prepend("<%= escape_javascript(render(@particular_hist))%>");
close_pane_hover();

View File

@ -0,0 +1 @@
$('#particular_hist_row_<%= @particular_hist.id %>').remove();

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -0,0 +1,15 @@
.qi_header
.right= link_to ic(:plus)+' Ajouter', new_admin_particular_hist_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 => @particular_hists}
=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @particular_hists}

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -0,0 +1,10 @@
.qi_header
%h1
%span
.qi_row
.qi_pannel.qi_plain.padding
=debug @particular_hist

View File

@ -0,0 +1,2 @@
$('#particular_hist_row_<%= @particular_hist.id %>').replaceWith("<%= escape_javascript(render(@particular_hist))%>");
close_pane_hover();

View File

@ -26,5 +26,5 @@
=form.input :country, :label => false, :placeholder => "Pays", :priority_countries => ["FR", "CH", "BE"], :include_blank => false, :locale => @lang.slug =form.input :country, :label => false, :placeholder => "Pays", :priority_countries => ["FR", "CH", "BE"], :include_blank => false, :locale => @lang.slug
=#form.input :email, :label => false, :placeholder => qit("don-particular-email","Email") =#form.input :email, :label => false, :placeholder => qit("don-particular-email","Email")
=#form.input :tel, :label => false, :placeholder => qit("don-particular-phone","Téléphone") =form.input :tel, :label => false, :placeholder => qit("don-particular-phone","Téléphone")

View File

@ -31,10 +31,11 @@
.element .element
=link_to admin_menu_items_path(:menu_id => 1) do -if current_admin.has_permission?("CMS")
.cat#big_cat_ventes =link_to admin_menu_items_path(:menu_id => 1) do
=ic :"globe" .cat#big_cat_ventes
CMS =ic :"globe"
CMS
@ -68,7 +69,14 @@
=ic :"file-text-o" =ic :"file-text-o"
Documents Documents
-if current_admin.has_permission?("virements.view")
-if current_admin.has_permission?("primes")
.element
=link_to admin_m_odr_files_path do
.cat#big_cat_payments
=ic :"eur"
Primes
-elsif current_admin.has_permission?("virements.view")
.element .element
=link_to admin_m_odr_virements_path do =link_to admin_m_odr_virements_path do
.cat#big_cat_payments .cat#big_cat_payments
@ -85,7 +93,7 @@
Tunnels fichier sécurisés Tunnels fichier sécurisés
-if false -if current_admin.has_permission?("statistiques")
.element .element
=link_to admin_p_stats_path do =link_to admin_p_stats_path do
.cat#big_cat_statistiques .cat#big_cat_statistiques

Some files were not shown because too many files have changed in this diff Show More