Les données de compte, contact, enfant, réservation peuvent être importées d'un fichier au format Excel 97-2003 (.xls).
Ce fichier doit contenir les colonnes suivantes :
-structure, nom_compte, civilité, adresse1, adresse2, cp, ville, num_allocataire, mémo_compte, nom_contact, fixe, portable, email, mémo_contact, nom_enfant, prénom, classe, date_naissance, menuSP, menuALL, tarif_type, badge, prestation_type, début, fin, lundi, mardi, mercredi, jeudi, vendredi, matin, midi, soir, active, hors_période_scolaire
+structure, nom_compte, civilité, adresse1, adresse2, cp, ville, num_allocataire, mémo_compte, nom_contact, fixe, portable, email, mémo_contact, nom_enfant, prénom, classe, date_naissance, menu_sp, menu_all, tarif_type, badge, prestation_type, début, fin, lundi, mardi, mercredi, jeudi, vendredi, matin, midi, soir, active, hors_période_scolaire
Exemple de fichier : [Fichier.xls]("/exemple_fichier_import_xls")
@messages << message_import_log(contact)
contact.save if contact.valid? && enregistrer
- # Enfant => classroom nom_enfant prénom date_naissance menuSP menuALL tarif_type badge
+ # Enfant => classroom nom_enfant prénom date_naissance menu_sp menu_all tarif_type badge
enfant = compte
.enfants
.where('UPPER(nom) = ?', row[headers.index 'nom_enfant'].strip.upcase)
classe.nom = row[headers.index 'classe']
end
e.date_naissance = row[headers.index 'date_naissance']
- e.menuSP = (row[headers.index 'menuSP'].strip.upcase == 'OUI')
- e.menuALL = (row[headers.index 'menuALL'].strip.upcase == 'OUI')
+ e.menu_sp = (row[headers.index 'menu_sp'].strip.upcase == 'OUI')
+ e.menu_all = (row[headers.index 'menu_all'].strip.upcase == 'OUI')
e.tarif_type = organisation.tarif_types.find_by(nom: row[headers.index 'tarif_type'])
e.badge = row[headers.index 'badge']
end
def index
authorize Enfant
- @enfants = current_user.organisation.enfants
- @structures = current_user.organisation.structures
- @classrooms = current_user.organisation.classrooms
+ organisation = current_user.organisation
+ @enfants = organisation.enfants
+ @structures = organisation.structures
+ @classrooms = organisation.classrooms
unless params[:structure_id].blank?
@enfants = @enfants.joins(:compte).where(comptes: { structure_id: params[:structure_id] })
end
unless params[:nom].blank?
- @enfants = @enfants.where(Arel.sql("enfants.nom ILIKE '%#{params[:nom]}%' OR enfants.prénom ILIKE '%#{params[:nom]}%'"))
+ s = "'%#{params[:nom]}%'"
+ @enfants = @enfants.where(Arel.sql("enfants.nom ILIKE #{s} OR enfants.prénom ILIKE #{s}"))
end
# Appliquer le tri
# Never trust parameters from the scary internet, only allow the white list through.
def enfant_params
params.require(:enfant)
- .permit(:compte_id, :classroom_id, :nom, :prénom, :date_naissance, :menuSP, :menuALL, :tarif_type_id, :badge,
+ .permit(:compte_id, :classroom_id, :nom, :prénom, :date_naissance, :menu_sp, :menu_all, :tarif_type_id, :badge,
reservations_attributes: [:id, :enfant_id, :prestation_type_id, :début, :fin,
:lundi, :mardi, :mercredi, :jeudi, :vendredi,
:matin, :midi, :soir, :hors_période_scolaire, :_destroy])
end
def sortable_columns
- %w{structures.nom comptes.nom classrooms.nom comptes.nom enfants.nom enfants.prénom enfants.date_naissance enfants.menuSP enfants.menuALL}
+ %w{structures.nom comptes.nom classrooms.nom comptes.nom enfants.nom enfants.prénom enfants.date_naissance enfants.menu_sp enfants.menu_all}
end
def sort_column
- sortable_columns.include?(params[:column]) ? params[:column] : 'id'
+ sortable_columns.include?(params[:column]) ? params[:column] : 'enfants.id'
end
def sort_direction
def self.xls_headers
%w{structure nom_compte civilité adresse1 adresse2 cp ville num_allocataire mémo_compte
nom_contact fixe portable email mémo_contact
- nom_enfant prénom classe date_naissance menuSP menuALL tarif_type badge
+ nom_enfant prénom classe date_naissance menu_sp menu_all tarif_type badge
prestation_type début fin lundi mardi mercredi jeudi vendredi matin midi soir active hors_période_scolaire}
end
<td><%= link_to enfant.prénom, enfant, class: "text-primary" %></td>
<td><%= l enfant.date_naissance %></td>
<td><%= enfant.classroom.nom %></td>
- <td class="text-center"><i class="<%= enfant.menuSP ? "far fa-check-circle" : "" %>"></i></td>
- <td class="text-center"><i class="<%= enfant.menuALL ? "far fa-check-circle" : "" %>"></i></td>
+ <td class="text-center"><i class="<%= enfant.menu_sp ? "far fa-check-circle" : "" %>"></i></td>
+ <td class="text-center"><i class="<%= enfant.menu_all ? "far fa-check-circle" : "" %>"></i></td>
<td>
<% if policy(enfant).edit? %>
<%= link_to edit_enfant_path(enfant) do %>
<td><%= enfant.nom %></td>
<td><%= link_to enfant.prénom, enfant, class: "text-primary" %></td>
<td><%= l enfant.date_naissance %></td>
- <td class="text-center"><i class="<%= enfant.menuSP ? "far fa-check-circle" : "" %>"></i></td>
- <td class="text-center"><i class="<%= enfant.menuALL ? "far fa-check-circle" : "" %>"></i></td>
+ <td class="text-center"><i class="<%= enfant.menu_sp ? "far fa-check-circle" : "" %>"></i></td>
+ <td class="text-center"><i class="<%= enfant.menu_all ? "far fa-check-circle" : "" %>"></i></td>
<td>
<% if policy(enfant).edit? %>
<%= link_to edit_enfant_path(enfant) do %>
-json.extract! enfant, :id, :compte_id, :classroom_id, :nom, :prénom, :date_naissance, :menuSP, :menuALL, :created_at, :updated_at
+json.extract! enfant, :id, :compte_id, :classroom_id, :nom, :prénom, :date_naissance, :menu_sp, :menu_all, :created_at, :updated_at
json.url enfant_url(enfant, format: :json)
<div class="col"><%= form.text_field :badge %></div>
</div>
- <%= form.check_box :menuSP, label: "Menu 'Sans porc' ?", custom: :switch %>
- <%= form.check_box :menuALL, label: "Menu 'Allergie' ?", custom: :switch %>
+ <%= form.check_box :menu_sp, label: "Menu 'Sans porc' ?", custom: :switch %>
+ <%= form.check_box :menu_all, label: "Menu 'Allergie' ?", custom: :switch %>
<br />
<h3><i class="fas fa-calendar-alt"></i> Réservations</h3>
<th><%= sort_link 'enfants.nom', 'Nom' %></th>
<th><%= sort_link 'enfants.prénom', 'Prénom' %></th>
<th><%= sort_link 'enfants.date_naissance', 'Date naissance' %></th>
- <th><%= sort_link 'enfants.menuSP', 'Menu SP?' %></th>
- <th><%= sort_link 'enfants.menuALL', 'Menu ALLERGIE?' %></th>
+ <th><%= sort_link 'enfants.menu_sp', 'Menu SP?' %></th>
+ <th><%= sort_link 'enfants.menu_all', 'Menu ALLERGIE?' %></th>
<th colspan="2"></th>
</tr>
</thead>
<p>
<strong>Menu 'Sans porc' ?:</strong>
- <%= "OUI" if @enfant.menuSP %>
+ <%= "OUI" if @enfant.menu_sp %>
</p>
<p>
<strong>Menu 'Allergie' ?:</strong>
- <%= "OUI" if @enfant.menuALL %>
+ <%= "OUI" if @enfant.menu_all %>
</p>
</div>
<div class=col>
<td><%= reservation.enfant.compte.structure.nom %></td>
<td><%= reservation.enfant.classroom.nom %></td>
<td><%= link_to reservation.enfant.nom_et_prénom, reservation.enfant, class: "text-primary" %></td>
- <td class="text-center"><i class="<%= reservation.enfant.menuSP ? "far fa-check-circle" : "" %>"></i></td>
- <td class="text-center"><i class="<%= reservation.enfant.menuALL ? "far fa-check-circle" : "" %>"></i></td>
+ <td class="text-center"><i class="<%= reservation.enfant.menu_sp ? "far fa-check-circle" : "" %>"></i></td>
+ <td class="text-center"><i class="<%= reservation.enfant.menu_all ? "far fa-check-circle" : "" %>"></i></td>
<td><%= reservation.prestation_type.nom %></td>
<td class="text-center"><%= number_with_precision(reservation.lundi, locale: :fr, precision: 2, significant: true, strip_insignificant_zeros: true) if reservation.lundi > 0 %></td>
<td class="text-center"><%= number_with_precision(reservation.mardi, locale: :fr, precision: 2, significant: true, strip_insignificant_zeros: true) if reservation.mardi > 0 %></td>
t.string :nom, null: false, default: ""
t.string :prénom
t.date :date_naissance
- t.boolean :menuSP
- t.boolean :menuALL
+ t.boolean :menu_sp
+ t.boolean :menu_all
t.timestamps
end
--- /dev/null
+class ChangeEnfantMenuNameDowncase < ActiveRecord::Migration[5.2]
+ def change
+ rename_column :enfants, :menu_sp, :menu_sp
+ rename_column :enfants, :menu_all, :menu_all
+ end
+end
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2019_09_26_091830) do
+ActiveRecord::Schema.define(version: 2019_10_01_142730) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
t.string "nom", default: "", null: false
t.string "prénom"
t.date "date_naissance"
- t.boolean "menuSP"
- t.boolean "menuALL"
+ t.boolean "menu_sp"
+ t.boolean "menu_all"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "tarif_type_id"