{% extends 'base.html.twig' %}
{% block title %}Editer | {{ parent() }}{% endblock %}
{% block body %}
<div class="breadcrumb">
<h1 class="mr-2">Bulletin de notes</h1>
<ul>
<li><a href="{{ path('default') }}" onclick="$('.loader').addClass('is-active');">Accueil</a></li>
<li><a href="#">Pedagogie</a></li>
<li><a href="{{ path('report_card_index') }}" onclick="$('.loader').addClass('is-active');">Retour</a></li>
<li>Editer : {{ report_card.label }}</li>
<li>{{ report_card.level }}</li>
<li>{{ report_card.schoolYearPeriode }}</li>
</ul>
</div>
<div class="separator-breadcrumb border-top"></div>
<div class="row mb-4">
<div class="col-md-12">
{% if not report_card.schoolYearPeriode.isClosed %}
<a href="#" class="btn btn-danger" onclick="javascript:actionByPathAndElts('{{path('school_report_cards_selected_delete')}}')" id="delete-selected-btn"><i class="fa fa-trash"></i> Supprimer</a>
{% if report_card.isValidated %}
<a href="#" class="btn btn-warning" onclick="javascript:actionByPathAndElts('{{path('report_card_cancel', {'id': report_card.id})}}')"><i class="fa fa-times"></i> Annuler</a>
{% else %}
<a href="#" class="btn btn-success" onclick="javascript:actionByPathAndElts('{{path('report_card_validate', {'id': report_card.id})}}')"><i class="fa fa-check"></i> Valider</a>
{% endif %}
{% endif %}
<a href="{{ path('report_card_edit', {'id': report_card.id}) }}" class="btn btn-primary"><i class="fa fa-reload"></i> Actualiser</a>
{% if is_granted('ROLE_ADMIN') %}
<button type="button" class="btn btn-dark" data-toggle="modal" data-target="#modalImpression"><i class="fa fa-print"></i> Imprimer bulletin</button>
{% endif %}
<div class="btn-group">
<button type="button" class="btn btn-dark dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-print"></i> Fiches & Bordereaux
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="{{ path('report_card_blank_note_card_print', {'id': report_card.id}) }}"><i class="fa fa-file-o"></i> Fiche de note Vide</a>
<a class="dropdown-item" href="{{ path('report_card_note_card_print', {'id': report_card.id}) }}"><i class="fa fa-file-text-o"></i> Fiche de note</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="{{ path('report_card_assessment_slip_print', {'id': report_card.id}) }}"><i class="fa fa-list"></i> Bordereau d'évaluation</a>
<a class="dropdown-item" href="{{ path('report_card_annual_assessment_slip_print', {'id': report_card.id}) }}"><i class="fa fa-list-alt"></i> Bordereau d'évaluation annuel</a>
</div>
</div>
</div>
</div>
<hr />
<div class="row mb-4">
<div class="col-md-12">
{# <a href="#" class="btn btn-primary" onclick="javascript:computeAverage();"><i class="fa fa-calculator"></i> Recalculer les moyennes</a>
<a href="#" class="btn btn-primary" onclick="javascript:computeRank();"><i class="fa fa-calculator"></i> Recalculer les rangs</a>
<a href="#" class="btn btn-primary" onclick="javascript:computeAnnualReportCardAverage();"><i class="fa fa-calculator"></i> Recalculer les moyennes annuelles</a>
<a href="#" class="btn btn-primary" onclick="javascript:computeAnnualRank();"><i class="fa fa-calculator"></i> Recalculer les rangs annuelles</a> #}
</div>
</div>
{# un panel bien organisé pour les boutons de calcul des moyennes #}
<div class="row mb-4">
<div class="col-md-12 mb-4">
<div class="card text-left">
<div class="card-header">Calcul des moyennes</div>
<div class="card-body">
<div class="table-responsive">
<table class="display table table-striped table-bordered">
<tbody>
<tr>
<td><a href="#" onclick="javascript:computeSchoolAverageReportCards();"><i class="fa fa-calculator"></i> Recalculer les moyennes</a></td>
<td><a href="#" onclick="javascript:computeStudentRank();"><i class="fa fa-calculator"></i> Faire le rang</a></td>
<td><a href="#" onclick="javascript:computeAnnualReportCardAverage();"><i class="fa fa-calculator"></i> Moyennes annuelles</a></td>
<td><a href="#" onclick="javascript:computeAnnualRank();"><i class="fa fa-calculator"></i> Rang annuelles</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<hr />
<div class="row mb-4">
<div class="col-md-12 mb-4">
<div class="card text-left">
<div class="card-header">Bulletins élève</div>
<div class="card-body">
<div class="table-responsive">
<table class="display table table-striped table-bordered">
<thead>
<tr>
<th class="text-center" width="5%">
{% if not report_card.schoolYearPeriode.isClosed %}
<input type="checkbox" id="check-all" onclick="javascript:checkAllElt()">
{% endif %}
</th>
<th>Bulletin élève</th>
<th>Classe</th>
<th>Moyenne</th>
<th class="text-center" width="10%">Action</th>
</tr>
{% if not report_card.schoolYearPeriode.isClosed %}
<tr>
{{ form_start(school_report_card_form) }}
<th></th>
<th>
{{ form_widget(school_report_card_form.studentRegistration,{'attr': {'class': 'form-control select', 'style': 'width: 100%;'}}) }}
</th>
<th></th>
<th></th>
<th class="text-center">
<button class="btn-sm btn-primary"><i class="fa fa-plus"></i></button>
</th>
{{ form_end(school_report_card_form) }}
</tr>
{% endif %}
</thead>
<tbody>
{% for schoolReportCard in school_report_cards %}
<tr {% if not schoolReportCard.isValidated %}style="color: red; font-weight: bold;"{% endif %}>
<td class="text-center">
{% if not report_card.schoolYearPeriode.isClosed %}
<input type="checkbox" class="check-elt" value="{{ schoolReportCard.id }}" onclick="javascript:checkElt()">
{% endif %}
</td>
<td>{{ schoolReportCard.name }}</td>
<td>{{ schoolReportCard.classroom }}</td>
<td>{{ schoolReportCard.isUnclassified ? 'NC' : schoolReportCard.reportCardAverage|round(2, 'floor')|replace({"." : ","}) }} {{ schoolReportCard.isValidated ? '(Validé)' : '(Brouillon)' }} </td>
<td class="text-center">
<a href="{{ path('school_report_card_edit', {'id': schoolReportCard.id}) }}" target="_blank" class="btn btn-primary btn-sm"><i class="fa fa-edit"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-md-12 mb-4">
<div class="card text-left">
<div class="card-header">Edition</div>
<div class="card-body">
{{ include('school/report_card/_edit_form.html.twig') }}
</div>
</div>
</div>
</div>
{# Modal sélection de classe pour l'impression des bulletins modal-lg #}
<div class="modal fade" id="modalImpression" tabindex="-1" role="dialog" aria-labelledby="modalImpressionLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalImpressionLabel"><i class="fa fa-print"></i> Imprimer les bulletins</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Fermer">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="selectClassroom">Classe <small class="text-muted">(laisser vide pour toutes les classes du niveau)</small></label>
<select id="selectClassroom" class="form-control">
<option value="">— Toutes les classes —</option>
{% for classroom in report_card.level.settingClassrooms %}
{% if classroom.schoolYear == report_card.schoolYear %}
<option value="{{ classroom.id }}">{{ classroom.label }}</option>
{% endif %}
{% endfor %}
</select>
</div>
</div>
<div class="modal-footer flex-wrap gap-1">
{% if app.user.establishment.type == 'PRESCOLAIRE-PRIMAIRE' %}
<a id="btnMaternelle" href="{{ path('report_card_maternelle_print', {'id': report_card.id}) }}" class="btn btn-dark"><i class="fa fa-print"></i> Maternelle</a>
<a id="btnBilanMaternelle" href="{{ path('report_card_last_maternelle_print', {'id': report_card.id}) }}" class="btn btn-info"><i class="fa fa-print"></i> Bilan Maternelle</a>
<a id="btnPrimaire" href="{{ path('report_card_print', {'id': report_card.id}) }}" class="btn btn-dark"><i class="fa fa-print"></i> Primaire</a>
<a id="btnBilanPrimaire" href="{{ path('report_card_last_print', {'id': report_card.id}) }}" class="btn btn-info"><i class="fa fa-print"></i> Bilan Primaire</a>
{% else %}
<a id="btnImprimer" href="{{ path('report_card_print', {'id': report_card.id}) }}" class="btn btn-dark"><i class="fa fa-print"></i> Imprimer</a>
<a id="btnDernierBulletin" href="{{ path('report_card_last_print', {'id': report_card.id}) }}" class="btn btn-info"><i class="fa fa-print"></i> Dernier bulletin</a>
{% endif %}
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
</div>
</div>
</div>
</div>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script>
{% if not report_card.schoolYearPeriode.isClosed %}
$(document).ready(function () {
setInterval(function () {
{% if report_card.isValidated %}
//computeRank();
//computeAnnualRank();
{% else %}
//computeAverage();
{% endif %}
//computeAnnualReportCardAverage();
//computeAnnualMatterAverage();
}, 360000);
})
{% endif %}
/*function computeConductAverage() {
path = '{{ path('report_card_compute_conduct_average', {'id': report_card.id}) }}';
axios.get(path, {
params: {}
}).then(function (response) {
if(response.data.code == 200){
console.log(response.data);
computeAverage();
}else{
}
});
}*/
function computeAnnualMatterAverage() {
path = '{{ path('report_card_compute_annual_matter_average', {'id': report_card.id}) }}';
axios.get(path, {
params: {}
}).then(function (response) {
console.log(response.data);
});
}
function computeAnnualRank() {
$('.loader').addClass('is-active');
path = '{{ path('report_card_compute_annual_rank', {'id': report_card.id}) }}';
axios.get(path, {
params: {}
}).then(function (response) {
console.log(response.data);
$('.loader').removeClass('is-active');
location.reload();
});
}
function computeAnnualReportCardAverage() {
$('.loader').addClass('is-active');
path = '{{ path('report_card_compute_annual_report_card_average', {'id': report_card.id}) }}';
axios.get(path, {
params: {}
}).then(function (response) {
if(response.data.code == 200){
computeAnnualMatterAverage();
}
console.log(response.data);
$('.loader').removeClass('is-active');
location.reload();
});
}
function computeAverage() {
$('.loader').addClass('is-active');
path = '{{ path('report_card_compute_average', {'id': report_card.id}) }}';
axios.get(path, {
params: {}
}).then(function (response) {
if(response.data.code == 200){
console.log(response.data);
computeMinMaxAverage();
computeLevelMaxMinAverage();
$('.loader').removeClass('is-active');
location.reload();
}else{
$('.loader').removeClass('is-active');
location.reload();
}
});
}
function computeRank() {
$('.loader').addClass('is-active');
path = '{{ path('report_card_compute_rank', {'id': report_card.id}) }}';
axios.get(path, {
params: {}
}).then(function (response) {
$('.loader').removeClass('is-active');
console.log(response.data);
location.reload();
});
}
function computeMinMaxAverage() {
path = '{{ path('report_card_compute_min_max_average', {'id': report_card.id}) }}';
axios.get(path, {
params: {}
}).then(function (response) {
console.log(response.data);
});
}
function computeLevelMaxMinAverage() {
path = '{{ path('report_card_compute_level_average', {'id': report_card.id}) }}';
axios.get(path, {
params: {}
}).then(function (response) {
if(response.data.code == 200){
console.log(response.data);
}else{
}
console.log(response.data);
});
}
/**
* Calculer les moyennes des élèves par matière
*/
function computeSchoolAverageReportCards() {
$('.loader').addClass('is-active');
axios.get('{{ path('compute_school_average_report_cards', {'id': report_card.id}) }}', {
params: {}
}).then(function (response) {
if(response.data.code == 200){
computeGeneralAverage();
console.log(response.data);
$('.loader').removeClass('is-active');
location.reload();
}else{
$('.loader').removeClass('is-active');
location.reload();
}
console.log(response.data);
});
}
/**
* Calculer la moyenne générale des élèves
*/
function computeGeneralAverage() {
axios.get('{{ path('compute_general_average', {'id': report_card.id}) }}', {
params: {}
}).then(function (response) {
if(response.data.code == 200){
return true;
}else{
return false;
}
console.log(response.data);
return false;
});
}
/**
* Calculer les moyennes des élèves par matière
*/
function computeStudentRank() {
$('.loader').addClass('is-active');
axios.get('{{ path('compute_student_rank', {'id': report_card.id}) }}', {
params: {}
}).then(function (response) {
if(response.data.code == 200){
console.log(response.data);
$('.loader').removeClass('is-active');
location.reload();
}else{
$('.loader').removeClass('is-active');
location.reload();
}
console.log(response.data);
});
}
</script>
<script>
(function () {
var baseUrls = {
{% if app.user.establishment.type == 'PRESCOLAIRE-PRIMAIRE' %}
btnMaternelle: '{{ path('report_card_maternelle_print', {'id': report_card.id}) }}',
btnBilanMaternelle: '{{ path('report_card_last_maternelle_print', {'id': report_card.id}) }}',
btnPrimaire: '{{ path('report_card_print', {'id': report_card.id}) }}',
btnBilanPrimaire: '{{ path('report_card_last_print', {'id': report_card.id}) }}'
{% else %}
btnImprimer: '{{ path('report_card_print', {'id': report_card.id}) }}',
btnDernierBulletin: '{{ path('report_card_last_print', {'id': report_card.id}) }}'
{% endif %}
};
document.getElementById('selectClassroom').addEventListener('change', function () {
var classroomId = this.value;
Object.keys(baseUrls).forEach(function (id) {
var el = document.getElementById(id);
if (el) {
el.href = classroomId ? baseUrls[id] + '?classroom_id=' + classroomId : baseUrls[id];
}
});
});
})();
</script>
{% endblock %}