gem 'devise'
gem "bootstrap_form", ">= 4.2.0"
gem "audited", "~> 4.9"
+gem 'will_paginate', '~> 3.1.0'
+gem 'will_paginate-bootstrap4'
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
+ will_paginate (3.1.8)
+ will_paginate-bootstrap4 (0.2.2)
+ will_paginate (~> 3.0, >= 3.0.0)
PLATFORMS
ruby
sass-rails (~> 5.0)
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
+ will_paginate (~> 3.1.0)
+ will_paginate-bootstrap4
RUBY VERSION
ruby 2.6.0p0
--- /dev/null
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
--- /dev/null
+// Place all the styles related to the admin controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
*= require rails_bootstrap_forms
*/
-
\ No newline at end of file
+ a:hover {
+ color: white !important;
+ background-color: transparent;
+ }
\ No newline at end of file
--- /dev/null
+class AdminController < ApplicationController
+ def index
+ end
+end
class PrestationsController < ApplicationController
+
def index
+ @prestation_types = current_user.organisation.prestation_types
+
@prestations = current_user.organisation.prestations
+
+ unless params[:prestation_type_id].blank?
+ @prestations = @prestations.where(prestation_type_id: params[:prestation_type_id])
+ end
+
+ unless params[:date].blank?
+ @prestations = @prestations.where(date: params[:date])
+ end
+
+ unless params[:nom].blank?
+ @prestations = @prestations.joins(:enfant).where("enfants.nom like ?", "%#{params[:nom]}%")
+ end
+
+ @prestations = @prestations.paginate(page: params[:page])
end
+
end
--- /dev/null
+module AdminHelper
+end
class Compte < ApplicationRecord
belongs_to :structure
- has_many :contacts, inverse_of: :compte
+ has_many :contacts, inverse_of: :compte, dependent: :delete_all
accepts_nested_attributes_for :contacts, reject_if: proc { |attributes| attributes[:nom].blank? }, allow_destroy: true
has_many :enfants
belongs_to :compte
belongs_to :classroom
- has_many :reservations
+ has_many :reservations, dependent: :destroy
has_many :absences
has_many :prestations
class Prestation < ApplicationRecord
belongs_to :enfant
belongs_to :prestation_type
+
+ # default_scope { order(:date, :prestation_type_id) }
+
+ self.per_page = 10
+
end
has_many :comptes
+ default_scope { order(:nom) }
+
def nom_avec_organisation
self.organisation.nom + "/" + self.nom
end
<tr>
<td><%= absence.enfant.nom_et_prénom %></td>
<td><%= absence.enfant.classroom.nom %></td>
- <td><%= absence.début %></td>
- <td><%= absence.fin %></td>
+ <td><%= l absence.début %></td>
+ <td><%= l absence.fin %></td>
<td><%= absence.matin %></td>
<td><%= absence.midi %></td>
<td><%= absence.soir %></td>
--- /dev/null
+<h1>Admin#index</h1>
+<p>Find me in app/views/admin/index.html.erb</p>
--- /dev/null
+<h1>Admin#moulinette</h1>
+<p>Find me in app/views/admin/moulinette.html.erb</p>
<% @comptes.each do |compte| %>
<tr>
<td><%= compte.structure.nom %></td>
- <td><%= link_to compte.nom, compte %></td>
+ <td><%= link_to compte.nom, compte, class: "text-primary" %></td>
<td><%= compte.civilité %></td>
<td><%= compte.adresse1 %></td>
<td><%= compte.adresse2 %></td>
<% @compte.enfants.each do |enfant| %>
<tr>
<td><%= enfant.nom %></td>
- <td><%= link_to enfant.prénom, enfant %></td>
+ <td><%= link_to enfant.prénom, enfant, class: "text-primary" %></td>
<td><%= enfant.date_naissance %></td>
<td><%= enfant.classroom.nom %></td>
<td><%= enfant.menuSP %></td>
<td><%= enfant.compte.nom %></td>
<td><%= enfant.classroom.nom %></td>
<td><%= enfant.nom %></td>
- <td><%= link_to enfant.prénom, enfant %></td>
- <td><%= enfant.date_naissance %></td>
+ <td><%= link_to enfant.prénom, enfant, class: "text-primary" %></td>
+ <td><%= l enfant.date_naissance %></td>
<td><%= enfant.menuSP %></td>
<td><%= enfant.menuALL %></td>
<td><%= link_to 'Edit', edit_enfant_path(enfant) %></td>
<table class="table table-striped">
<% @enfant.reservations.each do |reservation| %>
<tr>
- <td><%= reservation.début %></td>
- <td><%= reservation.fin %></td>
+ <td><%= l reservation.début %></td>
+ <td><%= l reservation.fin %></td>
<td><%= reservation.prestation_type.nom %>
<td><%= reservation.lundi %>
<td><%= reservation.mardi %>
<table class="table table-striped">
<% @enfant.absences.each do |absence| %>
<tr>
- <td><%= absence.début %></td>
- <td><%= absence.fin %></td>
+ <td><%= l absence.début %></td>
+ <td><%= l absence.fin %></td>
<td><%= absence.matin %></td>
<td><%= absence.midi %></td>
<td><%= absence.soir %></td>
<table class="table table-striped">
<% @enfant.prestations.each do |prestation| %>
<tr>
- <td><%= prestation.date %></td>
+ <td><%= l prestation.date %></td>
<td><%= prestation.prestation_type.nom %>
<td><%= prestation.qté %></td>
</tr>
<ul class="navbar-nav navbar-right">
<% if current_user %>
<li class="nav-item <%= (params[:controller]=='organisations' ? 'active' : '') %>">
- <%= link_to organisation_url(current_user.organisation), class: "nav-link" do %><i class="fas fa-sitemap"></i></span> Organisation<% end %>
+ <%= link_to organisation_url(current_user.organisation), class: "nav-link" do %><i class="fas fa-city"></i></span> Organisation<% end %>
+ </li>
+ <li class="nav-item <%= (params[:controller]=='admin' ? 'active' : '') %>">
+ <%= link_to admin_index_url, class: "nav-link" do %><i class="fas fa-toolbox"></i></span> Admin<% end %>
</li>
<% end %>
<li class="nav-item">
<div class="col">
<%= form.text_field :nom %>
<%= form.text_field :adresse %>
- <%= form.text_field :cp %>
- <%= form.text_field :ville %>
+ <div class="row">
+ <div class="col-sm-3"><%= form.text_field :cp %></div>
+ <div class="col"><%= form.text_field :ville %></div>
+ </div>
</div>
<div class="col">
- <%= form.text_field :téléphone %>
- <%= form.text_field :email %>
- <%= form.file_field :logo %>
- <%= form.select :zone, ["A", "B", "C"], { label: "Zone de vacances scolaires:", wrapper: { class: 'has-warning', data: { foo: 'bar' } } }, { class: "selectpicker" } %>
+ <div class="row">
+ <div class="col-sm-4"><%= form.text_field :téléphone %></div>
+ <div class="col"><%= form.text_field :email %></div>
+ </div>
+ <div class="row">
+ <div class="col-sm-5"><%= form.select :zone, ["A", "B", "C"], { label: "Zone", help: "Zone de vacances scolaires", wrapper: { class: 'has-warning', data: { foo: 'bar' } } }, { class: "selectpicker" } %></div>
+ <div class="col"><%= form.file_field :logo, help: "Votre logo. Apparaît en haut des documents" %></div>
+ </div>
</div>
</div>
- <h3>Structures</h3>
- <%= form.fields_for :structures do |structure_form| %>
- <div class="row">
- <div class="col"><%= structure_form.text_field :nom, label_as_placeholder: true %></div>
- <div class="col"><%= structure_form.check_box :_destroy, label: "Supprimer ?" %></div>
- </div>
- <% end %>
+ <p>
+ <h3><i class="fas fa-school"></i> Structures</h3>
+ <%= form.fields_for :structures do |structure_form| %>
+ <div class="row">
+ <div class="col-sm-5"><%= structure_form.text_field :nom, label_as_placeholder: true %></div>
+ <% unless structure_form.object.new_record? or structure_form.object.comptes.any? or structure_form.object.classrooms.any? %>
+ <div class="col"><%= structure_form.check_box :_destroy, label: "Supprimer ?" %></div>
+ <% end %>
+ </div>
+ <% end %>
+ </p>
<div class="actions">
<%= form.submit "Enregistrer", class: "btn btn-success" %>
-<h1>Editing Organisation</h1>
+<h1>Editer Organisation</h1>
<%= render 'form', organisation: @organisation %>
-
-<%= link_to 'Show', @organisation %> |
-<%= link_to 'Back', organisations_path %>
-<h1><i class="fas fa-sitemap"></i> Organisation</h1>
-<p>
- <%= image_tag url_for(@organisation.logo) %>
-</p>
+<h1><i class="fas fa-city"></i> Organisation</h1>
<div class="row">
<div class="col">
- <h2>
- <%= @organisation.nom %>
- </h2>
-
<p>
- <strong>Adresse:</strong>
- <%= @organisation.adresse %>
+ <h2>
+ <%= @organisation.nom %>
+ </h2>
</p>
-
+
<p>
- <strong>Cp:</strong>
- <%= @organisation.cp %>
+ <strong>Adresse:</strong>
+ <%= @organisation.adresse %>
</p>
<p>
<strong>Ville:</strong>
- <%= @organisation.ville %>
+ <%= @organisation.cp %> <%= @organisation.ville %>
</p>
<p>
<strong>Email:</strong>
<%= @organisation.email %>
</p>
+ <%= link_to 'Editer', edit_organisation_path(@organisation) %>
+ </div>
+ <div class="col">
+ <p>
+ <%= image_tag url_for(@organisation.logo) %>
+ </p>
+ </div>
+</div>
+
+<div class="row">
+ <div class="col">
<p>
- <h3>Structures</h3>
+ <h3><i class="fas fa-school"></i> Structures</h3>
<table class="table table-bordered table-striped table-sm">
+ <thead>
+ <tr>
+ <th>Nom</th>
+ <th>Classes</th>
+ <th>Comptes</th>
+ </tr>
+ </thead>
<% @organisation.structures.each do |structure| %>
<tr>
- <td><%= link_to structure.nom, structure %></td>
+ <td><%= link_to structure.nom, structure, class: "text-primary" %></td>
+ <td><%= structure.classrooms.pluck(:nom).join(", ") %></td>
+ <td><%= structure.comptes.size %></td>
</tr>
<% end %>
</table>
</p>
- <%= link_to 'Editer', edit_organisation_path(@organisation) %>
<p>
- <h3>Types de prestations</h3>
+ <h3>Types de tarifs</h3>
<table class="table table-bordered table-striped table-sm">
- <% @organisation.prestation_types.each do |prestation| %>
+ <thead>
<tr>
- <td><%= link_to prestation.nom, prestation %></td>
+ <th>Nom</th>
+ </tr>
+ </thead>
+ <% @organisation.tarif_types.each do |tarif| %>
+ <tr>
+ <td><%= link_to tarif.nom, tarif, class: "text-primary" %></td>
</tr>
<% end %>
</table>
</p>
+ <%= link_to "Ajouter un type de tarif", new_tarif_type_path(organisation_id: @organisation) %>
- <%= link_to "Ajouter un type de prestation", new_prestation_type_path(organisation_id: @organisation) %>
-
- </div>
- <div class="col">
<p>
- <h3>Types de tarifs</h3>
+ <h3>Types de prestations</h3>
<table class="table table-bordered table-striped table-sm">
- <% @organisation.tarif_types.each do |tarif| %>
+ <thead>
<tr>
- <td><%= link_to tarif.nom, tarif %></td>
+ <th>Nom</th>
+ </tr>
+ </thead>
+ <% @organisation.prestation_types.each do |prestation| %>
+ <tr>
+ <td><%= link_to prestation.nom, prestation, class: "text-primary" %></td>
</tr>
<% end %>
</table>
</p>
+ <%= link_to "Ajouter un type de prestation", new_prestation_type_path(organisation_id: @organisation) %>
- <%= link_to "Ajouter un type de tarif", new_tarif_type_path(organisation_id: @organisation) %>
+ </div>
+ <div class="col">
<p>
<h3>Tarifs</h3>
<table class="table table-bordered table-striped table-sm">
+ <thead>
+ <tr>
+ <th>Type Tarif</th>
+ <th>Type Prestation</th>
+ <th>Prix</th>
+ </tr>
+ </thead>
<% @organisation.tarifs.each do |tarif| %>
<tr>
<td><%= tarif.tarif_type.nom %></td>
<p>
<h3>Vacances (Zone <%= @organisation.zone %>)</h3>
<table class="table table-bordered table-striped table-sm">
+ <thead>
+ <tr>
+ <th>Nom</th>
+ <th>Début</th>
+ <th>Fin</th>
+ </tr>
+ </thead>
<% Vacance.where(zone: @organisation.zone).each do | vacance | %>
<tr>
<td><%= vacance.nom %></td>
- <td><%= vacance.début %></td>
- <td><%= vacance.fin %></td>
+ <td><%= l vacance.début %></td>
+ <td><%= l vacance.fin if vacance.fin %></td>
</tr>
<% end %>
</table>
<h1><i class="fas fa-utensils"></i> Prestations</h1>
+<%= bootstrap_form_tag url: prestations_index_path, method: :get do |f| %>
+ <div class="row">
+ <div class="col"><%= f.select :prestation_type_id, options_from_collection_for_select(@prestation_types, 'id', 'nom', params[:prestation_type_id]), { include_blank: true, label: "Type" }, { class: "selectpicker", onchange: "this.form.submit()" } %></div>
+ <div class="col"><%= f.text_field :nom, value: params[:nom], onchange: "this.form.submit()" %></div>
+ <div class="col"><%= f.date_field :date, value: params[:date], onchange: "this.form.submit()" %></div>
+ </div>
+<% end %>
+
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th>Type</th>
<th>Qté</th>
- <th colspan="3"></th>
+ <th colspan="1"></th>
</tr>
</thead>
<td><%= prestation.enfant.nom %></td>
<td><%= prestation.enfant.prénom %></td>
<td><%= prestation.enfant.classroom.nom %></td>
- <td><%= prestation.date %></td>
+ <td><%= l prestation.date %></td>
<td><%= prestation.prestation_type.nom %></td>
<td><%= prestation.qté %></td>
+ <td></td>
</tr>
<% end %>
</tbody>
-</table>
\ No newline at end of file
+</table>
+
+<%= will_paginate @prestations, renderer: WillPaginate::ActionView::BootstrapLinkRenderer %>
<td><%= reservation.enfant.nom %></td>
<td><%= reservation.enfant.prénom %></td>
<td><%= reservation.prestation_type.nom %></td>
- <td><%= reservation.début %></td>
- <td><%= reservation.fin %></td>
+ <td><%= l reservation.début %></td>
+ <td><%= l reservation.fin %></td>
<td><%= reservation.lundi %></td>
<td><%= reservation.mardi %></td>
<td><%= reservation.mercredi %></td>
</table>
<br>
-
-<%= link_to 'New Reservation', new_reservation_path %>
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
+
+ config.i18n.default_locale = :fr
+
# Don't generate system test files.
config.generators.system_tests = nil
--- /dev/null
+fr:
+ devise:
+ mailer:
+ hello: "Bienvenu %{email} !"
+ welcome: "Bienvenu %{email} !"
+ confirm: "Valider mon compte"
+ change: 'Changer mon mot de passe'
+ someone_requested: "Un changement de mot de passe a été demandé. Vous pouvez le faire en cliquant sur le lien ci-dessous."
+ please_ignore: "Si vous n'avez pas fait cette demande, veuillez ignorer cet email."
+ password_wont_change: "Votre mot de passe ne sera pas changé tant que vous n'aurez pas accédé au lien ci-dessus pour en créer un nouveau."
+ locked: "Votre compte a été bloqué à cause d'un nombre excessif de tentatives de connexion."
+ click_to_unlock: "Cliquez sur le lien ci-dessous pour déverrouiller votre compte"
+ unlock: "Déverrouiller mon compte"
+ confirmation_instructions:
+ subject: "Instructions de confirmation"
+ msg: "Vous pouvez confirmer votre compte au travers du lien suivant"
+ link: "Confirmer mon compte"
+ reset_password_instructions:
+ subject: "Instructions pour changer le mot de passe"
+ unlock_instructions:
+ subject: "Instructions pour déverrouiller le compte"
\ No newline at end of file
--- /dev/null
+fr:
+ activerecord:
+ errors:
+ messages:
+ record_invalid: 'La validation a échoué : %{errors}'
+ restrict_dependent_destroy:
+ has_one: Vous ne pouvez pas supprimer l'enregistrement car un(e) %{record}
+ dépendant(e) existe
+ has_many: Vous ne pouvez pas supprimer l'enregistrement parce que les %{record}
+ dépendants existent
+ date:
+ abbr_day_names:
+ - dim
+ - lun
+ - mar
+ - mer
+ - jeu
+ - ven
+ - sam
+ abbr_month_names:
+ -
+ - jan.
+ - fév.
+ - mar.
+ - avr.
+ - mai
+ - juin
+ - juil.
+ - août
+ - sept.
+ - oct.
+ - nov.
+ - déc.
+ day_names:
+ - dimanche
+ - lundi
+ - mardi
+ - mercredi
+ - jeudi
+ - vendredi
+ - samedi
+ formats:
+ default: "%d/%m/%Y"
+ long: "%e %B %Y"
+ short: "%e %b"
+ month_names:
+ -
+ - janvier
+ - février
+ - mars
+ - avril
+ - mai
+ - juin
+ - juillet
+ - août
+ - septembre
+ - octobre
+ - novembre
+ - décembre
+ order:
+ - :day
+ - :month
+ - :year
+ datetime:
+ distance_in_words:
+ about_x_hours:
+ one: environ une heure
+ other: environ %{count} heures
+ about_x_months:
+ one: environ un mois
+ other: environ %{count} mois
+ about_x_years:
+ one: environ un an
+ other: environ %{count} ans
+ almost_x_years:
+ one: presqu'un an
+ other: presque %{count} ans
+ half_a_minute: une demi-minute
+ less_than_x_seconds:
+ zero: moins d'une seconde
+ one: moins d'une seconde
+ other: moins de %{count} secondes
+ less_than_x_minutes:
+ zero: moins d'une minute
+ one: moins d'une minute
+ other: moins de %{count} minutes
+ over_x_years:
+ one: plus d'un an
+ other: plus de %{count} ans
+ x_seconds:
+ one: 1 seconde
+ other: "%{count} secondes"
+ x_minutes:
+ one: 1 minute
+ other: "%{count} minutes"
+ x_days:
+ one: 1 jour
+ other: "%{count} jours"
+ x_months:
+ one: 1 mois
+ other: "%{count} mois"
+ x_years:
+ one: 1 an
+ other: "%{count} ans"
+ prompts:
+ second: Seconde
+ minute: Minute
+ hour: Heure
+ day: Jour
+ month: Mois
+ year: Année
+ errors:
+ format: "%{attribute} %{message}"
+ messages:
+ accepted: doit être accepté(e)
+ blank: doit être rempli(e)
+ confirmation: ne concorde pas avec %{attribute}
+ empty: doit être rempli(e)
+ equal_to: doit être égal à %{count}
+ even: doit être pair
+ exclusion: n'est pas disponible
+ greater_than: doit être supérieur à %{count}
+ greater_than_or_equal_to: doit être supérieur ou égal à %{count}
+ inclusion: n'est pas inclus(e) dans la liste
+ invalid: n'est pas valide
+ less_than: doit être inférieur à %{count}
+ less_than_or_equal_to: doit être inférieur ou égal à %{count}
+ model_invalid: 'Validation échouée : %{errors}'
+ not_a_number: n'est pas un nombre
+ not_an_integer: doit être un nombre entier
+ odd: doit être impair
+ other_than: doit être différent de %{count}
+ present: doit être vide
+ required: doit exister
+ taken: n'est pas disponible
+ too_long:
+ one: est trop long (pas plus d'un caractère)
+ other: est trop long (pas plus de %{count} caractères)
+ too_short:
+ one: est trop court (au moins un caractère)
+ other: est trop court (au moins %{count} caractères)
+ wrong_length:
+ one: ne fait pas la bonne longueur (doit comporter un seul caractère)
+ other: ne fait pas la bonne longueur (doit comporter %{count} caractères)
+ template:
+ body: 'Veuillez vérifier les champs suivants : '
+ header:
+ one: 'Impossible d''enregistrer ce(tte) %{model} : 1 erreur'
+ other: 'Impossible d''enregistrer ce(tte) %{model} : %{count} erreurs'
+ helpers:
+ select:
+ prompt: Veuillez sélectionner
+ submit:
+ create: Créer un(e) %{model}
+ submit: Enregistrer ce(tte) %{model}
+ update: Modifier ce(tte) %{model}
+ number:
+ currency:
+ format:
+ delimiter: " "
+ format: "%n %u"
+ precision: 2
+ separator: ","
+ significant: false
+ strip_insignificant_zeros: false
+ unit: "€"
+ format:
+ delimiter: " "
+ precision: 3
+ separator: ","
+ significant: false
+ strip_insignificant_zeros: false
+ human:
+ decimal_units:
+ format: "%n %u"
+ units:
+ billion: milliard
+ million: million
+ quadrillion: million de milliards
+ thousand: millier
+ trillion: billion
+ unit: ''
+ format:
+ delimiter: ''
+ precision: 3
+ significant: true
+ strip_insignificant_zeros: true
+ storage_units:
+ format: "%n %u"
+ units:
+ byte:
+ one: octet
+ other: octets
+ eb: Eo
+ gb: Go
+ kb: ko
+ mb: Mo
+ pb: Po
+ tb: To
+ percentage:
+ format:
+ delimiter: ''
+ format: "%n%"
+ precision:
+ format:
+ delimiter: ''
+ support:
+ array:
+ last_word_connector: " et "
+ two_words_connector: " et "
+ words_connector: ", "
+ time:
+ am: am
+ formats:
+ default: "%d %B %Y %Hh %Mmin %Ss"
+ long: "%A %d %B %Y %Hh%M"
+ short: "%d %b %Hh%M"
+ pm: pm
Rails.application.routes.draw do
+ get 'admin/index'
+ get 'admin/moulinette'
resources :absences
resources :reservations
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
puts "-- ON BOOK ! --"
reservations.each do |reservation|
puts reservation.prestation_type.nom
- puts "Jour semaine match" if jour_semaine_match?(today, reservation)
+ qté_reservée = jour_semaine_match?(today, reservation)
+
+ if qté_reservée > 0
+ puts "Jour semaine match"
+ enfant
+ .prestations
+ .create(prestation_type: reservation.prestation_type,
+ date: today,
+ qté: qté_reservée)
+ end
end
end
-
puts "+-" * 20
end
-
end
end
# Est-ce que la réservation inclue le jour de la semaine de date ?
case date.wday
when 1 # lundi
- reservation.lundi > 0
+ reservation.lundi
when 2 # mardi
- reservation.mardi > 0
+ reservation.mardi
when 3
- reservation.mercredi > 0
+ reservation.mercredi
when 4
- reservation.jeudi > 0
+ reservation.jeudi
when 5
- reservation.vendredi > 0
+ reservation.vendredi
end
end