This commit is contained in:
Nicolas Bally 2020-07-23 11:17:11 +02:00
parent e6260010a4
commit f4ccdc82dc
15 changed files with 1354 additions and 9 deletions

View File

@ -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

@ -7,11 +7,32 @@ class Admin::PCustomersController < ApplicationController
before_action :admin_space before_action :admin_space
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"
@ -449,10 +470,17 @@ class Admin::PCustomersController < ApplicationController
if @p_customer.npai if @p_customer.npai
@p_customer.npai = false @p_customer.npai = false
message = "NPAI levé" 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 else
@p_customer.npai = true @p_customer.npai = true
message = "NPAI signalé" message = "NPAI signalé"
mail_hist = MailHist.auto_generate_mail(:fr, "stickers-npai", @p_customer.email, {:arguments => {}, :p_customer => @p_customer, :element => @p_customer})
end end
@p_customer.save @p_customer.save

View File

@ -56,7 +56,7 @@ class Public::MOdrRepRibsController < ApplicationController
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.admin_ok = nil
@m_odr_rep_rib.mail_sended = false
@m_odr_rep_rib.save @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

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

@ -261,6 +261,7 @@ class PCustomer < ApplicationRecord
:test_user => "Utilisateur test ?", :test_user => "Utilisateur test ?",
:npai => "NPAI ?", :npai => "NPAI ?",
:sticker => "Stickers envoyés ?", :sticker => "Stickers envoyés ?",
:particular_fill => "Adresse remplie ?",
:parent => "Ambassadeur", :parent => "Ambassadeur",
@ -269,6 +270,8 @@ class PCustomer < ApplicationRecord
:particular_city => "Ville", :particular_city => "Ville",
:particular_country => "Pays", :particular_country => "Pays",
:email => "Email", :email => "Email",
:tel => "Téléphone", :tel => "Téléphone",
:actions => "Actions" :actions => "Actions"
@ -285,7 +288,7 @@ class PCustomer < ApplicationRecord
def particular_fill? def particular_fill?
true if self.particular.firstname? and self.particular.name? and self.particular.address2? and self.particular.cp? and self.particular.city? true if self.particular.firstname? and self.particular.name? and self.particular.address_2? and self.particular.cp? and self.particular.city?
end end
before_destroy do before_destroy do

View File

@ -65,10 +65,18 @@
%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
.red Facture refusée .red Facture refusée
Envoyer un mail de notification : Envoyer un mail de notification :
@ -82,6 +90,7 @@
%br %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;" =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;"

View File

@ -16,6 +16,13 @@
=state_helper("Validé") =state_helper("Validé")
-elsif m_odr_rep_rib.admin_ok == false -elsif m_odr_rep_rib.admin_ok == false
=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

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

@ -67,6 +67,17 @@
-if p_customer.particular -if p_customer.particular
= p_customer.particular.firstname = 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é)

View File

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

View File

@ -863,6 +863,7 @@ Rails.application.routes.draw do
get :npai get :npai
get :toggle_npai get :toggle_npai
get :ask_particular get :ask_particular
get :send_mail
end end
collection do collection do

View File

@ -0,0 +1,5 @@
class AddErrorMailSendedToMOdrRepRibs < ActiveRecord::Migration[6.0]
def change
add_column :m_odr_rep_ribs, :mail_sended, :boolean, :default => false
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_07_22_123358) do ActiveRecord::Schema.define(version: 2020_07_23_090815) do
create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "name" t.string "name"
@ -919,6 +919,7 @@ ActiveRecord::Schema.define(version: 2020_07_22_123358) do
t.string "reject_reason" t.string "reject_reason"
t.text "reject_reason_description" t.text "reject_reason_description"
t.integer "p_customer_id" t.integer "p_customer_id"
t.boolean "mail_sended", default: false
t.index ["admin_id"], name: "index_m_odr_rep_ribs_on_admin_id" t.index ["admin_id"], name: "index_m_odr_rep_ribs_on_admin_id"
end end

1224
import_csv/stickers.csv Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,33 @@
namespace :qi do namespace :qi do
desc "TODO" desc "TODO"
task import_stickers: :environment do
@file = "#{Rails.root}/import_csv/stickers.csv"
require 'csv'
csv_text = File.read(@file, :encoding => 'UTF-8')
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
@csv.each do |csv|
if p_customer = PCustomer.joins(:particular).where("particulars.name = ? and particulars.firstname = ?", csv[0], csv["prenom"]).first
p_customer.sticker = true
p_customer.save
else
puts csv[0].to_s+ " "+csv["prenom"]
end
end
puts "Fin de l'import"
end
task migrate_all: :environment do task migrate_all: :environment do