diff --git a/app/controllers/admin/circuits_controller.rb b/app/controllers/admin/circuits_controller.rb index 857d318..9e7d09e 100644 --- a/app/controllers/admin/circuits_controller.rb +++ b/app/controllers/admin/circuits_controller.rb @@ -12,7 +12,7 @@ class Admin::CircuitsController < ApplicationController def index @circuits = Circuit.all - @circuits = sort_by_sorting(@circuits, "name DESC") + @circuits = sort_by_sorting(@circuits, "name ASC") respond_to do |format| format.html{ diff --git a/app/controllers/admin/m_odr_files_controller.rb b/app/controllers/admin/m_odr_files_controller.rb index a22aeb4..19d93f6 100644 --- a/app/controllers/admin/m_odr_files_controller.rb +++ b/app/controllers/admin/m_odr_files_controller.rb @@ -43,13 +43,17 @@ class Admin::MOdrFilesController < ApplicationController 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 + @m_odr_file.m_odr_file_products.build(:admin_form => true) + end end def edit @m_odr_file = MOdrFile.find(params[:id]) + @m_odr_file.m_odr_file_products.each do |mofp| + mofp.admin_form = true + end end diff --git a/app/controllers/admin/m_odr_places_controller.rb b/app/controllers/admin/m_odr_places_controller.rb index bc63140..7cb6b76 100644 --- a/app/controllers/admin/m_odr_places_controller.rb +++ b/app/controllers/admin/m_odr_places_controller.rb @@ -74,4 +74,20 @@ class Admin::MOdrPlacesController < ApplicationController @m_odr_place.destroy 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 diff --git a/app/controllers/admin/m_odr_primes_controller.rb b/app/controllers/admin/m_odr_primes_controller.rb index 07607a1..b86e3da 100644 --- a/app/controllers/admin/m_odr_primes_controller.rb +++ b/app/controllers/admin/m_odr_primes_controller.rb @@ -33,6 +33,71 @@ class Admin::MOdrPrimesController < ApplicationController @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 diff --git a/app/controllers/admin/m_odr_rep_ribs_controller.rb b/app/controllers/admin/m_odr_rep_ribs_controller.rb index ea8ce99..352549f 100644 --- a/app/controllers/admin/m_odr_rep_ribs_controller.rb +++ b/app/controllers/admin/m_odr_rep_ribs_controller.rb @@ -13,7 +13,7 @@ class Admin::MOdrRepRibsController < ApplicationController def index @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| format.html{ diff --git a/app/controllers/admin/m_odr_virements_controller.rb b/app/controllers/admin/m_odr_virements_controller.rb index 66985c0..48ac086 100644 --- a/app/controllers/admin/m_odr_virements_controller.rb +++ b/app/controllers/admin/m_odr_virements_controller.rb @@ -17,6 +17,11 @@ class Admin::MOdrVirementsController < ApplicationController if params[:search][:m_odr_id].to_s != "" @m_odr_virements = @m_odr_virements.where(:m_odr_id => params[:search][:m_odr_id]) 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") diff --git a/app/controllers/admin/organisateurs_controller.rb b/app/controllers/admin/organisateurs_controller.rb index edf3ef9..56fd247 100644 --- a/app/controllers/admin/organisateurs_controller.rb +++ b/app/controllers/admin/organisateurs_controller.rb @@ -13,7 +13,7 @@ class Admin::OrganisateursController < ApplicationController def index @organisateurs = Organisateur.all - @organisateurs = sort_by_sorting(@organisateurs, "name DESC") + @organisateurs = sort_by_sorting(@organisateurs, "name ASC") respond_to do |format| format.html{ diff --git a/app/controllers/admin/p_stats_controller.rb b/app/controllers/admin/p_stats_controller.rb index 6ff69c0..83d1edd 100644 --- a/app/controllers/admin/p_stats_controller.rb +++ b/app/controllers/admin/p_stats_controller.rb @@ -47,6 +47,99 @@ class Admin::PStatsController < ApplicationController @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.created_at DESC") + @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 diff --git a/app/controllers/public/m_events_controller.rb b/app/controllers/public/m_events_controller.rb index 6373af8..31069f4 100644 --- a/app/controllers/public/m_events_controller.rb +++ b/app/controllers/public/m_events_controller.rb @@ -6,6 +6,8 @@ class Public::MEventsController < ApplicationController def index @m_events = MEvent.all + @m_events = @m_events.joins(:organisateur).where(:organisateurs => {:public => true}) + params[:search] = params[:search] || [] @m_events = @m_events.where("start_at >= ? or end_at >= ?", Date.today.beginning_of_day, Date.today.beginning_of_day) diff --git a/app/controllers/public/organisateurs_controller.rb b/app/controllers/public/organisateurs_controller.rb index 108c7cc..d183515 100644 --- a/app/controllers/public/organisateurs_controller.rb +++ b/app/controllers/public/organisateurs_controller.rb @@ -4,7 +4,7 @@ class Public::OrganisateursController < ApplicationController def index - @organisateurs = Organisateur.order(:name).all + @organisateurs = Organisateur.order(:name).where(:public => true).all @organisateurs_active = true diff --git a/app/helpers/document_line_helper.rb b/app/helpers/document_line_helper.rb index 4089c27..42385df 100644 --- a/app/helpers/document_line_helper.rb +++ b/app/helpers/document_line_helper.rb @@ -7,7 +7,10 @@ module DocumentLineHelper end 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 diff --git a/app/models/m_odr_file.rb b/app/models/m_odr_file.rb index efe5334..039a88a 100644 --- a/app/models/m_odr_file.rb +++ b/app/models/m_odr_file.rb @@ -21,6 +21,7 @@ class MOdrFile < ApplicationRecord validates :file, :presence => true + before_create { generate_token() } validates :buy_at, :presence => true, :if => :buy_at_needed? @@ -64,13 +65,24 @@ class MOdrFile < ApplicationRecord self.nbr_primes_not_useds = self.nbr_primes - nbr_primes_useds elsif self.m_odr_file_type_id == 2 - nbr_pneus = 0 + self.nbr_pneus = 0 self.m_odr_file_products.each do |mofp| - nbr_pneus += mofp.qte.to_i + self.nbr_pneus += mofp.qte.to_i end - - self.nbr_pneus = nbr_pneus + if self.nbr_pneus > 2 + self.nbr_pneus = 2 + + + end + + + + + + self.nbr_pneus_not_useds = self.nbr_pneus - self.nbr_pneus_useds.to_i + + end end diff --git a/app/models/m_odr_file_product.rb b/app/models/m_odr_file_product.rb index 208054e..4cc8d74 100644 --- a/app/models/m_odr_file_product.rb +++ b/app/models/m_odr_file_product.rb @@ -5,6 +5,26 @@ class MOdrFileProduct < ApplicationRecord #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_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 if self.m_odr_product_size diff --git a/app/models/m_odr_prime.rb b/app/models/m_odr_prime.rb index b347a17..5a191fb 100644 --- a/app/models/m_odr_prime.rb +++ b/app/models/m_odr_prime.rb @@ -34,8 +34,8 @@ class MOdrPrime < ApplicationRecord :p_customer_created_at => {:name => "Inscription", :reorder => true, :sort_name => "p_customers.created_at"}, - :particular_name => {:name => "Nom", :reorder => true, :sort_name => "particulars.name"}, - :particular_firstname => {:name => "Prénom", :reorder => true, :sort_name => "particulars.firstname"}, + :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"}, @@ -45,9 +45,9 @@ class MOdrPrime < ApplicationRecord #:pneu_tailles => {:name => "Tailles"}, - :m_odr_place_name => {:name => "Nom"}, - :m_odr_place_cp=> {:name => "CP"}, - :m_odr_place_city => {:name => "Nom"}, + :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"}, @@ -136,5 +136,70 @@ class MOdrPrime < ApplicationRecord mail_hist = MailHist.auto_generate_mail(:fr, slug, self.p_customer.email, {:arguments => {:remise => number_to_currency(self.amount.to_f), :nbr => self.nbr_pneus }, :m_odr_prime => self, :p_customer => self.p_customer, :element => self}) 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 diff --git a/app/models/m_odr_rep_rib.rb b/app/models/m_odr_rep_rib.rb index fee35cb..3fbc7af 100644 --- a/app/models/m_odr_rep_rib.rb +++ b/app/models/m_odr_rep_rib.rb @@ -24,6 +24,8 @@ class MOdrRepRib < ApplicationRecord :admin_ok => {:name => "Décision", :reorder => true}, :reject_reason => {:name => "Raison du rejet", :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}, } diff --git a/app/models/m_odr_virement.rb b/app/models/m_odr_virement.rb index 3b0a345..f9cfac7 100644 --- a/app/models/m_odr_virement.rb +++ b/app/models/m_odr_virement.rb @@ -5,6 +5,7 @@ class MOdrVirement < ApplicationRecord belongs_to :m_odr_prime belongs_to :m_odr_remise + has_one :p_customer, :through => :m_odr_prime diff --git a/app/models/p_customer.rb b/app/models/p_customer.rb index eb5e15a..2eb5d21 100644 --- a/app/models/p_customer.rb +++ b/app/models/p_customer.rb @@ -75,7 +75,7 @@ class PCustomer < ApplicationRecord validates :past_id, :uniqueness => true, :if => :imported - acts_as_caching :fields => [:show_name] + acts_as_caching :fields => [:show_name, :particular_name, :particular_firstname] attr_accessor :refresh_import @@ -274,7 +274,7 @@ class PCustomer < ApplicationRecord :email => "Email", - :tel => "Téléphone", + :particular_tel => "Téléphone", :actions => "Actions" } @@ -505,6 +505,20 @@ class PCustomer < ApplicationRecord 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 if self.particular @@ -618,6 +632,10 @@ class PCustomer < ApplicationRecord end + def csv_particular_tel + self.particular.tel if self.particular + end + end diff --git a/app/views/admin/m_odr_file_products/_form.html.haml b/app/views/admin/m_odr_file_products/_form.html.haml index 73b5390..086b171 100644 --- a/app/views/admin/m_odr_file_products/_form.html.haml +++ b/app/views/admin/m_odr_file_products/_form.html.haml @@ -1,6 +1,9 @@ %tr.m_odr_file_product_form.field %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" diff --git a/app/views/admin/m_odr_file_roulages/_form.html.haml b/app/views/admin/m_odr_file_roulages/_form.html.haml index c251c39..aac1822 100644 --- a/app/views/admin/m_odr_file_roulages/_form.html.haml +++ b/app/views/admin/m_odr_file_roulages/_form.html.haml @@ -1,11 +1,11 @@ %tr.m_odr_file_roulage_form.field - %td= form.input :date, :label => "date :" , :as => :date, :input_html => {:id => "roulage_date_input"} + %td.td_roulage_date_input= form.input :date, :label => "date :" , :as => :date, :input_html => {:class => "roulage_date_input"} -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, :input_html => {:id => "select_date_input"} + %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 - %td= form.input :m_event_id, :label => "Journée de roulage :", :as => :date, :collection => [], :member_label => :member_label, :as => :select, :input_html => {:id => "select_date_input"} + %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 @@ -14,9 +14,10 @@ :coffeescript - $('#roulage_date_input').change -> + + $("body").on "change", ".td_roulage_date_input input", -> + obj = $(this) $.getJSON "/admin/m_events/autocomplete.json?date="+$(this).val(), (data) -> - - $("#select_date_input").html('') + obj.closest(".field").find(".select_date_input").html("") $.each data, -> - $("#select_date_input").append '' + obj.closest(".field").find(".select_date_input").append '' diff --git a/app/views/admin/m_odr_files/_form.html.haml b/app/views/admin/m_odr_files/_form.html.haml index 0940e32..d4c3a39 100644 --- a/app/views/admin/m_odr_files/_form.html.haml +++ b/app/views/admin/m_odr_files/_form.html.haml @@ -4,7 +4,7 @@ .qi_row .qi_pannel.qi_plain.padding =f.inputs do - + =render :partial => "qi/autocomplete", :locals => {:form => f, :field => :p_customer, :label => "Utilisateur :"} = f.input :file, :label => "Fichier :" @@ -20,11 +20,13 @@ -if f.object.m_odr_file_type_id == 2 %table.m_odr_file_products_form.form-table = 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| =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 diff --git a/app/views/admin/m_odr_files/show.html.haml b/app/views/admin/m_odr_files/show.html.haml index ec2a8c5..5b5d1ac 100644 --- a/app/views/admin/m_odr_files/show.html.haml +++ b/app/views/admin/m_odr_files/show.html.haml @@ -11,8 +11,20 @@ +=debug @m_odr_file.nbr_pneus +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 = 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%;"} .qi_row @@ -124,15 +136,4 @@ Historique des mails envoyés =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @mail_hists} -.clear -%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 = 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 \ No newline at end of file diff --git a/app/views/admin/m_odr_primes/index.html.haml b/app/views/admin/m_odr_primes/index.html.haml index 6456748..9c4f069 100644 --- a/app/views/admin/m_odr_primes/index.html.haml +++ b/app/views/admin/m_odr_primes/index.html.haml @@ -9,7 +9,7 @@ .qi_search_row =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 diff --git a/app/views/admin/m_odr_virements/index.html.haml b/app/views/admin/m_odr_virements/index.html.haml index cd0e02f..497e09b 100644 --- a/app/views/admin/m_odr_virements/index.html.haml +++ b/app/views/admin/m_odr_virements/index.html.haml @@ -12,6 +12,9 @@ -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([["",""]]+MOdrRep.group(:state).order(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]) diff --git a/app/views/admin/mail_types/_form.html.haml b/app/views/admin/mail_types/_form.html.haml index 33511e4..4f1418e 100644 --- a/app/views/admin/mail_types/_form.html.haml +++ b/app/views/admin/mail_types/_form.html.haml @@ -17,6 +17,13 @@ = form.input :subject = form.input :message = 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" diff --git a/app/views/admin/organisateurs/_form.html.haml b/app/views/admin/organisateurs/_form.html.haml index 57a7fa5..0077576 100644 --- a/app/views/admin/organisateurs/_form.html.haml +++ b/app/views/admin/organisateurs/_form.html.haml @@ -3,6 +3,8 @@ .content =f.inputs do + = f.input :public, :label => "Organisateur référencé ?" + = f.input :logo_id, :label => "Logo :", :as => :qi_image_select = f.input :image_file_id, :label => "Image :" , :as => :qi_image_select diff --git a/app/views/admin/p_customers/_form.html.haml b/app/views/admin/p_customers/_form.html.haml index 7ef4002..458046c 100755 --- a/app/views/admin/p_customers/_form.html.haml +++ b/app/views/admin/p_customers/_form.html.haml @@ -42,7 +42,7 @@ - = form.input :tel, :label => "Tel :" + =# form.input :tel, :label => "Tel :" = 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 diff --git a/app/views/admin/p_customers/_p_customer.html.haml b/app/views/admin/p_customers/_p_customer.html.haml index a51784a..8d6b516 100644 --- a/app/views/admin/p_customers/_p_customer.html.haml +++ b/app/views/admin/p_customers/_p_customer.html.haml @@ -24,7 +24,7 @@ =p_customer.mlm_token - -tr[:tel] = capture do + -tr[:particular_tel] = capture do %td -if p_customer.particular =p_customer.particular.tel diff --git a/app/views/admin/p_stats/index.html.haml b/app/views/admin/p_stats/index.html.haml index 6e6f03f..ccaa82b 100644 --- a/app/views/admin/p_stats/index.html.haml +++ b/app/views/admin/p_stats/index.html.haml @@ -49,7 +49,7 @@ %hr - -@m_odr_primes = MOdrPrime.where("created_at >= ? and created_at < ?",@start.beginning_of_year, @stop).where(:state => ["Virement envoyé"]) + %table.table.table-stripped %tr @@ -103,13 +103,9 @@ %br %br - -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 = @m_odr_primes.where("created_at >= ?", @start) - -@m_odr_primes = sort_by_sorting(@m_odr_primes, "created_at DESC") - -@m_odr_primes = @m_odr_primes.page(page).per(per_page) + =link_to "Export CSV", params.permit!.merge({:format => :csv}) =#debug MailHist.qi_ordered_table_name =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_primes} diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 40c8374..7560de4 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -72,7 +72,7 @@ -if current_admin.has_permission?("primes") .element - =link_to admin_m_odr_primes_path do + =link_to admin_m_odr_files_path do .cat#big_cat_payments =ic :"eur" Primes diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index dc979b8..73794df 100644 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -70,6 +70,22 @@ = stylesheet_link_tag 'public', :media => :all + + + + %body diff --git a/app/views/public/m_events/_m_event.html.haml b/app/views/public/m_events/_m_event.html.haml index b42fcad..8148ef0 100644 --- a/app/views/public/m_events/_m_event.html.haml +++ b/app/views/public/m_events/_m_event.html.haml @@ -27,7 +27,7 @@ .organisateur_name Organisé par - %strong=link_to m_event.organisateur.name, public_organisateur_path(m_event.organisateur), :target => "_blank" if m_event.organisateur + %strong=link_to m_event.organisateur.name, public_organisateur_path(:id => m_event.organisateur.slug), :target => "_blank" if m_event.organisateur -if m_event.description? %br diff --git a/app/views/public/m_events/_search.html.haml b/app/views/public/m_events/_search.html.haml index 7c1f29a..f86f367 100644 --- a/app/views/public/m_events/_search.html.haml +++ b/app/views/public/m_events/_search.html.haml @@ -13,7 +13,7 @@ .select.inline_large_input=select_tag "search[circuit_id]", options_for_select([["Circuit",""]]+Circuit.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:circuit_id]), :place_holder => "" - .select.inline_large_input=select_tag "search[organisateur_id]", options_for_select([["Organisateur",""]]+Organisateur.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:organisateur_id]), :place_holder => "" + .select.inline_large_input=select_tag "search[organisateur_id]", options_for_select([["Organisateur",""]]+Organisateur.where(:public => true).order(:name).all.map{|a| [a.name, a.id]}, params[:search][:organisateur_id]), :place_holder => "" .no-mobile.right{:style => "position:relative;top:10px;"} diff --git a/app/views/public/menu_items/index.html.haml b/app/views/public/menu_items/index.html.haml index fcfa6bf..70d5bc3 100644 --- a/app/views/public/menu_items/index.html.haml +++ b/app/views/public/menu_items/index.html.haml @@ -51,7 +51,7 @@ %span.label-chiffre Circuits .col-xs-12.col-md-6.col-lg-3 %span.chiffre - =Organisateur.count + =Organisateur.where(:public => true).count %span.label-chiffre Organisateurs .avantage diff --git a/config/routes.rb b/config/routes.rb index cbca708..325e49b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -349,7 +349,7 @@ Rails.application.routes.draw do end collection do - + get :autocomplete end end diff --git a/db/migrate/20210209140453_add_public_to_organisateurs.rb b/db/migrate/20210209140453_add_public_to_organisateurs.rb new file mode 100644 index 0000000..2a96194 --- /dev/null +++ b/db/migrate/20210209140453_add_public_to_organisateurs.rb @@ -0,0 +1,5 @@ +class AddPublicToOrganisateurs < ActiveRecord::Migration[6.0] + def change + add_column :organisateurs, :public, :boolean, :default => true + end +end diff --git a/db/migrate/20210209153303_add_caches_to_p_customers.rb b/db/migrate/20210209153303_add_caches_to_p_customers.rb new file mode 100644 index 0000000..b08c3e3 --- /dev/null +++ b/db/migrate/20210209153303_add_caches_to_p_customers.rb @@ -0,0 +1,13 @@ +class AddCachesToPCustomers < ActiveRecord::Migration[6.0] + def change + add_column :p_customers, :cc_particular_name, :string + add_column :p_customers, :ac_particular_name, :string + add_column :p_customers, :cc_particular_firstname, :string + add_column :p_customers, :ac_particular_firstname, :string + + + PCustomer.all.each do |pc| + pc.save + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 73c5bef..e233e2d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_07_23_090815) do +ActiveRecord::Schema.define(version: 2021_02_09_153303) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -195,7 +195,7 @@ ActiveRecord::Schema.define(version: 2020_07_23_090815) do t.index ["table_row_id"], name: "index_cel_tables_on_table_row_id" end - create_table "circuit_region_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "circuit_region_cats", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.string "name" t.integer "position" t.datetime "created_at", precision: 6, null: false @@ -1392,6 +1392,7 @@ ActiveRecord::Schema.define(version: 2020_07_23_090815) do t.datetime "updated_at", precision: 6, null: false t.integer "circuit_region_id" t.string "slug" + t.boolean "public", default: true t.index ["admin_id"], name: "index_organisateurs_on_admin_id" end @@ -1738,6 +1739,10 @@ ActiveRecord::Schema.define(version: 2020_07_23_090815) do t.string "ac_show_name" t.boolean "particular_thankable", default: false t.boolean "particular_mail_sended", default: false + t.string "cc_particular_name" + t.string "ac_particular_name" + t.string "cc_particular_firstname" + t.string "ac_particular_firstname" t.index ["market_discount_id"], name: "index_p_customers_on_market_discount_id" t.index ["p_customer_cat_id"], name: "index_p_customers_on_p_customer_cat_id" t.index ["particular_id"], name: "index_p_customers_on_particular_id" @@ -2265,7 +2270,7 @@ ActiveRecord::Schema.define(version: 2020_07_23_090815) do t.datetime "updated_at", precision: 6, null: false end - create_table "particular_hists", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "particular_hists", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.bigint "particular_id" t.bigint "p_customer_id" t.text "description" diff --git a/public/uploads/tmp/1593001054-297866157927543-0003-5520/departement.csv b/public/uploads/tmp/1593001054-297866157927543-0003-5520/departement.csv new file mode 100644 index 0000000..b86dbe9 --- /dev/null +++ b/public/uploads/tmp/1593001054-297866157927543-0003-5520/departement.csv @@ -0,0 +1,101 @@ +"1","01","Ain","AIN","ain","A500" +"2","02","Aisne","AISNE","aisne","A250" +"3","03","Allier","ALLIER","allier","A460" +"5","05","Hautes-Alpes","HAUTES-ALPES","hautes-alpes","H32412" +"4","04","Alpes-de-Haute-Provence","ALPES-DE-HAUTE-PROVENCE","alpes-de-haute-provence","A412316152" +"6","06","Alpes-Maritimes","ALPES-MARITIMES","alpes-maritimes","A41256352" +"7","07","Ardèche","ARDÈCHE","ardeche","A632" +"8","08","Ardennes","ARDENNES","ardennes","A6352" +"9","09","Ariège","ARIÈGE","ariege","A620" +"10","10","Aube","AUBE","aube","A100" +"11","11","Aude","AUDE","aude","A300" +"12","12","Aveyron","AVEYRON","aveyron","A165" +"13","13","Bouches-du-Rhône","BOUCHES-DU-RHÔNE","bouches-du-rhone","B2365" +"14","14","Calvados","CALVADOS","calvados","C4132" +"15","15","Cantal","CANTAL","cantal","C534" +"16","16","Charente","CHARENTE","charente","C653" +"17","17","Charente-Maritime","CHARENTE-MARITIME","charente-maritime","C6535635" +"18","18","Cher","CHER","cher","C600" +"19","19","Corrèze","CORRÈZE","correze","C620" +"20","2a","Corse-du-sud","CORSE-DU-SUD","corse-du-sud","C62323" +"21","2b","Haute-corse","HAUTE-CORSE","haute-corse","H3262" +"22","21","Côte-d'or","CÔTE-D'OR","cote-dor","C360" +"23","22","Côtes-d'armor","CÔTES-D'ARMOR","cotes-darmor","C323656" +"24","23","Creuse","CREUSE","creuse","C620" +"25","24","Dordogne","DORDOGNE","dordogne","D6325" +"26","25","Doubs","DOUBS","doubs","D120" +"27","26","Drôme","DRÔME","drome","D650" +"28","27","Eure","EURE","eure","E600" +"29","28","Eure-et-Loir","EURE-ET-LOIR","eure-et-loir","E6346" +"30","29","Finistère","FINISTÈRE","finistere","F5236" +"31","30","Gard","GARD","gard","G630" +"32","31","Haute-Garonne","HAUTE-GARONNE","haute-garonne","H3265" +"33","32","Gers","GERS","gers","G620" +"34","33","Gironde","GIRONDE","gironde","G653" +"35","34","Hérault","HÉRAULT","herault","H643" +"36","35","Ile-et-Vilaine","ILE-ET-VILAINE","ile-et-vilaine","I43145" +"37","36","Indre","INDRE","indre","I536" +"38","37","Indre-et-Loire","INDRE-ET-LOIRE","indre-et-loire","I536346" +"39","38","Isère","ISÈRE","isere","I260" +"40","39","Jura","JURA","jura","J600" +"41","40","Landes","LANDES","landes","L532" +"42","41","Loir-et-Cher","LOIR-ET-CHER","loir-et-cher","L6326" +"43","42","Loire","LOIRE","loire","L600" +"44","43","Haute-Loire","HAUTE-LOIRE","haute-loire","H346" +"45","44","Loire-Atlantique","LOIRE-ATLANTIQUE","loire-atlantique","L634532" +"46","45","Loiret","LOIRET","loiret","L630" +"47","46","Lot","LOT","lot","L300" +"48","47","Lot-et-Garonne","LOT-ET-GARONNE","lot-et-garonne","L3265" +"49","48","Lozère","LOZÈRE","lozere","L260" +"50","49","Maine-et-Loire","MAINE-ET-LOIRE","maine-et-loire","M346" +"51","50","Manche","MANCHE","manche","M200" +"52","51","Marne","MARNE","marne","M650" +"53","52","Haute-Marne","HAUTE-MARNE","haute-marne","H3565" +"54","53","Mayenne","MAYENNE","mayenne","M000" +"55","54","Meurthe-et-Moselle","MEURTHE-ET-MOSELLE","meurthe-et-moselle","M63524" +"56","55","Meuse","MEUSE","meuse","M200" +"57","56","Morbihan","MORBIHAN","morbihan","M615" +"58","57","Moselle","MOSELLE","moselle","M240" +"59","58","Nièvre","NIÈVRE","nievre","N160" +"60","59","Nord","NORD","nord","N630" +"61","60","Oise","OISE","oise","O200" +"62","61","Orne","ORNE","orne","O650" +"63","62","Pas-de-Calais","PAS-DE-CALAIS","pas-de-calais","P23242" +"64","63","Puy-de-Dôme","PUY-DE-DÔME","puy-de-dome","P350" +"65","64","Pyrénées-Atlantiques","PYRÉNÉES-ATLANTIQUES","pyrenees-atlantiques","P65234532" +"66","65","Hautes-Pyrénées","HAUTES-PYRÉNÉES","hautes-pyrenees","H321652" +"67","66","Pyrénées-Orientales","PYRÉNÉES-ORIENTALES","pyrenees-orientales","P65265342" +"68","67","Bas-Rhin","BAS-RHIN","bas-rhin","B265" +"69","68","Haut-Rhin","HAUT-RHIN","haut-rhin","H365" +"70","69","Rhône","RHÔNE","rhone","R500" +"71","70","Haute-Saône","HAUTE-SAÔNE","haute-saone","H325" +"72","71","Saône-et-Loire","SAÔNE-ET-LOIRE","saone-et-loire","S5346" +"73","72","Sarthe","SARTHE","sarthe","S630" +"74","73","Savoie","SAVOIE","savoie","S100" +"75","74","Haute-Savoie","HAUTE-SAVOIE","haute-savoie","H321" +"76","75","Paris","PARIS","paris","P620" +"77","76","Seine-Maritime","SEINE-MARITIME","seine-maritime","S5635" +"78","77","Seine-et-Marne","SEINE-ET-MARNE","seine-et-marne","S53565" +"79","78","Yvelines","YVELINES","yvelines","Y1452" +"80","79","Deux-Sèvres","DEUX-SÈVRES","deux-sevres","D2162" +"81","80","Somme","SOMME","somme","S500" +"82","81","Tarn","TARN","tarn","T650" +"83","82","Tarn-et-Garonne","TARN-ET-GARONNE","tarn-et-garonne","T653265" +"84","83","Var","VAR","var","V600" +"85","84","Vaucluse","VAUCLUSE","vaucluse","V242" +"86","85","Vendée","VENDÉE","vendee","V530" +"87","86","Vienne","VIENNE","vienne","V500" +"88","87","Haute-Vienne","HAUTE-VIENNE","haute-vienne","H315" +"89","88","Vosges","VOSGES","vosges","V200" +"90","89","Yonne","YONNE","yonne","Y500" +"91","90","Territoire de Belfort","TERRITOIRE DE BELFORT","territoire-de-belfort","T636314163" +"92","91","Essonne","ESSONNE","essonne","E250" +"93","92","Hauts-de-Seine","HAUTS-DE-SEINE","hauts-de-seine","H32325" +"94","93","Seine-Saint-Denis","SEINE-SAINT-DENIS","seine-saint-denis","S525352" +"95","94","Val-de-Marne","VAL-DE-MARNE","val-de-marne","V43565" +"96","95","Val-d'oise","VAL-D'OISE","val-doise","V432" +"97","976","Mayotte","MAYOTTE","mayotte","M300" +"98","971","Guadeloupe","GUADELOUPE","guadeloupe","G341" +"99","973","Guyane","GUYANE","guyane","G500" +"100","972","Martinique","MARTINIQUE","martinique","M6352" +"101","974","Réunion","RÉUNION","reunion","R500" diff --git a/public/uploads/tmp/1593001097-861601596316031-0004-2417/departements-region.csv b/public/uploads/tmp/1593001097-861601596316031-0004-2417/departements-region.csv new file mode 100644 index 0000000..96582a9 --- /dev/null +++ b/public/uploads/tmp/1593001097-861601596316031-0004-2417/departements-region.csv @@ -0,0 +1,102 @@ +num_dep,dep_name,region_name +01,Ain,Auvergne-Rhône-Alpes +02,Aisne,Hauts-de-France +03,Allier,Auvergne-Rhône-Alpes +04,Alpes-de-Haute-Provence,Provence-Alpes-Côte d'Azur +05,Hautes-Alpes,Provence-Alpes-Côte d'Azur +06,Alpes-Maritimes,Provence-Alpes-Côte d'Azur +07,Ardèche,Auvergne-Rhône-Alpes +08,Ardennes,Grand Est +09,Ariège,Occitanie +10,Aube,Grand Est +11,Aude,Occitanie +12,Aveyron,Occitanie +13,Bouches-du-Rhône,Provence-Alpes-Côte d'Azur +14,Calvados,Normandie +15,Cantal,Auvergne-Rhône-Alpes +16,Charente,Nouvelle-Aquitaine +17,Charente-Maritime,Nouvelle-Aquitaine +18,Cher,Centre-Val de Loire +19,Corrèze,Nouvelle-Aquitaine +21,Côte-d'Or,Bourgogne-Franche-Comté +22,Côtes-d'Armor,Bretagne +23,Creuse,Nouvelle-Aquitaine +24,Dordogne,Nouvelle-Aquitaine +25,Doubs,Bourgogne-Franche-Comté +26,Drôme,Auvergne-Rhône-Alpes +27,Eure,Normandie +28,Eure-et-Loir,Centre-Val de Loire +29,Finistère,Bretagne +2A,Corse-du-Sud,Corse +2B,Haute-Corse,Corse +30,Gard,Occitanie +31,Haute-Garonne,Occitanie +32,Gers,Occitanie +33,Gironde,Nouvelle-Aquitaine +34,Hérault,Occitanie +35,Ille-et-Vilaine,Bretagne +36,Indre,Centre-Val de Loire +37,Indre-et-Loire,Centre-Val de Loire +38,Isère,Auvergne-Rhône-Alpes +39,Jura,Bourgogne-Franche-Comté +40,Landes,Nouvelle-Aquitaine +41,Loir-et-Cher,Centre-Val de Loire +42,Loire,Auvergne-Rhône-Alpes +43,Haute-Loire,Auvergne-Rhône-Alpes +44,Loire-Atlantique,Pays de la Loire +45,Loiret,Centre-Val de Loire +46,Lot,Occitanie +47,Lot-et-Garonne,Nouvelle-Aquitaine +48,Lozère,Occitanie +49,Maine-et-Loire,Pays de la Loire +50,Manche,Normandie +51,Marne,Grand Est +52,Haute-Marne,Grand Est +53,Mayenne,Pays de la Loire +54,Meurthe-et-Moselle,Grand Est +55,Meuse,Grand Est +56,Morbihan,Bretagne +57,Moselle,Grand Est +58,Nièvre,Bourgogne-Franche-Comté +59,Nord,Hauts-de-France +60,Oise,Hauts-de-France +61,Orne,Normandie +62,Pas-de-Calais,Hauts-de-France +63,Puy-de-Dôme,Auvergne-Rhône-Alpes +64,Pyrénées-Atlantiques,Nouvelle-Aquitaine +65,Hautes-Pyrénées,Occitanie +66,Pyrénées-Orientales,Occitanie +67,Bas-Rhin,Grand Est +68,Haut-Rhin,Grand Est +69,Rhône,Auvergne-Rhône-Alpes +70,Haute-Saône,Bourgogne-Franche-Comté +71,Saône-et-Loire,Bourgogne-Franche-Comté +72,Sarthe,Pays de la Loire +73,Savoie,Auvergne-Rhône-Alpes +74,Haute-Savoie,Auvergne-Rhône-Alpes +75,Paris,Île-de-France +76,Seine-Maritime,Normandie +77,Seine-et-Marne,Île-de-France +78,Yvelines,Île-de-France +79,Deux-Sèvres,Nouvelle-Aquitaine +80,Somme,Hauts-de-France +81,Tarn,Occitanie +82,Tarn-et-Garonne,Occitanie +83,Var,Provence-Alpes-Côte d'Azur +84,Vaucluse,Provence-Alpes-Côte d'Azur +85,Vendée,Pays de la Loire +86,Vienne,Nouvelle-Aquitaine +87,Haute-Vienne,Nouvelle-Aquitaine +88,Vosges,Grand Est +89,Yonne,Bourgogne-Franche-Comté +90,Territoire de Belfort,Bourgogne-Franche-Comté +91,Essonne,Île-de-France +92,Hauts-de-Seine,Île-de-France +93,Seine-Saint-Denis,Île-de-France +94,Val-de-Marne,Île-de-France +95,Val-d'Oise,Île-de-France +971,Guadeloupe,Guadeloupe +972,Martinique,Martinique +973,Guyane,Guyane +974,La Réunion,La Réunion +976,Mayotte,Mayotte