def tarifs
@organisation = current_user.organisation
end
+
+ def audit
+ @audits = Audited::Audit
+ .where(user_id: current_user.organisation.users)
+ .order("id DESC")
+ .paginate(page: params[:page], per_page: 10)
+ end
end
module AdminHelper
+ def prettify(audit)
+ pretty_changes = []
+
+ audit.audited_changes.each do |c|
+ key = c.first.humanize
+ if audit.action == 'update'
+ unless c.last.first.blank? && c.last.last.blank?
+ pretty_changes << "#{key} modifié de '#{c.last.first}' à '#{c.last.last}'"
+ end
+ else
+ unless c.last.blank?
+ pretty_changes << "#{key} #{audit.action == 'create' ? 'initialisé à' : 'était'} '#{c.last}'"
+ end
+ end
+ end
+ pretty_changes
+ end
+
end
class Absence < ApplicationRecord
+ audited
+
belongs_to :enfant
self.per_page = 10
class Classroom < ApplicationRecord
+ audited
+
belongs_to :structure, inverse_of: :classrooms
has_many :enfants
class Contact < ApplicationRecord
-
+ audited
+
belongs_to :compte, inverse_of: :contacts
end
extend FriendlyId
friendly_id :nom_et_prénom, use: :slugged
+ audited
+
belongs_to :compte, :counter_cache => true
belongs_to :classroom
belongs_to :tarif_type
extend FriendlyId
friendly_id :réf, use: :slugged
+ audited
+
belongs_to :compte
has_many :facture_lignes, dependent: :destroy
class FactureChrono < ApplicationRecord
+ audited
+
belongs_to :organisation
end
class FactureLigne < ApplicationRecord
+ audited
+
belongs_to :facture
belongs_to :prestation_type
end
class Prestation < ApplicationRecord
+ audited
+
belongs_to :enfant
belongs_to :prestation_type
class PrestationType < ApplicationRecord
+ audited
+
belongs_to :organisation
has_many :tarifs
class Reservation < ApplicationRecord
+ audited
+
belongs_to :enfant, dependent: :destroy
belongs_to :prestation_type
class Structure < ApplicationRecord
-
audited
belongs_to :organisation, inverse_of: :structures
class Tarif < ApplicationRecord
+ audited
+
belongs_to :tarif_type
belongs_to :prestation_type
class TarifType < ApplicationRecord
+ audited
+
belongs_to :organisation
+
has_many :tarifs
has_many :enfants
class Vacance < ApplicationRecord
-
+ audited
+
default_scope { order(:début) }
-
end
--- /dev/null
+<tr>
+ <td><%= l(audit.created_at, format: :short) %></td>
+ <td><%= audit.try(:user).try(:email) %></td>
+ <td><%= audit.auditable_type %></td>
+ <td style="text-align: right;"><%= audit.auditable_id %></td>
+ <td><%= audit.action.humanize %></td>
+ <td><%= sanitize prettify(audit).join('<br>') %></td>
+</tr>
--- /dev/null
+<table class="table table-bordered table-hover table-condensed">
+ <thead>
+ <tr>
+ <th>Date</th>
+ <th>Utilisateur</th>
+ <th>Type</th>
+ <th>id</th>
+ <th>Action</th>
+ <th>Modifications</th>
+ </tr>
+ </thead>
+
+ <%= render partial: 'audit', collection: @audits %>
+
+</table>
+
+<%= will_paginate @audits, renderer: WillPaginate::ActionView::BootstrapLinkRenderer %>
+<br>
\ No newline at end of file
<h4><i class="fas fa-calendar-day"></i> Facturation prestations</h4>
<% end %>
</li>
+
+
+ <li class="list-group-item">
+ <%= link_to admin_audit_path, class: "text-dark" do %>
+ <h4><i class="fas fa-search"></i> Audit des modifications</h4>
+ <% end %>
+ </li>
+
</ul>
</div>
get 'admin/ajout_factures'
post 'admin/ajout_factures_do'
get 'admin/tarifs'
+ get 'admin/audit'
devise_for :users