From 8ab6a385074992d0a7e8e4ebf2f3609ded3a73ac Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Wed, 1 Apr 2020 23:52:28 +0200 Subject: [PATCH] suite --- .../admin/m_odr_files_controller.rb | 11 +- .../admin/m_odr_remises_controller.rb | 3 +- .../admin/m_odr_rep_ribs_controller.rb | 2 +- .../admin/m_odr_reps_controller.rb | 6 +- app/controllers/application_controller.rb | 4 + app/models/m_odr_file.rb | 16 ++ app/views/admin/m_odr_files/_image.html.haml | 2 + app/views/admin/m_odr_files/rotate.js.erb | 1 + app/views/admin/m_odr_files/update.js.erb | 3 + .../m_odr_remises/_m_odr_remise.html.haml | 6 +- app/views/admin/m_odr_remises/show.html.haml | 28 +-- app/views/admin/m_odr_rep_ribs/update.js.erb | 4 + app/views/admin/m_odr_reps/_head.html.haml | 34 ++++ .../admin/m_odr_reps/_left_column.html.haml | 141 +++++++++++++++ app/views/admin/m_odr_reps/_state.html.haml | 1 + app/views/admin/m_odr_reps/index.html.haml | 4 +- app/views/admin/m_odr_reps/show.html.haml | 160 +++--------------- app/views/admin/m_odr_reps/update.js.erb | 5 + .../m_odr_virements/_m_odr_virement.html.haml | 21 ++- .../admin/m_odr_virements/destroy.js.erb | 2 +- .../admin/m_odr_virements/index.html.haml | 2 +- app/views/admin/m_odrs/_m_odr.html.haml | 10 +- app/views/admin/m_odrs/index.html.haml | 5 +- app/views/admin/m_odrs/show.html.haml | 53 +++++- app/views/layouts/admin.html.haml | 7 + config/routes.rb | 1 + 26 files changed, 351 insertions(+), 181 deletions(-) create mode 100644 app/views/admin/m_odr_files/_image.html.haml create mode 100644 app/views/admin/m_odr_files/rotate.js.erb create mode 100644 app/views/admin/m_odr_reps/_head.html.haml create mode 100644 app/views/admin/m_odr_reps/_left_column.html.haml create mode 100644 app/views/admin/m_odr_reps/_state.html.haml diff --git a/app/controllers/admin/m_odr_files_controller.rb b/app/controllers/admin/m_odr_files_controller.rb index f5651ab..27305a6 100644 --- a/app/controllers/admin/m_odr_files_controller.rb +++ b/app/controllers/admin/m_odr_files_controller.rb @@ -68,7 +68,7 @@ class Admin::MOdrFilesController < ApplicationController def update @m_odr_file = MOdrFile.find(params[:id]) - + @m_odr_rep = @m_odr_file.m_odr_rep if @m_odr_file.update_attributes(params.require(:m_odr_file).permit!) @@ -90,4 +90,13 @@ class Admin::MOdrFilesController < ApplicationController @m_odr_file.destroy end + + def rotate + deg = params[:direction] == "right" ? -90 : 90 + + @m_odr_file = MOdrFile.find(params[:id]) + @m_odr_file.rotate(deg) + end + + end diff --git a/app/controllers/admin/m_odr_remises_controller.rb b/app/controllers/admin/m_odr_remises_controller.rb index dff997f..cacd799 100644 --- a/app/controllers/admin/m_odr_remises_controller.rb +++ b/app/controllers/admin/m_odr_remises_controller.rb @@ -46,7 +46,8 @@ class Admin::MOdrRemisesController < ApplicationController def confirm @m_odr_remise = MOdrRemise.find(params[:id]) - @m_odr_remise.m_odr_virements.each do |m_odr_virement| + @m_odr_remise.m_odr_virements.where(:refused => false).each do |m_odr_virement| + m_odr_virement.sended = true m_odr_virement.m_odr_rep.change_state("Virement envoyé") m_odr_virement.save diff --git a/app/controllers/admin/m_odr_rep_ribs_controller.rb b/app/controllers/admin/m_odr_rep_ribs_controller.rb index 92d0299..254528a 100644 --- a/app/controllers/admin/m_odr_rep_ribs_controller.rb +++ b/app/controllers/admin/m_odr_rep_ribs_controller.rb @@ -45,7 +45,7 @@ class Admin::MOdrRepRibsController < ApplicationController def update @m_odr_rep_rib = MOdrRepRib.find(params[:id]) - + @m_odr_rep = @m_odr_rep_rib.m_odr_rep 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") diff --git a/app/controllers/admin/m_odr_reps_controller.rb b/app/controllers/admin/m_odr_reps_controller.rb index 290799c..b9327f5 100644 --- a/app/controllers/admin/m_odr_reps_controller.rb +++ b/app/controllers/admin/m_odr_reps_controller.rb @@ -11,7 +11,7 @@ class Admin::MOdrRepsController < ApplicationController end def index - @m_odr_reps = MOdrRep.includes(:particulars).includes(:m_odr) + @m_odr_reps = MOdrRep.includes(:m_odr) @can_update = current_admin.has_permission?("odr_rep.update") @@ -29,8 +29,8 @@ class Admin::MOdrRepsController < ApplicationController 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, "m_odr_reps.created_at DESC") diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4adcb86..96df211 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,7 +8,11 @@ class ApplicationController < ActionController::Base before_action :set_locale + before_action :time_stats + def time_stats + @gen_past_time = Time.now + end before_action :popups diff --git a/app/models/m_odr_file.rb b/app/models/m_odr_file.rb index 477664e..fccdbe8 100644 --- a/app/models/m_odr_file.rb +++ b/app/models/m_odr_file.rb @@ -15,7 +15,23 @@ class MOdrFile < ApplicationRecord end while MOdrFile.exists?(:token => self[:token]) end + + + def rotate(degrees=90) + versions = [self.file.path] + versions.each do |v| + image = Magick::ImageList.new(v) + image = image.rotate(degrees) + image.write(v) + end + + self.file.recreate_versions!(:secure, :secure_thumb) + + + self.updated_at = Time.now + self.save + end end diff --git a/app/views/admin/m_odr_files/_image.html.haml b/app/views/admin/m_odr_files/_image.html.haml new file mode 100644 index 0000000..1c27f8d --- /dev/null +++ b/app/views/admin/m_odr_files/_image.html.haml @@ -0,0 +1,2 @@ + +=image_tag(file.file.url+"?v=#{file.updated_at.to_s.to_slug}", :style => "max-width:100%;display:block;margin:auto;") \ No newline at end of file diff --git a/app/views/admin/m_odr_files/rotate.js.erb b/app/views/admin/m_odr_files/rotate.js.erb new file mode 100644 index 0000000..d199ca7 --- /dev/null +++ b/app/views/admin/m_odr_files/rotate.js.erb @@ -0,0 +1 @@ +$('#image_previ').html("<%= escape_javascript(render(:partial => "admin/m_odr_files/image", :locals => {:file => @m_odr_file})) %>"); diff --git a/app/views/admin/m_odr_files/update.js.erb b/app/views/admin/m_odr_files/update.js.erb index 2905cd0..2fa63b7 100644 --- a/app/views/admin/m_odr_files/update.js.erb +++ b/app/views/admin/m_odr_files/update.js.erb @@ -1,2 +1,5 @@ +$('#state').html("<%= escape_javascript(render(:partial => "admin/m_odr_reps/state"))%>"); +$('#head').html("<%= escape_javascript(render(:partial => "admin/m_odr_reps/head"))%>"); +$('#left_column').html("<%= escape_javascript(render(:partial => "admin/m_odr_reps/left_column"))%>"); close_pane_hover(); \ 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 index d6b63b4..30aee55 100644 --- a/app/views/admin/m_odr_remises/_m_odr_remise.html.haml +++ b/app/views/admin/m_odr_remises/_m_odr_remise.html.haml @@ -2,13 +2,15 @@ -tr = {} - + -tr[:confirmed] = capture do + %td + ="Oui" if m_odr_remise.confirmed + -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 diff --git a/app/views/admin/m_odr_remises/show.html.haml b/app/views/admin/m_odr_remises/show.html.haml index 2a24678..17bc5b7 100644 --- a/app/views/admin/m_odr_remises/show.html.haml +++ b/app/views/admin/m_odr_remises/show.html.haml @@ -1,24 +1,28 @@ .qi_header %h1 + Remises %span - + Détails de la remise + +.right=link_to ic(:download)+" Export XML", export_sepa_admin_m_odr_remise_path(@m_odr_remise), :class => "btn btn-primary" +-if !@m_odr_remise.confirmed + =link_to ic(:envelope)+" Confirmer maintenant TOUS les virements", confirm_admin_m_odr_remise_path(@m_odr_remise) , :class => "btn btn-success" + à indiquer une fois que la banque à valider le fichier XML et exectué les virements + + + + +.clear +Virements .qi_row + + + .qi_pannel.qi_plain.padding - =link_to "Export CSV", export_sepa_admin_m_odr_remise_path(@m_odr_remise) - - %br - %br - =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 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 d047c85..2fa63b7 100644 --- a/app/views/admin/m_odr_rep_ribs/update.js.erb +++ b/app/views/admin/m_odr_rep_ribs/update.js.erb @@ -1 +1,5 @@ +$('#state').html("<%= escape_javascript(render(:partial => "admin/m_odr_reps/state"))%>"); +$('#head').html("<%= escape_javascript(render(:partial => "admin/m_odr_reps/head"))%>"); +$('#left_column').html("<%= escape_javascript(render(:partial => "admin/m_odr_reps/left_column"))%>"); + close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/m_odr_reps/_head.html.haml b/app/views/admin/m_odr_reps/_head.html.haml new file mode 100644 index 0000000..cb8b42b --- /dev/null +++ b/app/views/admin/m_odr_reps/_head.html.haml @@ -0,0 +1,34 @@ + +%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 diff --git a/app/views/admin/m_odr_reps/_left_column.html.haml b/app/views/admin/m_odr_reps/_left_column.html.haml new file mode 100644 index 0000000..def5e66 --- /dev/null +++ b/app/views/admin/m_odr_reps/_left_column.html.haml @@ -0,0 +1,141 @@ +%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 + = link_to i(:pencil), edit_admin_m_odr_rep_path(@m_odr_rep), :remote => true + +Fichier +-@m_odr_rep.m_odr_files.order("id DESC").each do |file| + %table.table.table-striped.table-hover.table-bordered + %tr + %td Etat + %td + -if file.admin_ok == true + =state_helper "Validé" + -elsif file.admin_ok == false + =state_helper "Refusé" + + =link_to i(:pencil), edit_admin_m_odr_file_path(file), :remote => true + + + %tr + + %td{:style => "width:200px;"} Fichier + %td + =File.basename file.file.path + + %tr + %td Lien + %td + =link_to ic(:download)+" Télécharger ce fichier", download_admin_m_odr_file_path(file, :disposition => "attachment") + + + %tr + %td Validation + %td + -if file.admin_ok == false + =file.reject_reason + =simple_format file.reject_reason_description if file.reject_reason_description? + + + -if file.admin_ok == false + %tr + %td Envois de mail + + %td + Envoyer un mail de notification : + -[["facture-illisible", "Facture illisible"]].each do |key| + %br + =link_to ic(:envelope)+" #{key[1]}", send_mail_admin_m_odr_file_path(file, :slug => key[0]), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;" + + + +RIB : +-@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 Etat + %td + -if m_odr_rep_rib.admin_ok == true + =state_helper "Validé" + -elsif m_odr_rep_rib.admin_ok == false + =state_helper "Refusé" + + + =link_to i(:pencil), edit_admin_m_odr_rep_rib_path(m_odr_rep_rib), :remote => true + + + %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 == false + + %br + =m_odr_rep_rib.reject_reason + =simple_format m_odr_rep_rib.reject_reason_description if m_odr_rep_rib.reject_reason_description? + + -if m_odr_rep_rib.admin_ok == false + %tr + %td Envois de mail + + %td + Envoyer un mail de notification : + -if true or m_odr_rep_rib.mail_hists.count == 0 + %br + =link_to ic(:envelope)+" Demander un nouveau RIB", send_mail_admin_m_odr_rep_rib_path(m_odr_rep_rib), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;" + + + + + +-if @m_odr_rep.state == "Refusée" + .red Demande refusée + Envoyer un mail de notification : + -[["document-non-valide", "Document non valide"], ["mauvais-titulaire", "Mauvais titulaire"], ["achat-hors-delais", "Achat hors délais"],["pneus-non-porteurs-de-l-offre", "Pneus invalides"],["dossier-deja-enregistre", "Dossier déjà enregistré"]].each do |key| + %br + =link_to ic(:envelope)+" #{key[1]}", send_mail_admin_m_odr_rep_path(@m_odr_rep, :slug => key[0]), :remote => false, :class => "btn btn-primary", :style => "margin-bottom:4px;" + +-else + =link_to "Refuser cette demande", refuse_admin_m_odr_rep_path(@m_odr_rep), :class => "btn btn-danger" + + -if @m_odr_rep.admin_ok_to_send and @m_odr_rep.m_odr_virements.where(:refused => false).count == 0 + %br + %br + =link_to "Générer le virement", generate_virement_admin_m_odr_rep_path(@m_odr_rep), :class => "btn btn-primary" + + \ No newline at end of file diff --git a/app/views/admin/m_odr_reps/_state.html.haml b/app/views/admin/m_odr_reps/_state.html.haml new file mode 100644 index 0000000..ea1634c --- /dev/null +++ b/app/views/admin/m_odr_reps/_state.html.haml @@ -0,0 +1 @@ +=state_helper @m_odr_rep.state \ 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 174514c..87582fe 100644 --- a/app/views/admin/m_odr_reps/index.html.haml +++ b/app/views/admin/m_odr_reps/index.html.haml @@ -6,8 +6,8 @@ %span Liste des participations --MOdrRep.all.each do |m_odr_rep| - -m_odr_rep.save +-#MOdrRep.all.each do |m_odr_rep| +-#m_odr_rep.save .qi_search_row diff --git a/app/views/admin/m_odr_reps/show.html.haml b/app/views/admin/m_odr_reps/show.html.haml index d0c98a1..c9d91a8 100644 --- a/app/views/admin/m_odr_reps/show.html.haml +++ b/app/views/admin/m_odr_reps/show.html.haml @@ -1,7 +1,12 @@ .qi_header + .right + #state=render :partial => "admin/m_odr_reps/state" %h1 - + Participations ODR %span + Détail + + -@m_odr_rep.save @@ -9,160 +14,39 @@ .qi_pannel.qi_plain.padding - - %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 - + #head=render :partial => "admin/m_odr_reps/head" %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? - -[["achat-hors-delais", "Achat hors délais"],["facture-illisible", "Facture illisible"],["pneus-non-porteurs-de-l-offre", "Pneus invalides"]].each do |key| - %br - =link_to "Envoyer un mail de notification : #{key[1]}", send_mail_admin_m_odr_file_path(file, :slug => key[0]), :remote => false - %br - - =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? - - -if m_odr_rep_rib.mail_hists.count == 0 - =link_to "Envoyer un mail de notification", send_mail_admin_m_odr_rep_rib_path(m_odr_rep_rib), :remote => false - - - =link_to "Modérer ce RIB", edit_admin_m_odr_rep_rib_path(m_odr_rep_rib), :remote => true - - - -if @m_odr_rep.state == "Refusée" - .red Offre refusée : - -[["achat-hors-delais", "Achat hors délais"],["facture-illisible", "Facture illisible"],["pneus-non-porteurs-de-l-offre", "Pneus invalides"],["dossier-deja-enregistre", "Dossier déjà enregistré"]].each do |key| - %br - =link_to " Envoyer un mail de notification : #{key[1]}", send_mail_admin_m_odr_rep_path(@m_odr_rep, :slug => key[0]), :remote => false - - -else - =link_to "Marquer cette offre comme refusée", refuse_admin_m_odr_rep_path(@m_odr_rep) + #left_column + =render :partial => "admin/m_odr_reps/left_column" .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;"} + =link_to ic(:download)+" Télécharger le document", download_admin_m_odr_file_path(file, :disposition => "attachment") + -if File.extname(file.file.path) == ".pdf" || File.extname(file.file.path) == ".PDF" + + %iframe{:src => file.file.url, :style => "width:100%;height:800px;border:1px solid gray;"} + + -else +    + =link_to ic(:"rotate-left"), rotate_admin_m_odr_file_path(:id => file.id, :direction => "right"), :remote => true +    + =link_to ic(:"rotate-right"), rotate_admin_m_odr_file_path(file), :remote => true + #image_previ{:style => "width:100%;height:800px;border:1px solid gray;overflow:auto;"} + =render :partial => "admin/m_odr_files/image", :locals => {:file => file} + .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 diff --git a/app/views/admin/m_odr_reps/update.js.erb b/app/views/admin/m_odr_reps/update.js.erb index d3d5f1b..21b883b 100644 --- a/app/views/admin/m_odr_reps/update.js.erb +++ b/app/views/admin/m_odr_reps/update.js.erb @@ -1,2 +1,7 @@ +$('#state').html("<%= escape_javascript(render(:partial => "admin/m_odr_reps/state"))%>"); +$('#head').html("<%= escape_javascript(render(:partial => "admin/m_odr_reps/head"))%>"); +$('#left_column').html("<%= escape_javascript(render(:partial => "admin/m_odr_reps/left_column"))%>"); + + $('#m_odr_rep_row_<%= @m_odr_rep.id %>').replaceWith("<%= escape_javascript(render(@m_odr_rep))%>"); close_pane_hover(); \ 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 index 5d0dce0..ceae83e 100644 --- a/app/views/admin/m_odr_virements/_m_odr_virement.html.haml +++ b/app/views/admin/m_odr_virements/_m_odr_virement.html.haml @@ -12,10 +12,11 @@ -tr[:enabled] = capture do %td -if m_odr_virement.enabled + =ic(:check) Oui -else -if !@m_odr_rep - = link_to i(:check)+" valider maintenant", admin_valid_admin_m_odr_virement_path(m_odr_virement), :remote => true + = link_to ic(:check)+" ok pour remise", admin_valid_admin_m_odr_virement_path(m_odr_virement), :remote => true, :class => "btn btn-success" -tr[:refused] = capture do %td @@ -23,13 +24,21 @@ 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 - + = link_to "Indiquer comme refusé par la banque", refuse_admin_m_odr_virement_path(m_odr_virement), :remote => true, :class => "btn btn-danger" + + + -tr[:sended] = capture do + %td + -if m_odr_virement.sended + =ic(:check) + Envoyé + + -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 !m_odr_virement.enabled + = link_to i(:"trash-o"), [:admin, m_odr_virement], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + diff --git a/app/views/admin/m_odr_virements/destroy.js.erb b/app/views/admin/m_odr_virements/destroy.js.erb index bd23461..54f2d77 100644 --- a/app/views/admin/m_odr_virements/destroy.js.erb +++ b/app/views/admin/m_odr_virements/destroy.js.erb @@ -1 +1 @@ -$('#m_odr_virement_<%= @m_odr_virement.id %>').remove(); \ No newline at end of file +$('#m_odr_virement_row_<%= @m_odr_virement.id %>').remove(); \ 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 index 6a35772..1685f6c 100644 --- a/app/views/admin/m_odr_virements/index.html.haml +++ b/app/views/admin/m_odr_virements/index.html.haml @@ -28,6 +28,6 @@ =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() +%p{:style => "text-align:center;margin-bottom:-10px;margin-top:10px"}=link_to "Générer les remises pour tous les virements ok pour remise", generate_all_admin_m_odr_remises_path(), :class => "btn btn-success" =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @m_odr_virements} diff --git a/app/views/admin/m_odrs/_m_odr.html.haml b/app/views/admin/m_odrs/_m_odr.html.haml index 59c0479..3192237 100644 --- a/app/views/admin/m_odrs/_m_odr.html.haml +++ b/app/views/admin/m_odrs/_m_odr.html.haml @@ -9,18 +9,14 @@ -m_odr.m_odr_trackers.each do |mot| %br =link_to public_m_odr_path(m_odr.slug, :t => mot.token, :lang => nil), public_m_odr_path(m_odr.slug, :t => mot.token, :lang => nil), :target => "_blank" - %td= m_odr.slug %td= m_odr.start_at %td= m_odr.end_at %td= m_odr.public_end - %td= "oui" if m_odr.address_process - %td= "oui" if m_odr.rib_process - %td= "oui" if m_odr.email_needed - %td= "oui" if m_odr.tel_needed + %td.actions - = link_to i(:"trash-o"), [:admin, m_odr], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true + =# link_to i(:"trash-o"), [:admin, m_odr], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true = link_to i(:pencil), edit_admin_m_odr_path(m_odr), :remote => false - = link_to i(:eye), admin_m_odr_path(m_odr), :remote => true + = link_to i(:"bar-chart"), admin_m_odr_path(m_odr), :remote => false diff --git a/app/views/admin/m_odrs/index.html.haml b/app/views/admin/m_odrs/index.html.haml index 571ff12..b179b4d 100644 --- a/app/views/admin/m_odrs/index.html.haml +++ b/app/views/admin/m_odrs/index.html.haml @@ -17,10 +17,7 @@ %th Date de début %th Date de fin %th Fin de réception - %th Adresse ? - %th Rib ? - %th Email ? - %th Tel ? + %th.actions diff --git a/app/views/admin/m_odrs/show.html.haml b/app/views/admin/m_odrs/show.html.haml index c26954a..a387cb0 100644 --- a/app/views/admin/m_odrs/show.html.haml +++ b/app/views/admin/m_odrs/show.html.haml @@ -1,10 +1,59 @@ .qi_header %h1 - + ODR %span + Statistiques + %span + =@m_odr.p_customer.show_name + ="-" + =@m_odr.name .qi_row .qi_pannel.qi_plain.padding - =debug @m_odr \ No newline at end of file + + + -@m_odr_reps = @m_odr.m_odr_reps + + %table.table.table-striped.table-hover.table-bordered + %tr + %th + %th{:rowspan => 2} Nombre de participation + -@m_odr_reps.group(:state).each do |state| + %th{:style => "font-weight:normal", :colspan => 3} + Etat : + =state_helper state.state + + %tr + %th + + -@m_odr_reps.group(:state).each do |state| + %th Nbr participation + %th Nbr pneus + %th Total remises + -m_odr_reps = @m_odr_reps + %tr + %td Général + %td=m_odr_reps.count + -@m_odr_reps.group(:state).each do |state| + %td + =m_odr_reps.where(:state => state.state).count + %td + =m_odr_reps.where(:state => state.state).sum(:qte) + %td.numeraire{:style => ("color:red;" if total = m_odr_reps.where(:state => state.state).sum(:cc_remise) and total == 0.0)} + =number_to_currency total + + -@m_odr_reps.group(:m_odr_place_id).joins(:m_odr_place).order("m_odr_places.name").each do |place| + -m_odr_reps = @m_odr_reps.where(:m_odr_place_id => place.m_odr_place_id) + + %tr + %td=place.m_odr_place.name + %td=m_odr_reps.count + -@m_odr_reps.group(:state).each do |state| + %td + =m_odr_reps.where(:state => state.state).count + %td + =m_odr_reps.where(:state => state.state).sum(:qte) + %td.numeraire{:style => ("color:red;" if total = m_odr_reps.where(:state => state.state).sum(:cc_remise) and total == 0.0)} + =number_to_currency total \ No newline at end of file diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 1af5610..f7341aa 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -279,4 +279,11 @@ = timer_watcher() if Rails.env.production? + + %div{:style => "position:fixed;bottom:2px;right:3px;font-size:9px;z-index:1000"} + -if @gen_past_time + HTML rendu en + ="#{(Time.now - @gen_past_time).round(3)}s" + + diff --git a/config/routes.rb b/config/routes.rb index 3c3e27b..88cd83d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -200,6 +200,7 @@ Rails.application.routes.draw do member do get :download get :send_mail + get :rotate end collection do