Case personnalisée et double fichier
This commit is contained in:
parent
77e6847052
commit
913af8a1fd
@ -4,7 +4,7 @@ class MOdrFile < ApplicationRecord
|
||||
|
||||
mount_uploader :file, OdrUploader
|
||||
|
||||
validates :file, :presence => true
|
||||
validates :file, :presence => true, :if => :file_needed?
|
||||
|
||||
|
||||
before_create { generate_token() }
|
||||
@ -14,6 +14,19 @@ class MOdrFile < ApplicationRecord
|
||||
self[:token] = SecureRandom.urlsafe_base64
|
||||
end while MOdrFile.exists?(:token => self[:token])
|
||||
end
|
||||
|
||||
def file_needed?
|
||||
|
||||
if self.m_odr_file_type&.need_file
|
||||
|
||||
true
|
||||
|
||||
else
|
||||
false
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
@ -35,6 +35,7 @@ class MOdrRep < ApplicationRecord
|
||||
validates :m_odr_place_id, :presence => true
|
||||
|
||||
validates :rgpd, :presence => true, :if => :rgpd_needed?
|
||||
validates :custom_case, :presence => true, :if => :custom_case_needed?
|
||||
|
||||
validates :reduc_code, :presence => true, :if => :reduc_code_needed? #length: { in: 6..6 },
|
||||
|
||||
@ -46,7 +47,16 @@ class MOdrRep < ApplicationRecord
|
||||
belongs_to :m_odr_product_cat
|
||||
|
||||
|
||||
|
||||
|
||||
def custom_case_needed?
|
||||
if self.m_odr.custom_case_needed
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def reduc_needed?
|
||||
if self.m_odr.reduc_needed
|
||||
@ -118,7 +128,7 @@ file_admin_ok remise particular_civilite particular_name particular_firstname pa
|
||||
end
|
||||
|
||||
def ca_file_admin_ok
|
||||
if self.m_odr_files.where(:admin_ok => true).count > 0
|
||||
if self.m_odr_files.where(:admin_ok => true).count == self.m_odr_files.count
|
||||
true
|
||||
else
|
||||
false
|
||||
@ -317,6 +327,7 @@ file_admin_ok remise particular_civilite particular_name particular_firstname pa
|
||||
:cc_place_name => {:name => "Revendeur", :reorder => true},
|
||||
|
||||
:reduc_code => {:name => "Code réduction", :reorder => true},
|
||||
:custom_case => {:name => "Case personnalisée", :reorder => true, :as => :boolean},
|
||||
|
||||
:ba_number => {:name => "N° bon de réduction", :reorder => true},
|
||||
:ba_used => {:name => "Bon utilisé ?", :reorder => true, :as => :boolean},
|
||||
|
@ -32,6 +32,17 @@
|
||||
%td
|
||||
=@m_odr_rep.reduc_code
|
||||
|
||||
-if @m_odr_rep.m_odr.custom_case
|
||||
%tr
|
||||
%td
|
||||
Case personnalisée cochée
|
||||
="(#{@m_odr_rep.m_odr.custom_case_label})"
|
||||
|
||||
%td
|
||||
-if @m_odr_rep.custom_case
|
||||
Oui
|
||||
-else
|
||||
Non
|
||||
|
||||
|
||||
|
||||
@ -48,60 +59,65 @@
|
||||
|
||||
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é"
|
||||
-else
|
||||
=link_to admin_m_odr_file_path(:id => file.id, :m_odr_file => {:admin_ok => true}), :remote => true, :method => :put do
|
||||
=ic :check
|
||||
Valider
|
||||
|
||||
|
||||
=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
|
||||
-if file.file? and file.file.path.present?
|
||||
%table.table.table-striped.table-hover.table-bordered
|
||||
%tr
|
||||
%td Envois de mail
|
||||
|
||||
%td Type
|
||||
%td
|
||||
Envoyer un mail de notification :
|
||||
|
||||
-if mail_type_cat = @m_odr_rep.m_odr.mail_type_cats.where(:slug => "refus-facture").first
|
||||
-slugs = mail_type_cat.mail_types.map{|u| [u.slug, u.slug]}
|
||||
=file.m_odr_file_type.name if file.m_odr_file_type
|
||||
%tr
|
||||
%td Etat
|
||||
%td
|
||||
-if file.admin_ok == true
|
||||
=state_helper "Validé"
|
||||
-elsif file.admin_ok == false
|
||||
=state_helper "Refusé"
|
||||
-else
|
||||
-slugs = [["facture-illisible", "Facture illisible"]]
|
||||
|
||||
-slugs.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;"
|
||||
|
||||
|
||||
=link_to admin_m_odr_file_path(:id => file.id, :m_odr_file => {:admin_ok => true}), :remote => true, :method => :put do
|
||||
=ic :check
|
||||
Valider
|
||||
|
||||
|
||||
=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 :
|
||||
|
||||
-if mail_type_cat = @m_odr_rep.m_odr.mail_type_cats.where(:slug => "refus-facture").first
|
||||
-slugs = mail_type_cat.mail_types.map{|u| [u.slug, u.slug]}
|
||||
-else
|
||||
-slugs = [["facture-illisible", "Facture illisible"]]
|
||||
|
||||
-slugs.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|
|
||||
|
@ -44,22 +44,23 @@
|
||||
|
||||
|
||||
.columns.span_8{:style => "padding-left:20px;"}
|
||||
-file = @m_odr_rep.m_odr_files.order("id DESC").first
|
||||
-if file
|
||||
=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}
|
||||
-file = @m_odr_rep.m_odr_files.order("id DESC").each do |file|
|
||||
-if file.file and file.file.path.present?
|
||||
|
||||
=link_to ic(:download)+" Télécharger le document", download_admin_m_odr_file_path(file, :disposition => "attachment")
|
||||
|
||||
|
||||
-if file.file and file.file.path.present? and 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}
|
||||
|
||||
|
||||
|
||||
|
@ -78,6 +78,9 @@
|
||||
= f.input :reduc_needed, :label => "Obligatoire ?"
|
||||
|
||||
= f.input :confirm_case_needed, :label => "Case de confirmation obligatoire ?"
|
||||
|
||||
= f.input :custom_case, :label => "Case personnalisée ?"
|
||||
= f.input :custom_case_needed, :label => "Case personnalisée obligatoire ?"
|
||||
|
||||
|
||||
= f.input :product_process, :label => "Produit ?"
|
||||
@ -93,7 +96,8 @@
|
||||
= f.input :placeholder, :label => "Afficher les libellés ?"
|
||||
= f.input :name_label, :label => "Label nom :"
|
||||
= f.input :firstname_label, :label => "Label prénom :"
|
||||
= f.input :confirm_case_label, :label => "Label case de confirmation :"
|
||||
= f.input :confirm_case_label, :label => "Label case de confirmation :"
|
||||
= f.input :custom_case_label, :label => "Label case personnalisée :"
|
||||
= f.input :product_cat_label, :label => "Label catégorie produit :"
|
||||
= f.input :product_label, :label => "Label produit :"
|
||||
= f.input :qte_label, :label => "Label quantité :"
|
||||
|
@ -193,6 +193,11 @@
|
||||
-if @m_odr_rep.m_odr.confirm_case_needed
|
||||
=f.input :rgpd, :label => (@m_odr_rep.m_odr.confirm_case_label? ? @m_odr_rep.m_odr.confirm_case_label : "J'accepte les conditions générales")
|
||||
|
||||
-if @m_odr_rep.m_odr.custom_case
|
||||
=f.input :custom_case, :label => (@m_odr_rep.m_odr.custom_case_label? ? @m_odr_rep.m_odr.custom_case_label : "")
|
||||
|
||||
|
||||
|
||||
-if @m_odr_rep.m_odr.buy_infos?
|
||||
.buy_infos{:style => "text-align:center"}=simple_format @m_odr_rep.m_odr.buy_infos
|
||||
%br
|
||||
|
7
db/migrate/20250612084840_add_custom_case_to_m_odrs.rb
Normal file
7
db/migrate/20250612084840_add_custom_case_to_m_odrs.rb
Normal file
@ -0,0 +1,7 @@
|
||||
class AddCustomCaseToMOdrs < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :m_odrs, :custom_case_needed, :boolean, :default => false
|
||||
add_column :m_odrs, :custom_case, :boolean, :default => false
|
||||
add_column :m_odrs, :custom_case_label, :string
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddCustomCaseToMOdrReps < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :m_odr_reps, :custom_case, :boolean, :default => false
|
||||
end
|
||||
end
|
328
db/schema.rb
328
db/schema.rb
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user