diff --git a/app/controllers/admin/m_odr_files_controller.rb b/app/controllers/admin/m_odr_files_controller.rb index b2c2133..97eab5e 100644 --- a/app/controllers/admin/m_odr_files_controller.rb +++ b/app/controllers/admin/m_odr_files_controller.rb @@ -29,12 +29,23 @@ class Admin::MOdrFilesController < ApplicationController @m_odr_file = MOdrFile.find(params[:id]) end + + + def download + @m_odr_file = MOdrFile.find(params[:id]) + + if @m_odr_file.file + send_file @m_odr_file.file.path, :disposition => (params[:disposition] || :inline) + end + end def create @m_odr_file = MOdrFile.new(params.require(:m_odr_file).permit!) if @m_odr_file.save + @m_odr_file.m_odr_rep.change_state("En cours de traitement") + else render action: "new" @@ -48,11 +59,16 @@ class Admin::MOdrFilesController < ApplicationController if @m_odr_file.update_attributes(params.require(:m_odr_file).permit!) + + @m_odr_file.m_odr_rep.change_state("En cours de traitement") else render action: "edit" end + + + end diff --git a/app/controllers/admin/m_odr_remises_controller.rb b/app/controllers/admin/m_odr_remises_controller.rb new file mode 100644 index 0000000..7633215 --- /dev/null +++ b/app/controllers/admin/m_odr_remises_controller.rb @@ -0,0 +1,112 @@ +# -*- encoding : utf-8 -*- + +class Admin::MOdrRemisesController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "payments" + end + + def confirm + + @m_odr_remise = MOdrRemise.find(params[:id]) + @m_odr_remise.m_odr_virements.each do |m_odr_virement| + m_odr_virement.sended = true + m_odr_virement.m_odr_rep.change_state("Virement envoyé") + m_odr_virement.save + + end + @m_odr_remise.confirmed = true + @m_odr_remise.save + + redirect_to [:admin, @m_odr_remise] + + end + + + def generate_all + + + redirect_to admin_m_odr_remises_path + + + @m_odr_virements = MOdrVirement.where(:enabled => true, :m_odr_remise_id => nil) + + @m_odr_virements.group(:m_odr_id).each do |m_odr| + @m_odr_remise = MOdrRemise.new(:m_odr_id => m_odr.m_odr_id) + m_odr_virements = @m_odr_virements.where(:m_odr_id => m_odr.m_odr_id) + @m_odr_remise.m_odr_virements << m_odr_virements + + @m_odr_remise.save + + + + end + + end + + + def index + @m_odr_remises = MOdrRemise.includes(:m_odr) + + @m_odr_remises = sort_by_sorting(@m_odr_remises, "created_at DESC") + + 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_remises = @m_odr_remises.page(page).per(per_page) + + + end + + def show + @m_odr_remise = MOdrRemise.find(params[:id]) + + end + + def new + @m_odr_remise = MOdrRemise.new + + end + + def edit + @m_odr_remise = MOdrRemise.find(params[:id]) + + end + + def create + @m_odr_remise = MOdrRemise.new(params.require(:m_odr_remise).permit!) + + if @m_odr_remise.save + + else + render action: "new" + + end + + end + + + def update + @m_odr_remise = MOdrRemise.find(params[:id]) + + + if @m_odr_remise.update_attributes(params.require(:m_odr_remise).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @m_odr_remise = MOdrRemise.find(params[:id]) + @m_odr_remise.destroy + + 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 21f8324..4b25082 100644 --- a/app/controllers/admin/m_odr_rep_ribs_controller.rb +++ b/app/controllers/admin/m_odr_rep_ribs_controller.rb @@ -34,7 +34,7 @@ class Admin::MOdrRepRibsController < ApplicationController @m_odr_rep_rib = MOdrRepRib.new(params.require(:m_odr_rep_rib).permit!) if @m_odr_rep_rib.save - + @m_odr_rep_rib.m_odr_rep.change_state("En cours de traitement") else render action: "new" @@ -48,7 +48,7 @@ class Admin::MOdrRepRibsController < ApplicationController if @m_odr_rep_rib.update_attributes(params.require(:m_odr_rep_rib).permit!) - + @m_odr_rep_rib.m_odr_rep.change_state("En cours de traitement") else render action: "edit" diff --git a/app/controllers/admin/m_odr_reps_controller.rb b/app/controllers/admin/m_odr_reps_controller.rb index 2a89d76..6e2edf6 100644 --- a/app/controllers/admin/m_odr_reps_controller.rb +++ b/app/controllers/admin/m_odr_reps_controller.rb @@ -7,17 +7,40 @@ class Admin::MOdrRepsController < ApplicationController before_action :admin_space def admin_space - @admin_space = "default" + @admin_space = "stocks" end def index - @m_odr_reps = MOdrRep.order(:name).all + @m_odr_reps = MOdrRep.includes(:particulars) + + + + + if params[:search][:state].to_s != "" + @m_odr_reps = @m_odr_reps.where(:state => params[:search][:state]) + end + + if params[:search][:m_odr_id].to_s != "" + @m_odr_reps = @m_odr_reps.where(:m_odr_id => params[:search][:m_odr_id]) + end + + #puts @m_odr_reps.klass + @m_odr_reps = sort_by_sorting(@m_odr_reps, "created_at DESC") + + + 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_reps = @m_odr_reps.page(page).per(per_page) + end def show @m_odr_rep = MOdrRep.find(params[:id]) - + @m_odr = @m_odr_rep.m_odr + + end def new @@ -62,4 +85,18 @@ class Admin::MOdrRepsController < ApplicationController @m_odr_rep.destroy end + + + def generate_virement + @m_odr_rep = MOdrRep.find(params[:id]) + + @m_odr_rep.m_odr_virements.create + @m_odr_rep.change_state("Virement demandé") + + redirect_back(fallback_location:"/") + end + + + + end diff --git a/app/controllers/admin/m_odr_virements_controller.rb b/app/controllers/admin/m_odr_virements_controller.rb new file mode 100644 index 0000000..82c346d --- /dev/null +++ b/app/controllers/admin/m_odr_virements_controller.rb @@ -0,0 +1,99 @@ +# -*- encoding : utf-8 -*- + +class Admin::MOdrVirementsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "payments" + end + + def index + @m_odr_virements = MOdrVirement.includes(:m_odr_rep) + + + if params[:search][:m_odr_id].to_s != "" + @m_odr_virements = @m_odr_virements.where(:m_odr_id => params[:search][:m_odr_id]) + end + + + @m_odr_virements = sort_by_sorting(@m_odr_virements, "created_at DESC") + + 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_virements = @m_odr_virements.page(page).per(per_page) + + end + + def show + @m_odr_virement = MOdrVirement.find(params[:id]) + + end + + def new + @m_odr_virement = MOdrVirement.new + + end + + def edit + @m_odr_virement = MOdrVirement.find(params[:id]) + + end + + def create + @m_odr_virement = MOdrVirement.new(params.require(:m_odr_virement).permit!) + + if @m_odr_virement.save + + else + render action: "new" + + end + + end + + + def update + @m_odr_virement = MOdrVirement.find(params[:id]) + + + if @m_odr_virement.update_attributes(params.require(:m_odr_virement).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @m_odr_virement = MOdrVirement.find(params[:id]) + @m_odr_virement.destroy + + end + + def admin_valid + @m_odr_virement = MOdrVirement.find(params[:id]) + @m_odr_virement.enabled = true + @m_odr_virement.save + + @m_odr_remise = @m_odr_virement.m_odr_remise if @m_odr_virement.m_odr_remise + + + end + + def refuse + @m_odr_virement = MOdrVirement.find(params[:id]) + @m_odr_virement.refused = true + @m_odr_virement.save + @m_odr_virement.m_odr_rep.change_state("Erreur sur virement") + @m_odr_remise = @m_odr_virement.m_odr_remise if @m_odr_virement.m_odr_remise + + end + + +end diff --git a/app/controllers/admin/m_odrs_controller.rb b/app/controllers/admin/m_odrs_controller.rb index e07b513..2901e66 100644 --- a/app/controllers/admin/m_odrs_controller.rb +++ b/app/controllers/admin/m_odrs_controller.rb @@ -7,7 +7,7 @@ class Admin::MOdrsController < ApplicationController before_action :admin_space def admin_space - @admin_space = "default" + @admin_space = "stocks" end def index diff --git a/app/controllers/admin/mail_hists_controller.rb b/app/controllers/admin/mail_hists_controller.rb new file mode 100644 index 0000000..cbc9d82 --- /dev/null +++ b/app/controllers/admin/mail_hists_controller.rb @@ -0,0 +1,74 @@ +# -*- encoding : utf-8 -*- + +class Admin::MailHistsController < ApplicationController + layout "admin" + before_action :auth_admin + + before_action :admin_space + + def admin_space + @admin_space = "stocks" + end + + def index + @mail_hists = MailHist.all + + @mail_hists = sort_by_sorting(@mail_hists, "created_at DESC") + + + params[:search][:per_page] = params[:search][:per_page] || 50 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @mail_hists = @mail_hists.page(page).per(per_page) + + + end + + def show + @mail_hist = MailHist.find(params[:id]) + + end + + def new + @mail_hist = MailHist.new + + end + + def edit + @mail_hist = MailHist.find(params[:id]) + + end + + def create + @mail_hist = MailHist.new(params.require(:mail_hist).permit!) + + if @mail_hist.save + + else + render action: "new" + + end + + end + + + def update + @mail_hist = MailHist.find(params[:id]) + + + if @mail_hist.update_attributes(params.require(:mail_hist).permit!) + + else + render action: "edit" + + end + + end + + + def destroy + @mail_hist = MailHist.find(params[:id]) + @mail_hist.destroy + + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2471a9c..4adcb86 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,9 +3,37 @@ class ApplicationController < ActionController::Base # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + + + + before_action :set_locale + + + + before_action :popups + + before_action :debug_translation + + before_action :get_sorting + + def get_sorting( column_default=nil, direction_default="desc") + + + + sorting_direction = %w[asc desc].include?(params[:direction]) ? params[:direction] : direction_default + sorting_column = params[:column] ? params[:column] : column_default + + if sorting_direction and sorting_column + @sorting = [sorting_column, sorting_direction] + end + end + + before_action :set_qi_order def set_qi_order + params[:search] = params[:search] || {} + session[:qi_sort_string] = session[:qi_sort_string] || {} if params[:qi_sort_string].to_s != "" and params[:qi_sort_string][:class] @@ -51,30 +79,9 @@ class ApplicationController < ActionController::Base end - - - before_action :set_locale - - - - before_action :popups - - before_action :debug_translation - - before_action :get_sorting - - def get_sorting - - sorting_direction = %w[asc desc].include?(params[:direction]) ? params[:direction] : "asc" - sorting_column = params[:column] ? params[:column] : nil - - if sorting_direction and sorting_column - @sorting = [sorting_column, sorting_direction] - end - end - def sort_by_sorting(var) + def sort_by_sorting(var, default=nil) if @sorting klass = var.klass.to_s @@ -96,9 +103,12 @@ class ApplicationController < ActionController::Base end - + elsif default + var = var.order(default) end + + return var @@ -107,6 +117,7 @@ class ApplicationController < ActionController::Base + def debug_translation if params[:debug_translation] if current_admin diff --git a/app/controllers/public/m_odr_reps_controller.rb b/app/controllers/public/m_odr_reps_controller.rb index 9985ef6..82721cd 100644 --- a/app/controllers/public/m_odr_reps_controller.rb +++ b/app/controllers/public/m_odr_reps_controller.rb @@ -19,11 +19,7 @@ class Public::MOdrRepsController < ApplicationController @m_odr = @m_odr_rep.m_odr if @m_odr_rep.save - if mail_type = @m_odr.mail_types.where(:slug => "confirmation-inscription").first - - mail = GeneralMails.general(:fr, mail_type, @m_odr_rep.particulars.first.email, {:arguments => {:numero_avoir => ""}, :m_odr => @m_odr}) - mail.deliver - end + @m_odr_rep.send_mail_type("confirmation-inscription") redirect_to thank_public_m_odr_rep_path(@m_odr_rep) diff --git a/app/helpers/translation_helper.rb b/app/helpers/translation_helper.rb index d721638..9217cb1 100755 --- a/app/helpers/translation_helper.rb +++ b/app/helpers/translation_helper.rb @@ -21,5 +21,34 @@ module TranslationHelper raw t.value end end + + + def state_helper(value) + value = value.to_s + if ["brouillon","Reçue"].include?(value) + r = ''+value+'' + elsif ["Virement envoyé", "Validé"].include?(value) + r = ''+value+'' + elsif value == "commande" + r = 'Commande' + elsif value == "livraison-en-cours" + r = 'Livr. en cours' + elsif ["Virement demandé"].include?(value) + r = ''+value+'' + elsif value =="facturée" + r = 'Facturée' + elsif value == "annulée" + r = 'Annulée' + elsif ["Erreur sur virement", "Refusé"].include?(value) + r = ''+value+'' + elsif ["En cours de traitement"].include?(value) + r = ''+value+'' + + else + r = ''+value+'' + end + + return raw(r) + end end diff --git a/app/mailers/general_mails.rb b/app/mailers/general_mails.rb index e7cd8f9..09e6aaf 100644 --- a/app/mailers/general_mails.rb +++ b/app/mailers/general_mails.rb @@ -58,5 +58,35 @@ class GeneralMails < ActionMailer::Base + def general2(email_to, subject, body, mail_options = {}) + @options = mail_options + + @m_odr = @options[:m_odr] + + @to = email_to + + @body = body + + + @subject = subject + + + @ccis = @options[:ccis] || [] + + if @options[:from] + @from = @options[:from] + elsif @m_odr and @m_odr.email_from? + @from = @m_odr.email_from + end + + if @from + mail(:to => @to, :subject => @subject, :bcc => @ccis.join(";"), :from => @from) + else + mail(:to => @to, :subject => @subject, :bcc => @ccis.join(";")) + end + + end + + end diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 3f9adaa..0914134 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -7,9 +7,15 @@ class ApplicationRecord < ActiveRecord::Base #START QI_DYNAMICS_CORE QI_DYNAMICS.each do |s| - define_method("#{s}") { - return eval("!self.ac_#{s} ? self.ca_#{s} : self.ac_#{s}") - } + if true + define_method("#{s}") { + return eval("!self.ac_#{s} ? self.ca_#{s} : self.ac_#{s}") + } + + else + puts "QI DYNAMICS : pas de méthode pour ca_#{s}" + end + end def qi_dynamics_cache @@ -25,7 +31,11 @@ class ApplicationRecord < ActiveRecord::Base QI_DYNAMICS.each do |s| - eval("self.cc_#{s} = self.#{s}") + + if true + + eval("self.cc_#{s} = self.#{s}") + end end end diff --git a/app/models/m_odr.rb b/app/models/m_odr.rb index 5437591..22343cc 100644 --- a/app/models/m_odr.rb +++ b/app/models/m_odr.rb @@ -44,4 +44,7 @@ class MOdr < ApplicationRecord + + + end diff --git a/app/models/m_odr_remise.rb b/app/models/m_odr_remise.rb new file mode 100644 index 0000000..e2b2242 --- /dev/null +++ b/app/models/m_odr_remise.rb @@ -0,0 +1,66 @@ +class MOdrRemise < ApplicationRecord + belongs_to :m_odr + + + + + QI_DYNAMICS = %w(iban_from bic_from bank_name bank_subject) + + eval(QI_DYNAMICS_CORE) + + has_many :m_odr_virements, :dependent => :nullify + + def self.qi_table_order + { + :m_odr_name => "ODR", + :created_at => {:name => "Date", :reorder => true}, + :state => {:name => "Etat", :reorder => true}, + :confirmed => {:name => "Confirmé ?", :reorder => true}, + :nbr_virements => "Nbr virements", + :actions => "Actions", + + } + + end + + def self.valid_sort + r = [] + self.qi_table_order.each do |key, value| + if value.instance_of? Hash + if value[:reorder] and value[:reorder] == true + r << key.to_s if value[:reorder] + end + end + end + return r + + + end + + def m_odr_name + self.m_odr.name if self.m_odr + end + + + + def nbr_virements + self.m_odr_virements.count + end + + def ca_iban_from + self.m_odr.iban if self.m_odr + end + + def ca_bic_from + self.m_odr.bic if self.m_odr + end + + def ca_bank_name + self.m_odr.bank_name if self.m_odr + end + + def ca_bank_subject + self.m_odr.bank_subject if self.m_odr + end + +end diff --git a/app/models/m_odr_rep.rb b/app/models/m_odr_rep.rb index 3d827df..cb130f9 100644 --- a/app/models/m_odr_rep.rb +++ b/app/models/m_odr_rep.rb @@ -5,7 +5,9 @@ class MOdrRep < ApplicationRecord has_many :particulars, :dependent => :destroy accepts_nested_attributes_for :particulars, :allow_destroy => true + has_many :mail_hists + has_many :m_odr_virements has_many :m_odr_rep_ribs, :dependent => :destroy accepts_nested_attributes_for :m_odr_rep_ribs, :allow_destroy => true @@ -14,6 +16,8 @@ class MOdrRep < ApplicationRecord belongs_to :m_odr_place + belongs_to :particular + has_many :m_odr_files, :dependent => :destroy accepts_nested_attributes_for :m_odr_files, :allow_destroy => true @@ -26,9 +30,51 @@ class MOdrRep < ApplicationRecord belongs_to :m_odr_tracker - attr_accessor :t + def send_mail_type(slug, element = nil) + + if self.m_odr and mail_type = self.m_odr.mail_types.where(:slug => slug).first and self.particulars.first and self.particulars.first.email? + mail_hist = MailHist.generate_mail(:fr, mail_type, self.particulars.first.email, {:arguments => {:nom_odr => self.m_odr.name}, :m_odr => self.m_odr, :m_odr_rep => self}) + end + end + + + QI_DYNAMICS = %w(admin_ok_to_send rib_admin_ok +file_admin_ok remise particular_civilite particular_name particular_firstname particular_address_2 particular_address_3 particular_cp particular_city particular_country particular_email particular_tel product_name product_brand tracker_name place_name) + + eval(QI_DYNAMICS_CORE) + + + + def ca_rib_admin_ok + if self.m_odr_rep_ribs.where(:admin_ok => true).count > 0 + true + else + false + end + end + + def ca_file_admin_ok + if self.m_odr_files.where(:admin_ok => true).count > 0 + true + else + false + end + end + + + + def change_state(state) + self.state = state + self.save + end before_validation do + self.particular = self.particulars.first + + if !self.state + self.state = "Reçue" + end + if self.t.to_s != "" self.m_odr_tracker = MOdrTracker.where(:token => self.t).first end @@ -38,6 +84,66 @@ class MOdrRep < ApplicationRecord + def ca_particular_civilite + self.particular.civilite if self.particular + end + + def ca_particular_name + self.particular.name if self.particular + end + def ca_particular_firstname + self.particular.firstname if self.particular + end + def ca_particular_address_2 + self.particular.address_2 if self.particular + end + def ca_particular_address_3 + self.particular.address_3 if self.particular + end + def ca_particular_cp + self.particular.cp if self.particular + end + def ca_particular_city + self.particular.city if self.particular + end + def ca_particular_country + self.particular.country if self.particular + end + def ca_particular_email + self.particular.email if self.particular + end + + def ca_particular_tel + self.particular.tel if self.particular + end + + def ca_product_name + self.m_odr_product.name if self.m_odr_product + end + + def ca_product_brand + self.m_odr_product.m_odr_brand.name if self.m_odr_product and self.m_odr_product.m_odr_brand + end + + def ca_tracker_name + self.m_odr_tracker.name if self.m_odr_tracker + end + + def ca_place_name + self.m_odr_place.name if self.m_odr_place + end + + + attr_accessor :t + + + + + + + + + before_create { generate_token() } def generate_token() @@ -46,4 +152,93 @@ class MOdrRep < ApplicationRecord end while MOdrRep.exists?(:token => self[:token]) end + + + def self.qi_table_order + { + :m_odr => "ODR", + :created_at => {:name => "Date", :reorder => true}, + :state => {:name => "Etat", :reorder => true}, + :cc_rib_admin_ok => {:name => "Rib valide ?", :reorder => true}, + :cc_file_admin_ok => {:name => "Fichiers valides ?", :reorder => true}, + :cc_admin_ok_to_send => {:name => "Virement à envoyer ?", :reorder => true}, + :cc_particular_civilite => {:name => "Civ.", :reorder => true}, + :cc_particular_name => {:name => "Nom", :reorder => true}, + :cc_particular_firstname => {:name => "Prénom", :reorder => true}, + :cc_particular_address_2 => {:name => "Adresse", :reorder => true}, + :cc_particular_address_3 => {:name => "Adresse (2)", :reorder => true}, + :cc_particular_cp => {:name => "Code postal", :reorder => true}, + :cc_particular_city => {:name => "Ville", :reorder => true}, + :cc_particular_country => {:name => "Pays", :reorder => true}, + :cc_particular_email => {:name => "Email", :reorder => true}, + :cc_particular_tel => {:name => "Tel", :reorder => true}, + + :cc_particular_tel => {:name => "Tel", :reorder => true}, + :cc_particular_tel => {:name => "Tel", :reorder => true}, + + + :cc_product_brand => {:name => "Marque", :reorder => true}, + :cc_product_name => {:name => "Produit", :reorder => true}, + :qte => {:name => "Quantité", :reorder => true}, + :cc_remise => {:name => "Remise", :reorder => true}, + + :cc_place_name => {:name => "Revendeur", :reorder => true}, + + + + + :cc_tracker_name => {:name => "Trackeur", :reorder => true}, + + + + :actions => "Actions", + + #:created_at => {:name => "Date", :reorder => true}, + + + } + #, :sort_name => "code" + end + + def ca_admin_ok_to_send + if self.rib_admin_ok and self.file_admin_ok + true + else + false + end + end + + + def ca_remise + if self.qte and self.m_odr_product + + if self.m_odr_product and remise = self.m_odr_product.m_odr_product_remises.where(:qte => self.qte).first + remise.amount + else + nil + + end + + + end + end + + def long_name + self.particular.long_name if self.particular + end + + def self.valid_sort + r = [] + self.qi_table_order.each do |key, value| + if value.instance_of? Hash + if value[:reorder] and value[:reorder] == true + r << key.to_s if value[:reorder] + end + end + end + return r + + + end + end diff --git a/app/models/m_odr_virement.rb b/app/models/m_odr_virement.rb new file mode 100644 index 0000000..c8eb5a8 --- /dev/null +++ b/app/models/m_odr_virement.rb @@ -0,0 +1,105 @@ +class MOdrVirement < ApplicationRecord + belongs_to :m_odr + belongs_to :m_odr_rep + belongs_to :m_odr_rep_rib + + belongs_to :m_odr_remise + + + + QI_DYNAMICS = %w(remise iban_to bic_to iban_from bic_from bank_name bank_subject libelle ) + + eval(QI_DYNAMICS_CORE) + + + def self.qi_table_order + { + + :created_at => {:name => "Date", :reorder => true}, + + + + :amount => {:name => "Montant", :reorder => true}, + :cc_iban_to => {:name => "Iban destinataire", :reorder => true}, + :cc_bic_to => {:name => "Bic destinataire", :reorder => true}, + :cc_iban_from => {:name => "Iban expéditeur", :reorder => true}, + :cc_bic_from => {:name => "Bic expéditeur", :reorder => true}, + + + + + :enabled => {:name => "Vérifié ?", :reorder => true}, + + :sended => {:name => "Envoyé ?", :reorder => true}, + + :refused => {:name => "Refusé ?", :reorder => true}, + + + :actions => "Actions", + + #:created_at => {:name => "Date", :reorder => true}, + + + } + #, :sort_name => "code" + end + + def ca_remise + self.m_odr_rep.remise if self.m_odr_rep + end + + def ca_iban_to + self.m_odr_rep_rib.iban if self.m_odr_rep_rib + end + + def ca_bic_to + self.m_odr_rep_rib.bic if self.m_odr_rep_rib + end + + def ca_iban_from + self.m_odr_remise.iban_from if self.m_odr_remise + end + + def ca_bic_from + self.m_odr_remise.bic_from if self.m_odr_remise + end + + def ca_bank_name + self.m_odr_remise.bank_name if self.m_odr_remise + end + + def ca_bank_subject + self.m_odr_remise.bank_subject if self.m_odr_remise + end + + def ca_libelle + self.id.to_s+"-"+self.bank_subject if self.bank_subject + end + + + + before_validation do + self.m_odr = self.m_odr_rep.m_odr if self.m_odr_rep + + self.m_odr_rep_rib = self.m_odr_rep.m_odr_rep_ribs.where(:admin_ok => true).order("id DESC").first + + self.amount = self.remise + + end + + + def self.valid_sort + r = [] + self.qi_table_order.each do |key, value| + if value.instance_of? Hash + if value[:reorder] and value[:reorder] == true + r << key.to_s if value[:reorder] + end + end + end + return r + + + end + +end diff --git a/app/models/mail_hist.rb b/app/models/mail_hist.rb new file mode 100644 index 0000000..65fc9d2 --- /dev/null +++ b/app/models/mail_hist.rb @@ -0,0 +1,131 @@ +class MailHist < ApplicationRecord + belongs_to :mail_content + belongs_to :mail_type + belongs_to :m_odr_rep + belongs_to :m_odr + belongs_to :lang_site + + belongs_to :element, :polymorphic => true + + QI_DYNAMICS = %w() + + eval(QI_DYNAMICS_CORE) + + + + def self.qi_table_order + { + :m_odr => {:name => "ODR"}, + :m_odr_rep => {:name => "Participation"}, + :created_at => {:name => "Date", :reorder => true}, + :from_email => {:name => "Email exp.", :reorder => true}, + :to_email => {:name => "Email dest.", :reorder => true}, + :subject => {:name => "Sujet.", :reorder => true}, + :actions => "Actions", + } + end + + + def self.valid_sort + r = [] + self.qi_table_order.each do |key, value| + if value.instance_of? Hash + if value[:reorder] and value[:reorder] == true + r << key.to_s if value[:reorder] + end + end + end + + return r + end + + + + + + def self.generate_mail(lang_slug, mail_type, email, options = {}) + + #(lang_slug, mail_type, @m_odr_rep.particulars.first.email, {:arguments => {:numero_avoir => ""}, :m_odr => @m_odr}) + + @options = options + + @lang_site = LangSite.find_by_slug(lang_slug) + + @mail_type = mail_type + + @mail_content = @mail_type.mail_contents.where(:lang_site_id => @lang_site.id).first + + @m_odr = options[:m_odr] + @m_odr_rep = options[:m_odr_rep] + + @arguments = @options[:arguments] + + + + arguments = @arguments + + + s = @mail_content.subject.to_s + arguments.each_pair do |key, value| + s = s.gsub(/\[#{key.to_s}\]/, value.to_s) + + end + @subject = s + + r = @mail_content.message + arguments.each_pair do |key, value| + r = r.gsub(/\[#{key.to_s}\]/, value.to_s) + + end + + @body = r + + + if @options[:from] + @from = @options[:from] + elsif @m_odr and @m_odr.email_from? + @from = @m_odr.email_from + end + + + @to_email = email + + mail_history = MailHist.create(:lang_site => @lang_site, :to_email => @to_email, :from_email => @from, :element => options[:element], :subject => @subject, :body => @body, :m_odr => @m_odr, :m_odr_rep => @m_odr_rep, :mail_content => @mail_content, :mail_type => @mail_type) + + + mail = GeneralMails.general2(@to_email, @subject, @body, mail_options = {:m_odr => @m_odr}) + + mail_history.subject_send = @subject + mail_history.body_send = mail.body.encoded + + mail.deliver + + + mail_history.save + + + + return mail_history + + + end + + def deliver_mail + mail = GeneralMails.general(self.lang_site.slug, self.mail_type.slug, self.email , self.subject, self.content) + + self.subject_cache = self.subject + self.content_cache = mail.body.encoded + + mail.deliver + + self.sended = true + self.sended_at = Time.now + + self.save + + + + + end + +end diff --git a/app/models/particular.rb b/app/models/particular.rb index 0604a02..427fa62 100644 --- a/app/models/particular.rb +++ b/app/models/particular.rb @@ -68,6 +68,18 @@ class Particular < ApplicationRecord end + + def long_name + r = "" + + r+= "#{self.civilite} " if self.civilite + r+= "#{self.firstname} " if self.firstname + r+= "#{self.name} " if self.name + + return r + + + end def address_longue address_2.to_s + " " + address_3.to_s end diff --git a/app/uploaders/odr_uploader.rb b/app/uploaders/odr_uploader.rb index bb78902..0873354 100644 --- a/app/uploaders/odr_uploader.rb +++ b/app/uploaders/odr_uploader.rb @@ -17,7 +17,7 @@ class OdrUploader < CarrierWave::Uploader::Base end def url - "/download_odr_file/#{model.id}" + "/admin/m_odr_files/#{model.id}/download" end diff --git a/app/views/admin/admin_spaces/_payments.html.haml b/app/views/admin/admin_spaces/_payments.html.haml index 4ec8bca..9df6456 100644 --- a/app/views/admin/admin_spaces/_payments.html.haml +++ b/app/views/admin/admin_spaces/_payments.html.haml @@ -1,8 +1,8 @@ -%li= link_to "Paiements", admin_p_payments_path +%li= link_to "Virements", admin_m_odr_virements_path =#%li= link_to "Remises", admin_p_remises_path =#%li= link_to "Relances", relances_admin_p_payments_path -%li= link_to "Types de paiement", admin_p_payment_types_path +%li= link_to "Remises", admin_m_odr_remises_path =#%li= link_to "Comptes bancaires", admin_p_bank_accounts_path =#%li= link_to "Banques", admin_p_banks_path diff --git a/app/views/admin/admin_spaces/_stocks.html.haml b/app/views/admin/admin_spaces/_stocks.html.haml index 6cedd6f..ea8d178 100644 --- a/app/views/admin/admin_spaces/_stocks.html.haml +++ b/app/views/admin/admin_spaces/_stocks.html.haml @@ -1,17 +1,8 @@ -=#%li= link_to "Commandes fournisseurs", admin_p_fournisseur_orders_path --if current_admin.has_permission?("products") - %li= link_to "Produits", admin_p_products_path --if current_admin.has_permission?("product-cats") - %li= link_to "Catégories produits", admin_p_product_cats_path +%li= link_to "Participations ODR", admin_m_odr_reps_path --if current_admin.has_permission?("product_sub_cats") - %li= link_to "Sous catégories produits", admin_p_product_sub_cats_path --if current_admin.has_permission?("brands") - %li= link_to "Marques", admin_s_brands_path - --if current_admin.has_permission?("fournisseurs") - %li= link_to "Fournisseurs", admin_p_fournisseurs_path +%li= link_to "ODR", admin_m_odrs_path +%li= link_to "Historique mail", admin_mail_hists_path diff --git a/app/views/admin/m_odr_files/_form.html.haml b/app/views/admin/m_odr_files/_form.html.haml index 8a6349c..c408b9f 100644 --- a/app/views/admin/m_odr_files/_form.html.haml +++ b/app/views/admin/m_odr_files/_form.html.haml @@ -2,14 +2,10 @@ .content =f.inputs do - = f.input :file, :label => "file :" - = f.input :m_odr, :label => "m_odr :" - = f.input :action_date, :label => "action_date :" - = f.input :notes, :label => "notes :" - = f.input :name, :label => "name :" - = f.input :m_odr_file_type, :label => "m_odr_file_type :" - + = f.input :admin_ok, :label => "Décision :", :collection => [["Validé",true], ["Refusé", false]], :as => :select + = f.input :reject_reason, :label => "Motif du rejet :", :collection => ["Mauvais document","Mauvaise qualité rendant le fichier illisible"] + = f.input :reject_reason_description, :label => "Précisions sur le rejet" diff --git a/app/views/admin/m_odr_files/update.js copy.erb b/app/views/admin/m_odr_files/update.js copy.erb new file mode 100644 index 0000000..356ec52 --- /dev/null +++ b/app/views/admin/m_odr_files/update.js copy.erb @@ -0,0 +1,2 @@ +$('#m_odr_file_row_<%= @m_odr_file.id %>').replaceWith("<%= escape_javascript(render(@m_odr_file))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odr_files/update.js.erb b/app/views/admin/m_odr_files/update.js.erb index 356ec52..2905cd0 100644 --- a/app/views/admin/m_odr_files/update.js.erb +++ b/app/views/admin/m_odr_files/update.js.erb @@ -1,2 +1,2 @@ -$('#m_odr_file_row_<%= @m_odr_file.id %>').replaceWith("<%= escape_javascript(render(@m_odr_file))%>"); + close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odr_remises/_form.html.haml b/app/views/admin/m_odr_remises/_form.html.haml new file mode 100644 index 0000000..32b289a --- /dev/null +++ b/app/views/admin/m_odr_remises/_form.html.haml @@ -0,0 +1,18 @@ +=semantic_form_for [:admin, @m_odr_remise], :remote => true do |f| + + .content + =f.inputs do + = f.input :notes, :label => "notes :" + = f.input :m_odr, :label => "m_odr :" + = f.input :download_at, :label => "download_at :" + = f.input :confirmed_at, :label => "confirmed_at :" + = f.input :state, :label => "state :" + = f.input :confirmed, :label => "confirmed :" + = f.input :admin_id, :label => "admin_id :" + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/m_odr_remises/_m_odr_remise.html.haml b/app/views/admin/m_odr_remises/_m_odr_remise.html.haml new file mode 100644 index 0000000..d6b63b4 --- /dev/null +++ b/app/views/admin/m_odr_remises/_m_odr_remise.html.haml @@ -0,0 +1,34 @@ +%tr#m_odr_remise_row{:id => m_odr_remise.id} + -tr = {} + + + + + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, m_odr_remise], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_m_odr_remise_path(m_odr_remise), :remote => true + = link_to i(:eye), admin_m_odr_remise_path(m_odr_remise), :remote => false + + + + -if !@qi_table_orders + =render :partial => "qi/qi_ordered_table_head", :locals => {:qi_ordered_table_name => m_odr_remise.class.to_s.tableize, :qi_ordered_table_model => m_odr_remise.class} + + + + + + -@qi_table_orders[:m_odr_remises].each do |key,value| + -if tr[:"#{key}"] + =raw tr[:"#{key}"] + -elsif (m_odr_remise.respond_to?(key)) + %td + =m_odr_remise.send(key.to_s) + + -else + %td + Err : + =key + diff --git a/app/views/admin/m_odr_remises/create.js.erb b/app/views/admin/m_odr_remises/create.js.erb new file mode 100644 index 0000000..3dca328 --- /dev/null +++ b/app/views/admin/m_odr_remises/create.js.erb @@ -0,0 +1,2 @@ +$('#m_odr_remises_rows').prepend("<%= escape_javascript(render(@m_odr_remise))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odr_remises/destroy.js.erb b/app/views/admin/m_odr_remises/destroy.js.erb new file mode 100644 index 0000000..ba3f6c3 --- /dev/null +++ b/app/views/admin/m_odr_remises/destroy.js.erb @@ -0,0 +1 @@ +$('#m_odr_remise_<%= @m_odr_remise.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/m_odr_remises/edit.js.erb b/app/views/admin/m_odr_remises/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/m_odr_remises/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/m_odr_remises/index.html.haml b/app/views/admin/m_odr_remises/index.html.haml new file mode 100644 index 0000000..696738a --- /dev/null +++ b/app/views/admin/m_odr_remises/index.html.haml @@ -0,0 +1,31 @@ +.qi_header + .right= link_to 'Ajouter ', new_admin_m_odr_remise_path(), :class => "btn btn-primary", :remote => true + %h1 + Virements + %span + Remises + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + -params[:search] =params[:search] || {} + %table + %tr + %td + Statut : + =select_tag "search[state]", options_for_select([["",""]]+MOdrRep.group(:state).order(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]) + + + %td + Opération : + =select_tag "search[m_odr_id]", options_for_select([["",""]]+MOdr.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:m_odr_id]) + + + %td=text_field_tag :name, params[:name],:class => "form-control", :placeholder => "Nom" + + + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @m_odr_remises} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_remises} \ No newline at end of file diff --git a/app/views/admin/m_odr_remises/new.js.erb b/app/views/admin/m_odr_remises/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/m_odr_remises/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/m_odr_remises/show.html.haml b/app/views/admin/m_odr_remises/show.html.haml new file mode 100644 index 0000000..ad8c173 --- /dev/null +++ b/app/views/admin/m_odr_remises/show.html.haml @@ -0,0 +1,24 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =link_to "Confirmer maintenant TOUS les virements", confirm_admin_m_odr_remise_path(@m_odr_remise) if !@m_odr_remise.confirmed + + + + %hr + Virements + + + -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_virements = @m_odr_remise.m_odr_virements.page(page).per(per_page) + + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_virements} + \ No newline at end of file diff --git a/app/views/admin/m_odr_remises/update.js.erb b/app/views/admin/m_odr_remises/update.js.erb new file mode 100644 index 0000000..a513b5e --- /dev/null +++ b/app/views/admin/m_odr_remises/update.js.erb @@ -0,0 +1,2 @@ +$('#m_odr_remise_row_<%= @m_odr_remise.id %>').replaceWith("<%= escape_javascript(render(@m_odr_remise))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odr_rep_ribs/_form.html.haml b/app/views/admin/m_odr_rep_ribs/_form.html.haml index 420d78f..bdb2457 100644 --- a/app/views/admin/m_odr_rep_ribs/_form.html.haml +++ b/app/views/admin/m_odr_rep_ribs/_form.html.haml @@ -4,16 +4,12 @@ =f.inputs do = f.input :iban, :label => "iban :" = f.input :bic, :label => "bic :" - = f.input :name, :label => "name :" - = f.input :admin, :label => "admin :" - = f.input :admin_valid, :label => "admin_valid :" - = f.input :confirmed, :label => "confirmed :" - = f.input :m_odr_rep_id, :label => "m_odr_rep_id :" - = f.input :nbr_virements, :label => "nbr_virements :" - = f.input :bank_name, :label => "bank_name :" - = f.input :bank_adress, :label => "bank_adress :" - = f.input :notes, :label => "notes :" - + %hr + = f.input :admin_ok, :label => "Décision :", :collection => [["Validé",true], ["Refusé", false]], :as => :select + = f.input :reject_reason, :label => "Motif du rejet :", :collection => ["RIB et IBAN invalide"] + + = f.input :reject_reason_description, :label => "Précisions sur le rejet" + diff --git a/app/views/admin/m_odr_rep_ribs/update.js copy.erb b/app/views/admin/m_odr_rep_ribs/update.js copy.erb new file mode 100644 index 0000000..95c7e87 --- /dev/null +++ b/app/views/admin/m_odr_rep_ribs/update.js copy.erb @@ -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(); \ No newline at end of file diff --git a/app/views/admin/m_odr_rep_ribs/update.js.erb b/app/views/admin/m_odr_rep_ribs/update.js.erb index 95c7e87..d047c85 100644 --- a/app/views/admin/m_odr_rep_ribs/update.js.erb +++ b/app/views/admin/m_odr_rep_ribs/update.js.erb @@ -1,2 +1 @@ -$('#m_odr_rep_rib_row_<%= @m_odr_rep_rib.id %>').replaceWith("<%= escape_javascript(render(@m_odr_rep_rib))%>"); close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odr_reps/_form.html.haml b/app/views/admin/m_odr_reps/_form.html.haml index 210dcd9..35e292d 100644 --- a/app/views/admin/m_odr_reps/_form.html.haml +++ b/app/views/admin/m_odr_reps/_form.html.haml @@ -2,16 +2,22 @@ .content =f.inputs do - = f.input :state, :label => "state :" - = f.input :admin_id, :label => "admin_id :" - = f.input :admin_valid, :label => "admin_valid :" - = f.input :token, :label => "token :" - = f.input :m_odr, :label => "m_odr :" - = f.input :rgpd, :label => "rgpd :" + =# f.input :state, :label => "state :" + =# f.input :admin_id, :label => "admin_id :" + =# f.input :admin_valid, :label => "admin_valid :" + =# f.input :token, :label => "token :" + =# f.input :m_odr, :label => "m_odr :" + =# f.input :rgpd, :label => "rgpd :" - - - + =f.input :m_odr_product_id, :label => "Pneu :", :as => :select, :collection => f.object.m_odr.m_odr_products.order("m_odr_brand_id ASC, m_odr_products.name"), :member_label => :member_label, :include_blank => true + + + =f.input :qte, :label => "Nombre de pneus :", :as => :select, :collection => [1,2], :include_blank => true + + + =f.input :m_odr_place, :label => "Point de vente :", :as => :select, :collection => f.object.m_odr.m_odr_places.order(:name), :include_blank => true + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" \ No newline at end of file diff --git a/app/views/admin/m_odr_reps/_m_odr_rep.html.haml b/app/views/admin/m_odr_reps/_m_odr_rep.html.haml index 98bbff9..899d3d6 100644 --- a/app/views/admin/m_odr_reps/_m_odr_rep.html.haml +++ b/app/views/admin/m_odr_reps/_m_odr_rep.html.haml @@ -1,13 +1,35 @@ %tr#m_odr_rep_row{:id => m_odr_rep.id} - %td= m_odr_rep.state - %td= m_odr_rep.admin_id - %td= m_odr_rep.admin_valid - %td= m_odr_rep.token - %td= m_odr_rep.m_odr_id - %td= m_odr_rep.rgpd - - %td.actions - = link_to i(:"trash-o"), [:admin, m_odr_rep], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true - = link_to i(:pencil), edit_admin_m_odr_rep_path(m_odr_rep), :remote => true - = link_to i(:eye), admin_m_odr_rep_path(m_odr_rep), :remote => true + -tr = {} + -tr[:state] = capture do + %td=state_helper m_odr_rep.state + + -tr[:m_odr] = capture do + %td=m_odr_rep.m_odr.name if m_odr_rep.m_odr + + -tr[:cc_remise] = capture do + %td=number_to_currency m_odr_rep.remise + + -tr[:cc_rib_admin_ok] = capture do + %td= "oui" if m_odr_rep.rib_admin_ok + + -tr[:cc_file_admin_ok] = capture do + %td= "oui" if m_odr_rep.file_admin_ok + + -tr[:cc_admin_ok_to_send] = capture do + %td= "oui" if m_odr_rep.admin_ok_to_send + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, m_odr_rep], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_m_odr_rep_path(m_odr_rep), :remote => true + = link_to i(:eye), admin_m_odr_rep_path(m_odr_rep) + + + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => m_odr_rep} + + + \ No newline at end of file diff --git a/app/views/admin/m_odr_reps/index.html.haml b/app/views/admin/m_odr_reps/index.html.haml index 2790bd9..194565e 100644 --- a/app/views/admin/m_odr_reps/index.html.haml +++ b/app/views/admin/m_odr_reps/index.html.haml @@ -1,25 +1,32 @@ .qi_header .right= link_to 'Ajouter ', new_admin_m_odr_rep_path(), :class => "btn btn-primary", :remote => true %h1 - + ODR %span - + Liste des participations +-MOdrRep.all.each do |m_odr_rep| + -m_odr_rep.save -.qi_row - .qi_pannel.qi_plain.padding - %table.table +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + -params[:search] =params[:search] || {} + %table %tr - %th state - %th admin_id - %th admin_valid - %th token - %th m_odr_id - %th rgpd - %th.actions - + %td + Statut : + =select_tag "search[state]", options_for_select([["",""]]+MOdrRep.group(:state).order(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]) + + + %td + Opération : + =select_tag "search[m_odr_id]", options_for_select([["",""]]+MOdr.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:m_odr_id]) + + + %td=text_field_tag :name, params[:name],:class => "form-control", :placeholder => "Nom" - %tbody#m_odr_reps_rows - =render @m_odr_reps - - \ No newline at end of file + + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @m_odr_reps} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_reps} diff --git a/app/views/admin/m_odr_reps/show.html.haml b/app/views/admin/m_odr_reps/show.html.haml index 5effab7..da7cc05 100644 --- a/app/views/admin/m_odr_reps/show.html.haml +++ b/app/views/admin/m_odr_reps/show.html.haml @@ -3,8 +3,167 @@ %span - +-@m_odr_rep.save .qi_row .qi_pannel.qi_plain.padding - =debug @m_odr_rep \ No newline at end of file + + + + %table.table.table-striped.table-hover.table-bordered + %tr + %td{:style => "width:200px;"} Nom + %td + =@m_odr_rep.long_name + + %tr + %td Adresse + %td + =@m_odr_rep.particular_address_2 + + -if @m_odr_rep.particular_address_3.to_s != "" + %br + =@m_odr_rep.particular_address_3 + + %tr + %td Ville + %td + =@m_odr_rep.particular_cp + =@m_odr_rep.particular_city + ="-" + =@m_odr_rep.particular_country + + %tr + %td Tel + %td + =@m_odr_rep.particular_tel + + + %tr + %td Email + %td + =@m_odr_rep.particular_email + + + %hr + Achat + .row + .columns.span_4 + %table.table.table-striped.table-hover.table-bordered + %tr + %td{:style => "width:200px;"} Marque : + %td + =@m_odr_rep.product_brand + + %tr + %td Produit + %td + =@m_odr_rep.product_name + %tr + %td Quantité + %td + =@m_odr_rep.qte + + %table.table.table-striped.table-hover.table-bordered + %tr + %td{:style => "width:200px;"} Remise : + %td + =number_to_currency @m_odr_rep.remise + + + -@m_odr_rep.m_odr_files.order("id DESC").each do |file| + %table.table.table-striped.table-hover.table-bordered + %tr + %td{:style => "width:200px;"} Fichier + %td + =File.basename file.file.path + + %tr + %td Lien + %td + =link_to "Télécharger", download_admin_m_odr_file_path(file, :disposition => "attachment") + + + %tr + %td Validation + %td + -if file.admin_ok == true + =state_helper "Validé" + -elsif file.admin_ok == false + =state_helper "Refusé" + %br + =file.reject_reason + =simple_format file.reject_reason_description if file.reject_reason_description? + + =link_to "Modérer ce fichier", edit_admin_m_odr_file_path(file), :remote => true + + + RIBs : + -@m_odr_rep.m_odr_rep_ribs.order("id DESC").each do |m_odr_rep_rib| + %table.table.table-striped.table-hover.table-bordered + %tr + %td{:style => "width:200px;"} ID Rib + %td + =m_odr_rep_rib.id + + %tr + %td IBAN + %td + =m_odr_rep_rib.iban + + %tr + %td BIC + %td + =m_odr_rep_rib.bic + + + %tr + %td Validation + %td + -if m_odr_rep_rib.admin_ok == true + =state_helper "Validé" + -elsif m_odr_rep_rib.admin_ok == false + =state_helper "Refusé" + %br + =m_odr_rep_rib.reject_reason + =simple_format m_odr_rep_rib.reject_reason_description if m_odr_rep_rib.reject_reason_description? + + =link_to "Modérer ce RIB", edit_admin_m_odr_rep_rib_path(m_odr_rep_rib), :remote => true + + + + .columns.span_8{:style => "padding-left:20px;"} + -file = @m_odr_rep.m_odr_files.order("id DESC").first + -if file + =link_to "Télécharger", download_admin_m_odr_file_path(file, :disposition => "attachment") + %iframe{:src => file.file.url, :style => "width:100%;height:800px;border:1px solid gray;"} + + + + + .clear + %hr + Virements + -if @m_odr_rep.admin_ok_to_send and @m_odr_rep.m_odr_virements.where(:refused => false).count == 0 + =link_to "Générer le virement", generate_virement_admin_m_odr_rep_path(@m_odr_rep) + + + -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_virements = @m_odr_rep.m_odr_virements.page(page).per(per_page) + + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_virements} + + + %hr + Historique des mails envoyés + + -params[:search][:per_page] = params[:search][:per_page] || 50 + -per_page = params[:search][:per_page] + -page = (params[:page] and params[:page] != "") ? params[:page] : 1 + -@mail_hists = @m_odr_rep.mail_hists.page(page).per(per_page) + + =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @mail_hists} + + \ No newline at end of file diff --git a/app/views/admin/m_odr_virements/_form.html.haml b/app/views/admin/m_odr_virements/_form.html.haml new file mode 100644 index 0000000..158bcef --- /dev/null +++ b/app/views/admin/m_odr_virements/_form.html.haml @@ -0,0 +1,22 @@ +=semantic_form_for [:admin, @m_odr_virement], :remote => true do |f| + + .content + =f.inputs do + = f.input :m_odr, :label => "m_odr :" + = f.input :m_odr_rep, :label => "m_odr_rep :" + = f.input :m_odr_rep_rib, :label => "m_odr_rep_rib :" + = f.input :enabled, :label => "enabled :" + = f.input :sended, :label => "sended :" + = f.input :refused, :label => "refused :" + = f.input :reject_reason, :label => "reject_reason :" + = f.input :reject_reason_description, :label => "reject_reason_description :" + = f.input :cc_remise, :label => "cc_remise :" + = f.input :cc_iban, :label => "cc_iban :" + = f.input :cc_bic, :label => "cc_bic :" + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/m_odr_virements/_m_odr_virement.html.haml b/app/views/admin/m_odr_virements/_m_odr_virement.html.haml new file mode 100644 index 0000000..88783cc --- /dev/null +++ b/app/views/admin/m_odr_virements/_m_odr_virement.html.haml @@ -0,0 +1,67 @@ +%tr#m_odr_virement_row{:id => m_odr_virement.id} + -tr = {} + + -tr[:amount] = capture do + %td=number_to_currency m_odr_virement.amount + + + -tr[:enabled] = capture do + %td + -if m_odr_virement.enabled + Oui + -else + -if !@m_odr_rep + = link_to i(:check)+" valider maintenant", admin_valid_admin_m_odr_virement_path(m_odr_virement), :remote => true + + -tr[:refused] = capture do + %td + -if m_odr_virement.refused + Refusé + -else + -if @m_odr_remise + = link_to "Indiquer comme refusé par la banque", refuse_admin_m_odr_virement_path(m_odr_virement), :remote => true + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, m_odr_virement], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_m_odr_virement_path(m_odr_virement), :remote => true + = link_to i(:eye), admin_m_odr_virement_path(m_odr_virement), :remote => true + + + + + + + + + -if !@qi_table_orders + + =render :partial => "qi/qi_ordered_table_head", :locals => {:qi_ordered_table_name => m_odr_virement.class.to_s.tableize, :qi_ordered_table_model => m_odr_virement.class} + + + -@qi_table_orders[:m_odr_virements].each do |key,value| + + -if tr[:"#{key}"] + + =raw tr[:"#{key}"] + + -elsif (m_odr_virement.respond_to?(key)) + + %td + + =m_odr_virement.send(key.to_s) + + + + -else + + %td + + Err : + + =key + + + + + diff --git a/app/views/admin/m_odr_virements/admin_valid.js.erb b/app/views/admin/m_odr_virements/admin_valid.js.erb new file mode 100644 index 0000000..7c88bc1 --- /dev/null +++ b/app/views/admin/m_odr_virements/admin_valid.js.erb @@ -0,0 +1,2 @@ +$('#m_odr_virement_row_<%= @m_odr_virement.id %>').replaceWith("<%= escape_javascript(render(@m_odr_virement))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odr_virements/create.js.erb b/app/views/admin/m_odr_virements/create.js.erb new file mode 100644 index 0000000..427bf9c --- /dev/null +++ b/app/views/admin/m_odr_virements/create.js.erb @@ -0,0 +1,2 @@ +$('#m_odr_virements_rows').prepend("<%= escape_javascript(render(@m_odr_virement))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odr_virements/destroy.js.erb b/app/views/admin/m_odr_virements/destroy.js.erb new file mode 100644 index 0000000..bd23461 --- /dev/null +++ b/app/views/admin/m_odr_virements/destroy.js.erb @@ -0,0 +1 @@ +$('#m_odr_virement_<%= @m_odr_virement.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/m_odr_virements/edit.js.erb b/app/views/admin/m_odr_virements/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/m_odr_virements/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/m_odr_virements/index.html.haml b/app/views/admin/m_odr_virements/index.html.haml new file mode 100644 index 0000000..6a35772 --- /dev/null +++ b/app/views/admin/m_odr_virements/index.html.haml @@ -0,0 +1,33 @@ +.qi_header + .right= link_to 'Ajouter ', new_admin_m_odr_virement_path(), :class => "btn btn-primary", :remote => true + %h1 + Virements + %span + Demande de virement + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + -params[:search] =params[:search] || {} + %table + %tr + %td + Statut : + =select_tag "search[state]", options_for_select([["",""]]+MOdrRep.group(:state).order(:state).all.map{|a| [a.state, a.state]}, params[:search][:state]) + + + %td + Opération : + =select_tag "search[m_odr_id]", options_for_select([["",""]]+MOdr.order(:name).all.map{|a| [a.name, a.id]}, params[:search][:m_odr_id]) + + + %td=text_field_tag :name, params[:name],:class => "form-control", :placeholder => "Nom" + + + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @m_odr_virements} + + +=link_to "Générer les remises", generate_all_admin_m_odr_remises_path() + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_virements} diff --git a/app/views/admin/m_odr_virements/new.js.erb b/app/views/admin/m_odr_virements/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/m_odr_virements/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/m_odr_virements/refuse.js.erb b/app/views/admin/m_odr_virements/refuse.js.erb new file mode 100644 index 0000000..7c88bc1 --- /dev/null +++ b/app/views/admin/m_odr_virements/refuse.js.erb @@ -0,0 +1,2 @@ +$('#m_odr_virement_row_<%= @m_odr_virement.id %>').replaceWith("<%= escape_javascript(render(@m_odr_virement))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odr_virements/show.html.haml b/app/views/admin/m_odr_virements/show.html.haml new file mode 100644 index 0000000..755918d --- /dev/null +++ b/app/views/admin/m_odr_virements/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @m_odr_virement \ No newline at end of file diff --git a/app/views/admin/m_odr_virements/update.js.erb b/app/views/admin/m_odr_virements/update.js.erb new file mode 100644 index 0000000..7c88bc1 --- /dev/null +++ b/app/views/admin/m_odr_virements/update.js.erb @@ -0,0 +1,2 @@ +$('#m_odr_virement_row_<%= @m_odr_virement.id %>').replaceWith("<%= escape_javascript(render(@m_odr_virement))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odrs/_form.html.haml b/app/views/admin/m_odrs/_form.html.haml index 0462bc0..d60addf 100644 --- a/app/views/admin/m_odrs/_form.html.haml +++ b/app/views/admin/m_odrs/_form.html.haml @@ -57,8 +57,14 @@ =render :partial => "admin/shared/social_form", :locals => {:f => f} - - + .qi_row + .qi_pannel.qi_plain.padding + Infos pour les virements : + %hr + = f.input :iban, :label => "Iban :" + = f.input :bic, :label => "Bic :" + = f.input :bank_name, :label => "Nom du propriétaire du compte :" + = f.input :bank_subject, :label => "Libellé virement :" .qi_row .qi_pannel.qi_plain.padding Fichiers demandés : diff --git a/app/views/admin/m_odrs/index.html.haml b/app/views/admin/m_odrs/index.html.haml index 24b5dc6..571ff12 100644 --- a/app/views/admin/m_odrs/index.html.haml +++ b/app/views/admin/m_odrs/index.html.haml @@ -2,6 +2,8 @@ .right= link_to 'Ajouter ', new_admin_m_odr_path(), :class => "btn btn-primary", :remote => false %h1 ODR + %span + Liste des ODR diff --git a/app/views/admin/mail_hists/_form.html.haml b/app/views/admin/mail_hists/_form.html.haml new file mode 100644 index 0000000..8253451 --- /dev/null +++ b/app/views/admin/mail_hists/_form.html.haml @@ -0,0 +1,24 @@ +=semantic_form_for [:admin, @mail_hist], :remote => true do |f| + + .content + =f.inputs do + = f.input :from_email, :label => "from_email :" + = f.input :to_email, :label => "to_email :" + = f.input :subject, :label => "subject :" + = f.input :body, :label => "body :" + = f.input :mail_content, :label => "mail_content :" + = f.input :mail_type, :label => "mail_type :" + = f.input :element_type, :label => "element_type :" + = f.input :element_id, :label => "element_id :" + = f.input :m_odr_rep, :label => "m_odr_rep :" + = f.input :m_odr, :label => "m_odr :" + = f.input :mj_read, :label => "mj_read :" + = f.input :mj_token, :label => "mj_token :" + = f.input :nbr_send, :label => "nbr_send :" + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/admin/mail_hists/_mail_hist.html.haml b/app/views/admin/mail_hists/_mail_hist.html.haml new file mode 100644 index 0000000..b47ee1e --- /dev/null +++ b/app/views/admin/mail_hists/_mail_hist.html.haml @@ -0,0 +1,13 @@ +%tr#mail_hist_row{:id => mail_hist.id} + -tr = {} + + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, mail_hist], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_mail_hist_path(mail_hist), :remote => true + = link_to i(:eye), admin_mail_hist_path(mail_hist), :remote => true + + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => mail_hist} \ No newline at end of file diff --git a/app/views/admin/mail_hists/create.js.erb b/app/views/admin/mail_hists/create.js.erb new file mode 100644 index 0000000..f5b4343 --- /dev/null +++ b/app/views/admin/mail_hists/create.js.erb @@ -0,0 +1,2 @@ +$('#mail_hists_rows').prepend("<%= escape_javascript(render(@mail_hist))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/mail_hists/destroy.js.erb b/app/views/admin/mail_hists/destroy.js.erb new file mode 100644 index 0000000..812c44e --- /dev/null +++ b/app/views/admin/mail_hists/destroy.js.erb @@ -0,0 +1 @@ +$('#mail_hist_<%= @mail_hist.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/mail_hists/edit.js.erb b/app/views/admin/mail_hists/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/mail_hists/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/mail_hists/index.html.haml b/app/views/admin/mail_hists/index.html.haml new file mode 100644 index 0000000..1f544ee --- /dev/null +++ b/app/views/admin/mail_hists/index.html.haml @@ -0,0 +1,21 @@ +.qi_header + + %h1 + Mails + %span + Historique des mails envoyés + + + +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + -params[:search] =params[:search] || {} + %table + %tr + %td + + + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @mail_hists} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @mail_hists} diff --git a/app/views/admin/mail_hists/new.js.erb b/app/views/admin/mail_hists/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/mail_hists/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/mail_hists/show.html.haml b/app/views/admin/mail_hists/show.html.haml new file mode 100644 index 0000000..40789e4 --- /dev/null +++ b/app/views/admin/mail_hists/show.html.haml @@ -0,0 +1,10 @@ +.qi_header + %h1 + + %span + + + +.qi_row + .qi_pannel.qi_plain.padding + =debug @mail_hist \ No newline at end of file diff --git a/app/views/admin/mail_hists/update.js.erb b/app/views/admin/mail_hists/update.js.erb new file mode 100644 index 0000000..b587332 --- /dev/null +++ b/app/views/admin/mail_hists/update.js.erb @@ -0,0 +1,2 @@ +$('#mail_hist_row_<%= @mail_hist.id %>').replaceWith("<%= escape_javascript(render(@mail_hist))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/p_customers/_p_customer.html.haml b/app/views/admin/p_customers/_p_customer.html.haml index 2e5f8b9..61c7a29 100644 --- a/app/views/admin/p_customers/_p_customer.html.haml +++ b/app/views/admin/p_customers/_p_customer.html.haml @@ -32,6 +32,11 @@ ="%" + -if !@qi_table_orders + =render :partial => "qi/qi_ordered_table_head", :locals => {:qi_ordered_table_name => p_product.class.to_s.tableize, :qi_ordered_table_model => p_product.class} + + + -@qi_table_orders[:p_customers].each do |key,value| diff --git a/app/views/general_mails/general2.html.haml b/app/views/general_mails/general2.html.haml new file mode 100644 index 0000000..846057c --- /dev/null +++ b/app/views/general_mails/general2.html.haml @@ -0,0 +1 @@ +=simple_format @body \ No newline at end of file diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 50ace6d..fd3e0ba 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -38,7 +38,7 @@ Clients .element - =link_to admin_m_odrs_path do + =link_to admin_m_odr_reps_path do .cat#big_cat_stocks =ic :"cubes" Opérations ODR @@ -57,12 +57,11 @@ Documents - -if current_admin.has_permission?("payments") - .element - =link_to admin_p_payments_path do - .cat#big_cat_payments - =ic :"eur" - Paiements + .element + =link_to admin_m_odr_virements_path do + .cat#big_cat_payments + =ic :"eur" + Virements -if false .element diff --git a/app/views/public/m_odrs/show.html.haml b/app/views/public/m_odrs/show.html.haml index 756ceca..fb7009c 100644 --- a/app/views/public/m_odrs/show.html.haml +++ b/app/views/public/m_odrs/show.html.haml @@ -118,7 +118,7 @@ %h3 Votre achat =f.inputs do - =f.input :m_odr_product_id, :label => "Pneu :", :as => :select, :collection => f.object.m_odr.m_odr_products.order("m_odr_brand_id ASC, m_odr_products.name"), :member_label => :member_label, :include_blank => true + =f.input :m_odr_product_id, :label => "Pneu :", :as => :select, :collection => f.object.m_odr.m_odr_products.where(:m_odr_brand_id => f.object.m_odr.m_odr_brands.where("(start_at is null or start_at <= ?) and (public_end is null or public_end >= ?)", Date.today,Date.today) ).order("m_odr_brand_id ASC, m_odr_products.name"), :member_label => :member_label, :include_blank => true =f.inputs do =f.input :qte, :label => "Nombre de pneus :", :as => :select, :collection => [1,2], :include_blank => true diff --git a/app/views/qi/_qi_ordered_table.html.haml b/app/views/qi/_qi_ordered_table.html.haml index 2156ded..6105a21 100644 --- a/app/views/qi/_qi_ordered_table.html.haml +++ b/app/views/qi/_qi_ordered_table.html.haml @@ -1,5 +1,12 @@ -qi_ordered_table_name = qi_ordered_table_collection.klass.to_s.tableize +-qi_ordered_table_model = qi_ordered_table_collection.klass + + + +=render :partial => "qi/qi_ordered_table_head", :locals => {:qi_ordered_table_name => qi_ordered_table_name, :qi_ordered_table_model => qi_ordered_table_model} + + -@qi_table_orders = @qi_table_orders || {} -if current_admin @@ -23,18 +30,6 @@ --if qi_ordered_table_personalised.to_s != "" - -@qi_table_orders[qi_ordered_table_name.to_sym] = {} - - -qi_ordered_table_personalised.split(",").each do |k| - -if qi_ordered_table_collection.klass.qi_table_order[k.to_sym] - - -@qi_table_orders[qi_ordered_table_name.to_sym][k.to_sym] = qi_ordered_table_collection.klass.qi_table_order[k.to_sym] - --else - -@qi_table_orders[qi_ordered_table_name.to_sym] = qi_ordered_table_collection.klass.qi_table_order - - %span.qi_ordered_table_column{:onclick => "$(this).next('.qi_ordered_table_sort_select_wrapper').toggle();"} @@ -68,8 +63,9 @@ -else =value %hr{:style => "margin:3px 0;"} - Colonnes fixes : - =select_tag "qi_sort_string[nbr_colonnes]", options_for_select([0,1,2,3], qi_ordered_table_nbr_col) + -if false + Colonnes fixes : + =select_tag "qi_sort_string[nbr_colonnes]", options_for_select([0,1,2,3], qi_ordered_table_nbr_col) =link_to "Mettre à jour", "#", :class => "btn btn-primary update_table_order_link" @@ -164,7 +160,8 @@ =#sort_link "code", "Code" - %th + -if false + %th %tbody{:id => "#{qi_ordered_table_name}_rows"} diff --git a/app/views/qi/_qi_ordered_table_head.html.haml b/app/views/qi/_qi_ordered_table_head.html.haml new file mode 100644 index 0000000..80da8d8 --- /dev/null +++ b/app/views/qi/_qi_ordered_table_head.html.haml @@ -0,0 +1,35 @@ + + +-@qi_table_orders = @qi_table_orders || {} + +-if current_admin + + -if ap = current_admin.admin_preferences.where(:key => "sort_table_"+qi_ordered_table_name).first + -qi_ordered_table_personalised = ap.value + + + -if ap = current_admin.admin_preferences.where(:key => "sort_table_"+qi_ordered_table_name+"_nbr_col").first + -qi_ordered_table_nbr_col = ap.value + -else + -qi_ordered_table_nbr_col = 1 + + + +-else + -qi_ordered_table_personalised = session[:qi_sort_string][qi_ordered_table_name] + + -qi_ordered_table_nbr_col = session[:qi_sort_string][qi_ordered_table_name+"_nbr_col"] || 1 + + + + +-if qi_ordered_table_personalised.to_s != "" + -@qi_table_orders[qi_ordered_table_name.to_sym] = {} + + -qi_ordered_table_personalised.split(",").each do |k| + -if qi_ordered_table_model.qi_table_order[k.to_sym] + + -@qi_table_orders[qi_ordered_table_name.to_sym][k.to_sym] = qi_ordered_table_model.qi_table_order[k.to_sym] + +-else + -@qi_table_orders[qi_ordered_table_name.to_sym] = qi_ordered_table_model.qi_table_order diff --git a/app/views/qi/_qi_ordered_table_object.html.haml b/app/views/qi/_qi_ordered_table_object.html.haml new file mode 100644 index 0000000..71ec7e4 --- /dev/null +++ b/app/views/qi/_qi_ordered_table_object.html.haml @@ -0,0 +1,22 @@ +-qi_ordered_table_model = object.class +-qi_ordered_table_name = qi_ordered_table_model.to_s.tableize + +-if !@qi_table_orders + =render :partial => "qi/qi_ordered_table_head", :locals => {:qi_ordered_table_name => qi_ordered_table_name, :qi_ordered_table_model => qi_ordered_table_model} + + + + + +-@qi_table_orders[qi_ordered_table_name.to_sym].each do |key,value| + -if tr[:"#{key}"] + =raw tr[:"#{key}"] + -elsif object.respond_to?(key.to_s) + %td + =#eval("#{qi_ordered_table_name.singularize}.send('#{key}')") + =object.send(key.to_s) + + -else + %td + Err : + =key diff --git a/app/views/qi/_qi_ordered_table_search_footer.html.haml b/app/views/qi/_qi_ordered_table_search_footer.html.haml new file mode 100644 index 0000000..b9fe2dd --- /dev/null +++ b/app/views/qi/_qi_ordered_table_search_footer.html.haml @@ -0,0 +1,10 @@ +=link_to ic(:search)+" Rechercher", "#", :class => "btn btn-default btn-qi-search", :onclick => "$(this).closest('form').submit();$(this).html('...');return false;" + + +.results_count + ="(#{collection_object.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 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 32f1d32..44689a7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,40 @@ Rails.application.routes.draw do + namespace :admin do + resources :mail_hists do + member do + + end + collection do + + end + end + end + + namespace :admin do + resources :m_odr_remises do + member do + get :confirm + end + collection do + get :generate_all + + end + end + end + + namespace :admin do + resources :m_odr_virements do + member do + get :admin_valid + get :refuse + end + collection do + + end + end + end + namespace :admin do resources :m_odr_trackers do member do @@ -80,7 +115,7 @@ Rails.application.routes.draw do namespace :admin do resources :m_odr_files do member do - + get :download end collection do @@ -91,7 +126,7 @@ Rails.application.routes.draw do namespace :admin do resources :m_odr_reps do member do - + get :generate_virement end collection do @@ -756,6 +791,9 @@ Rails.application.routes.draw do resources :audio_files resources :video_files resources :download_data_files + + resources :download_odr_files + get 'fr/read/:token' => "public/data_files#read", :as => :read_data_file diff --git a/db/migrate/20200229130133_add_caches_to_m_odr_reps.rb b/db/migrate/20200229130133_add_caches_to_m_odr_reps.rb new file mode 100644 index 0000000..c9447a5 --- /dev/null +++ b/db/migrate/20200229130133_add_caches_to_m_odr_reps.rb @@ -0,0 +1,62 @@ +class AddCachesToMOdrReps < ActiveRecord::Migration[6.0] + def change + + add_column :m_odr_reps, :archived, :boolean, :default => true + + add_column :m_odr_reps, :particular_id, :integer + + add_column :m_odr_reps, :cc_particular_civilite, :string + add_column :m_odr_reps, :ac_particular_civilite, :string + + add_column :m_odr_reps, :cc_particular_name, :string + add_column :m_odr_reps, :ac_particular_name, :string + + add_column :m_odr_reps, :cc_particular_firstname, :string + add_column :m_odr_reps, :ac_particular_firstname, :string + + add_column :m_odr_reps, :cc_particular_address_2, :string + add_column :m_odr_reps, :ac_particular_address_2, :string + + add_column :m_odr_reps, :cc_particular_address_3, :string + add_column :m_odr_reps, :ac_particular_address_3, :string + + add_column :m_odr_reps, :cc_particular_cp, :string + add_column :m_odr_reps, :ac_particular_cp, :string + + add_column :m_odr_reps, :cc_particular_city, :string + add_column :m_odr_reps, :ac_particular_city, :string + + add_column :m_odr_reps, :cc_particular_country, :string + add_column :m_odr_reps, :ac_particular_country, :string + + add_column :m_odr_reps, :cc_particular_email, :string + add_column :m_odr_reps, :ac_particular_email, :string + + add_column :m_odr_reps, :cc_particular_tel, :string + add_column :m_odr_reps, :ac_particular_tel, :string + + add_column :m_odr_reps, :cc_product_name, :string + add_column :m_odr_reps, :ac_product_name, :string + + add_column :m_odr_reps, :cc_product_brand, :string + add_column :m_odr_reps, :ac_product_brand, :string + + add_column :m_odr_reps, :m_odr_brand_id, :integer + + + add_column :m_odr_reps, :cc_tracker_name, :string + add_column :m_odr_reps, :ac_tracker_name, :string + + + add_column :m_odr_reps, :cc_place_name, :string + add_column :m_odr_reps, :ac_place_name, :string + + + + + + + + + end +end diff --git a/db/migrate/20200229182042_add_enabled_to_m_odr_files.rb b/db/migrate/20200229182042_add_enabled_to_m_odr_files.rb new file mode 100644 index 0000000..42e081c --- /dev/null +++ b/db/migrate/20200229182042_add_enabled_to_m_odr_files.rb @@ -0,0 +1,13 @@ +class AddEnabledToMOdrFiles < ActiveRecord::Migration[6.0] + def change + add_column :m_odr_files, :admin_id, :integer + add_column :m_odr_files, :admin_validator_id, :integer + add_column :m_odr_files, :admin_ok, :boolean + add_column :m_odr_files, :reject_reason, :string + add_column :m_odr_files, :reject_reason_description, :text + + add_column :m_odr_reps, :file_ok_id, :integer + + + end +end diff --git a/db/migrate/20200229185402_add_enabled_to_m_odr_rep_rib.rb b/db/migrate/20200229185402_add_enabled_to_m_odr_rep_rib.rb new file mode 100644 index 0000000..80261c8 --- /dev/null +++ b/db/migrate/20200229185402_add_enabled_to_m_odr_rep_rib.rb @@ -0,0 +1,18 @@ +class AddEnabledToMOdrRepRib < ActiveRecord::Migration[6.0] + def change + add_column :m_odr_rep_ribs, :admin_validator_id, :integer + add_column :m_odr_rep_ribs, :admin_ok, :boolean + add_column :m_odr_rep_ribs, :reject_reason, :string + add_column :m_odr_rep_ribs, :reject_reason_description, :text + + add_column :m_odr_reps, :rib_ok_id, :integer + + + add_column :m_odr_reps, :cc_rib_admin_ok, :boolean, :default => false + add_column :m_odr_reps, :ac_rib_admin_ok, :boolean, :default => false + add_column :m_odr_reps, :cc_file_admin_ok, :boolean, :default => false + add_column :m_odr_reps, :ac_file_admin_ok, :boolean, :default => false + + + end +end diff --git a/db/migrate/20200229192022_add_admin_validations_to_m_odr_reps.rb b/db/migrate/20200229192022_add_admin_validations_to_m_odr_reps.rb new file mode 100644 index 0000000..c6de1f7 --- /dev/null +++ b/db/migrate/20200229192022_add_admin_validations_to_m_odr_reps.rb @@ -0,0 +1,6 @@ +class AddAdminValidationsToMOdrReps < ActiveRecord::Migration[6.0] + def change + add_column :m_odr_reps, :cc_admin_ok_to_send, :boolean, :default => false + add_column :m_odr_reps, :ac_admin_ok_to_send, :boolean, :default => false + end +end diff --git a/db/migrate/20200229193617_create_m_odr_virements.rb b/db/migrate/20200229193617_create_m_odr_virements.rb new file mode 100644 index 0000000..4bf3655 --- /dev/null +++ b/db/migrate/20200229193617_create_m_odr_virements.rb @@ -0,0 +1,48 @@ +class CreateMOdrVirements < ActiveRecord::Migration[6.0] + def change + create_table :m_odr_virements do |t| + t.references :m_odr, foreign_key: true + t.references :m_odr_rep, foreign_key: true + t.references :m_odr_rep_rib, foreign_key: true + t.boolean :enabled, :default => false + t.boolean :sended, :default => false + t.boolean :refused, :default => false + t.string :reject_reason + t.text :reject_reason_description + t.decimal :cc_remise, :precision => 14, :scale => 2 + t.decimal :ac_remise, :precision => 14, :scale => 2 + + t.decimal :amount, :precision => 14, :scale => 2 + + t.string :cc_iban_to + t.string :ac_iban_to + t.string :cc_bic_to + t.string :ac_bic_to + + t.integer :m_odr_remise_id + t.integer :m_odr_bank_account_id + + t.string :cc_iban_from + t.string :ac_iban_from + t.string :cc_bic_from + t.string :ac_bic_from + + t.string :cc_bank_name + t.string :ac_bank_name + + t.string :cc_bank_subject + t.string :ac_bank_subject + + t.string :cc_libelle + t.string :ac_libelle + + t.datetime :send_at + + t.datetime :confirmed_at + + t.string :token + + t.timestamps + end + end +end diff --git a/db/migrate/20200229222622_add_bank_infos_to_m_odrs.rb b/db/migrate/20200229222622_add_bank_infos_to_m_odrs.rb new file mode 100644 index 0000000..066822f --- /dev/null +++ b/db/migrate/20200229222622_add_bank_infos_to_m_odrs.rb @@ -0,0 +1,9 @@ +class AddBankInfosToMOdrs < ActiveRecord::Migration[6.0] + def change + add_column :m_odrs, :bic, :string + add_column :m_odrs, :iban, :string + add_column :m_odrs, :bank_name, :string + add_column :m_odrs, :bank_ics, :string + add_column :m_odrs, :bank_subject, :string + end +end diff --git a/db/migrate/20200229223930_create_m_odr_remises.rb b/db/migrate/20200229223930_create_m_odr_remises.rb new file mode 100644 index 0000000..5cba972 --- /dev/null +++ b/db/migrate/20200229223930_create_m_odr_remises.rb @@ -0,0 +1,29 @@ +class CreateMOdrRemises < ActiveRecord::Migration[6.0] + def change + create_table :m_odr_remises do |t| + t.text :notes + t.references :m_odr, foreign_key: true + t.datetime :download_at + t.datetime :confirmed_at + t.string :state, :default => "Généré" + t.boolean :confirmed, :default => false + t.integer :admin_id + + t.integer :cc_nbr_virements + t.integer :ac_nbr_virements + + t.string :cc_iban_from + t.string :ac_iban_from + t.string :cc_bic_from + t.string :ac_bic_from + + t.string :cc_bank_name + t.string :ac_bank_name + + t.string :cc_bank_subject + t.string :ac_bank_subject + + t.timestamps + end + end +end diff --git a/db/migrate/20200301125633_create_mail_hists.rb b/db/migrate/20200301125633_create_mail_hists.rb new file mode 100644 index 0000000..01ce38c --- /dev/null +++ b/db/migrate/20200301125633_create_mail_hists.rb @@ -0,0 +1,33 @@ +class CreateMailHists < ActiveRecord::Migration[6.0] + def change + create_table :mail_hists do |t| + + t.references :lang_site + t.string :from_email + + t.string :to_email + + t.string :subject + + t.text :body + + t.string :subject_send + + t.text :body_send + + + t.references :mail_content, foreign_key: true + t.references :mail_type, foreign_key: true + t.string :element_type + t.integer :element_id + t.references :m_odr_rep, foreign_key: true + t.references :m_odr, foreign_key: true + t.boolean :mj_read + t.string :mj_token + + t.integer :nbr_send + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 08d4b2c..39f2e02 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_02_27_162438) do +ActiveRecord::Schema.define(version: 2020_03_01_125633) do create_table "accounting_zones", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" @@ -508,7 +508,7 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.index ["cible_id"], name: "index_link_contents_on_cible_id" end - create_table "m_odr_brands", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "m_odr_brands", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.string "name" t.string "ref" t.integer "image_file_id" @@ -521,7 +521,7 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.index ["m_odr_id"], name: "index_m_odr_brands_on_m_odr_id" end - create_table "m_odr_file_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "m_odr_file_types", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.string "name" t.boolean "need_file" t.text "description" @@ -531,7 +531,7 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.index ["m_odr_id"], name: "index_m_odr_file_types_on_m_odr_id" end - create_table "m_odr_files", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "m_odr_files", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.string "file" t.bigint "m_odr_rep_id" t.datetime "action_date" @@ -543,11 +543,16 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.string "token" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.integer "admin_id" + t.integer "admin_validator_id" + t.boolean "admin_ok" + t.string "reject_reason" + t.text "reject_reason_description" t.index ["m_odr_file_type_id"], name: "index_m_odr_files_on_m_odr_file_type_id" t.index ["m_odr_rep_id"], name: "index_m_odr_files_on_m_odr_rep_id" end - create_table "m_odr_places", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "m_odr_places", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.string "name" t.string "enseigne" t.string "city" @@ -563,7 +568,7 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.index ["m_odr_id"], name: "index_m_odr_places_on_m_odr_id" end - create_table "m_odr_product_remises", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "m_odr_product_remises", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.bigint "m_odr_product_id" t.integer "qte" t.decimal "amount", precision: 14, scale: 2 @@ -572,7 +577,7 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.index ["m_odr_product_id"], name: "index_m_odr_product_remises_on_m_odr_product_id" end - create_table "m_odr_products", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "m_odr_products", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.string "name" t.bigint "m_odr_id" t.string "ref" @@ -584,7 +589,28 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.index ["m_odr_id"], name: "index_m_odr_products_on_m_odr_id" end - create_table "m_odr_rep_ribs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "m_odr_remises", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.text "notes" + t.bigint "m_odr_id" + t.datetime "download_at" + t.datetime "confirmed_at" + t.string "state", default: "Généré" + t.boolean "confirmed", default: false + t.integer "admin_id" + t.string "cc_iban_from" + t.string "ac_iban_from" + t.string "cc_bic_from" + t.string "ac_bic_from" + t.string "cc_bank_name" + t.string "ac_bank_name" + t.string "cc_bank_subject" + t.string "ac_bank_subject" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["m_odr_id"], name: "index_m_odr_remises_on_m_odr_id" + end + + create_table "m_odr_rep_ribs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.string "iban" t.string "bic" t.string "name" @@ -598,10 +624,14 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.text "notes" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.integer "admin_validator_id" + t.boolean "admin_ok" + t.string "reject_reason" + t.text "reject_reason_description" t.index ["admin_id"], name: "index_m_odr_rep_ribs_on_admin_id" end - create_table "m_odr_reps", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "m_odr_reps", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.string "state" t.integer "admin_id" t.datetime "admin_valid" @@ -616,13 +646,52 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.bigint "m_odr_tracker_id" + t.boolean "archived", default: true + t.integer "particular_id" + t.string "cc_particular_civilite" + t.string "ac_particular_civilite" + t.string "cc_particular_name" + t.string "ac_particular_name" + t.string "cc_particular_firstname" + t.string "ac_particular_firstname" + t.string "cc_particular_address_2" + t.string "ac_particular_address_2" + t.string "cc_particular_address_3" + t.string "ac_particular_address_3" + t.string "cc_particular_cp" + t.string "ac_particular_cp" + t.string "cc_particular_city" + t.string "ac_particular_city" + t.string "cc_particular_country" + t.string "ac_particular_country" + t.string "cc_particular_email" + t.string "ac_particular_email" + t.string "cc_particular_tel" + t.string "ac_particular_tel" + t.string "cc_product_name" + t.string "ac_product_name" + t.string "cc_product_brand" + t.string "ac_product_brand" + t.integer "m_odr_brand_id" + t.string "cc_tracker_name" + t.string "ac_tracker_name" + t.string "cc_place_name" + t.string "ac_place_name" + t.integer "file_ok_id" + t.integer "rib_ok_id" + t.boolean "cc_rib_admin_ok", default: false + t.boolean "ac_rib_admin_ok", default: false + t.boolean "cc_file_admin_ok", default: false + t.boolean "ac_file_admin_ok", default: false + t.boolean "cc_admin_ok_to_send", default: false + t.boolean "ac_admin_ok_to_send", default: false t.index ["m_odr_id"], name: "index_m_odr_reps_on_m_odr_id" t.index ["m_odr_place_id"], name: "index_m_odr_reps_on_m_odr_place_id" t.index ["m_odr_product_id"], name: "index_m_odr_reps_on_m_odr_product_id" t.index ["m_odr_tracker_id"], name: "index_m_odr_reps_on_m_odr_tracker_id" end - create_table "m_odr_trackers", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + create_table "m_odr_trackers", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.string "name" t.string "token" t.bigint "m_odr_id" @@ -631,6 +700,44 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.index ["m_odr_id"], name: "index_m_odr_trackers_on_m_odr_id" end + create_table "m_odr_virements", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.bigint "m_odr_id" + t.bigint "m_odr_rep_id" + t.bigint "m_odr_rep_rib_id" + t.boolean "enabled", default: false + t.boolean "sended", default: false + t.boolean "refused", default: false + t.string "reject_reason" + t.text "reject_reason_description" + t.decimal "cc_remise", precision: 14, scale: 2 + t.decimal "ac_remise", precision: 14, scale: 2 + t.decimal "amount", precision: 14, scale: 2 + t.string "cc_iban_to" + t.string "ac_iban_to" + t.string "cc_bic_to" + t.string "ac_bic_to" + t.integer "m_odr_remise_id" + t.integer "m_odr_bank_account_id" + t.string "cc_iban_from" + t.string "ac_iban_from" + t.string "cc_bic_from" + t.string "ac_bic_from" + t.string "cc_bank_name" + t.string "ac_bank_name" + t.string "cc_bank_subject" + t.string "ac_bank_subject" + t.string "cc_libelle" + t.string "ac_libelle" + t.datetime "send_at" + t.datetime "confirmed_at" + t.string "token" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["m_odr_id"], name: "index_m_odr_virements_on_m_odr_id" + t.index ["m_odr_rep_id"], name: "index_m_odr_virements_on_m_odr_rep_id" + t.index ["m_odr_rep_rib_id"], name: "index_m_odr_virements_on_m_odr_rep_rib_id" + end + create_table "m_odrs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "name" t.string "slug" @@ -670,6 +777,11 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.string "thank_title" t.text "thank_text" t.string "email_from" + t.string "bic" + t.string "iban" + t.string "bank_name" + t.string "bank_ics" + t.string "bank_subject" t.index ["p_customer_id"], name: "index_m_odrs_on_p_customer_id" end @@ -689,6 +801,32 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do t.index ["mail_type_id"], name: "index_mail_contents_on_mail_type_id" end + create_table "mail_hists", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| + t.bigint "lang_site_id" + t.string "from_email" + t.string "to_email" + t.string "subject" + t.text "body" + t.string "subject_send" + t.text "body_send" + t.bigint "mail_content_id" + t.bigint "mail_type_id" + t.string "element_type" + t.integer "element_id" + t.bigint "m_odr_rep_id" + t.bigint "m_odr_id" + t.boolean "mj_read" + t.string "mj_token" + t.integer "nbr_send" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["lang_site_id"], name: "index_mail_hists_on_lang_site_id" + t.index ["m_odr_id"], name: "index_mail_hists_on_m_odr_id" + t.index ["m_odr_rep_id"], name: "index_mail_hists_on_m_odr_rep_id" + t.index ["mail_content_id"], name: "index_mail_hists_on_mail_content_id" + t.index ["mail_type_id"], name: "index_mail_hists_on_mail_type_id" + end + create_table "mail_profiles", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t| t.string "civilite" t.string "firstname" @@ -2334,10 +2472,18 @@ ActiveRecord::Schema.define(version: 2020_02_27_162438) do add_foreign_key "m_odr_files", "m_odr_reps" add_foreign_key "m_odr_places", "m_odrs" add_foreign_key "m_odr_product_remises", "m_odr_products" + add_foreign_key "m_odr_remises", "m_odrs" add_foreign_key "m_odr_rep_ribs", "admins" add_foreign_key "m_odr_reps", "m_odr_trackers" add_foreign_key "m_odr_trackers", "m_odrs" + add_foreign_key "m_odr_virements", "m_odr_rep_ribs" + add_foreign_key "m_odr_virements", "m_odr_reps" + add_foreign_key "m_odr_virements", "m_odrs" add_foreign_key "m_odrs", "p_customers" + add_foreign_key "mail_hists", "m_odr_reps" + add_foreign_key "mail_hists", "m_odrs" + add_foreign_key "mail_hists", "mail_contents" + add_foreign_key "mail_hists", "mail_types" add_foreign_key "mail_types", "m_odrs" add_foreign_key "p_contact_contact_types", "p_contact_types" add_foreign_key "p_contact_contact_types", "p_contacts" diff --git a/lib/generators/rails/qis/templates/_class.html.haml b/lib/generators/rails/qis/templates/_class.html.haml index 71afcce..124caee 100644 --- a/lib/generators/rails/qis/templates/_class.html.haml +++ b/lib/generators/rails/qis/templates/_class.html.haml @@ -1,10 +1,13 @@ %tr#<%= singular_name %>_row{:id => <%= singular_name %>.id} - <% attributes_names.each do |attribute| -%> -%td= <%= singular_name %>.<%= attribute %> - <% end -%> + -tr = {} - %td.actions - = link_to i(:"trash-o"), [:admin, <%= singular_name %>], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true - = link_to i(:pencil), edit_admin_<%= singular_name %>_path(<%= singular_name %>), :remote => true - = link_to i(:eye), admin_<%= singular_name %>_path(<%= singular_name %>), :remote => true + -tr[:actions] = capture do + %td.actions + = link_to i(:"trash-o"), [:admin, <%= singular_name %>], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + = link_to i(:pencil), edit_admin_<%= singular_name %>_path(<%= singular_name %>), :remote => true + = link_to i(:eye), admin_<%= singular_name %>_path(<%= singular_name %>), :remote => true + + + + =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => <%= singular_name %>} \ No newline at end of file diff --git a/lib/generators/rails/qis/templates/controller.rb b/lib/generators/rails/qis/templates/controller.rb index f95456a..c7148e7 100644 --- a/lib/generators/rails/qis/templates/controller.rb +++ b/lib/generators/rails/qis/templates/controller.rb @@ -11,7 +11,16 @@ class Admin::<%= controller_class_name %>Controller < ApplicationController end def index - @<%= plural_name %> = <%= class_name %>.order(:name).all + @<%= plural_name %> = <%= class_name %>.all + + @<%= plural_name %> = sort_by_sorting(@<%= plural_name %>, "created_at DESC") + + + params[:search][:per_page] = params[:search][:per_page] || 50 + per_page = params[:search][:per_page] + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @<%= plural_name %> = @<%= plural_name %>.page(page).per(per_page) + end diff --git a/lib/generators/rails/qis/templates/index.html.haml b/lib/generators/rails/qis/templates/index.html.haml index 4ed7f2a..44cc468 100644 --- a/lib/generators/rails/qis/templates/index.html.haml +++ b/lib/generators/rails/qis/templates/index.html.haml @@ -6,17 +6,15 @@ -.qi_row - .qi_pannel.qi_plain.padding - %table.table +.qi_search_row + =form_tag "", :method => "get", :onsubmit => "" do + -params[:search] =params[:search] || {} + %table %tr - <% attributes_names.each do |attribute| -%> -%th <%= attribute %> - <% end -%> -%th.actions - - - %tbody#<%= plural_name %>_rows - =render @<%= plural_name %> - - \ No newline at end of file + %td + + + =render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @<%= plural_name %>} + + +=render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @<%= plural_name %>} diff --git a/test/fixtures/m_odr_remises.yml b/test/fixtures/m_odr_remises.yml new file mode 100644 index 0000000..56cc7cd --- /dev/null +++ b/test/fixtures/m_odr_remises.yml @@ -0,0 +1,19 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + notes: MyText + m_odr: one + download_at: 2020-02-29 23:39:30 + confirmed_at: 2020-02-29 23:39:30 + state: MyString + confirmed: false + admin_id: 1 + +two: + notes: MyText + m_odr: two + download_at: 2020-02-29 23:39:30 + confirmed_at: 2020-02-29 23:39:30 + state: MyString + confirmed: false + admin_id: 1 diff --git a/test/fixtures/m_odr_virements.yml b/test/fixtures/m_odr_virements.yml new file mode 100644 index 0000000..cd15c28 --- /dev/null +++ b/test/fixtures/m_odr_virements.yml @@ -0,0 +1,27 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + m_odr: one + m_odr_rep: one + m_odr_rep_rib: one + enabled: false + sended: false + refused: false + reject_reason: MyString + reject_reason_description: MyText + cc_remise: 9.99 + cc_iban: MyString + cc_bic: MyString + +two: + m_odr: two + m_odr_rep: two + m_odr_rep_rib: two + enabled: false + sended: false + refused: false + reject_reason: MyString + reject_reason_description: MyText + cc_remise: 9.99 + cc_iban: MyString + cc_bic: MyString diff --git a/test/fixtures/mail_hists.yml b/test/fixtures/mail_hists.yml new file mode 100644 index 0000000..48d8612 --- /dev/null +++ b/test/fixtures/mail_hists.yml @@ -0,0 +1,31 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + from_email: MyString + to_email: MyString + subject: MyString + body: MyText + mail_content: one + mail_type: one + element_type: MyString + element_id: 1 + m_odr_rep: one + m_odr: one + mj_read: false + mj_token: MyString + nbr_send: 1 + +two: + from_email: MyString + to_email: MyString + subject: MyString + body: MyText + mail_content: two + mail_type: two + element_type: MyString + element_id: 1 + m_odr_rep: two + m_odr: two + mj_read: false + mj_token: MyString + nbr_send: 1 diff --git a/test/models/m_odr_remise_test.rb b/test/models/m_odr_remise_test.rb new file mode 100644 index 0000000..fb6826a --- /dev/null +++ b/test/models/m_odr_remise_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MOdrRemiseTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/m_odr_virement_test.rb b/test/models/m_odr_virement_test.rb new file mode 100644 index 0000000..7560bcc --- /dev/null +++ b/test/models/m_odr_virement_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MOdrVirementTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/mail_hist_test.rb b/test/models/mail_hist_test.rb new file mode 100644 index 0000000..b394150 --- /dev/null +++ b/test/models/mail_hist_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MailHistTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end