2023-12-22 15:31:30 +01:00
|
|
|
{# Formulaire ajout ou modification de justificatif
|
|
|
|
Si justif, edit #}
|
2023-12-12 03:05:31 +01:00
|
|
|
{% extends "sco_page.j2" %}
|
|
|
|
{% import 'wtf.j2' as wtf %}
|
|
|
|
|
|
|
|
{% block styles %}
|
|
|
|
{{super()}}
|
|
|
|
<link rel="stylesheet" href="{{scu.STATIC_DIR}}/css/assiduites.css">
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
{% block app_content %}
|
|
|
|
<style>
|
|
|
|
form#ajout-justificatif-etud {
|
|
|
|
margin-bottom: 24px;
|
|
|
|
}
|
|
|
|
form#ajout-justificatif-etud > div {
|
|
|
|
margin-bottom: 16px;
|
|
|
|
}
|
2024-01-21 18:07:56 +01:00
|
|
|
fieldset > div {
|
|
|
|
margin-bottom: 12px;
|
|
|
|
}
|
2023-12-22 15:59:24 +01:00
|
|
|
div.fichiers {
|
|
|
|
margin-top: 16px;
|
|
|
|
margin-bottom: 32px;
|
|
|
|
}
|
|
|
|
div.fichiers ul {
|
|
|
|
list-style-type: none;
|
|
|
|
}
|
|
|
|
span.suppr_fichier_just {
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
2023-12-12 03:05:31 +01:00
|
|
|
div.submit {
|
|
|
|
margin-top: 12px;
|
|
|
|
}
|
|
|
|
div.submit > input {
|
|
|
|
margin-right: 16px;
|
|
|
|
}
|
2024-01-21 18:07:56 +01:00
|
|
|
.info-saisie {
|
|
|
|
margin-top: 12px;
|
|
|
|
margin-bottom: 12px;
|
|
|
|
font-style: italic;
|
|
|
|
}
|
2023-12-12 03:05:31 +01:00
|
|
|
</style>
|
|
|
|
<div class="tab-content">
|
2024-01-21 18:07:56 +01:00
|
|
|
<h2>{{title|safe}}</h2>
|
|
|
|
|
|
|
|
{% if justif %}
|
|
|
|
<div class="info-saisie">
|
2024-01-22 17:01:01 +01:00
|
|
|
Saisie par {{justif.user.get_prenomnom() if justif.user else "inconnu"}}
|
|
|
|
le {{justif.entry_date.strftime("%d/%m/%Y à %H:%M") if justif.entry_date else "?"}}
|
2024-01-21 18:07:56 +01:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
2023-12-12 03:05:31 +01:00
|
|
|
|
|
|
|
<section class="justi-form page">
|
|
|
|
|
2023-12-14 20:50:27 +01:00
|
|
|
{% for err_msg in form.error_messages %}
|
|
|
|
<div class="wtf-error-messages">
|
|
|
|
{{ err_msg }}
|
|
|
|
</div>
|
|
|
|
{% endfor %}
|
|
|
|
|
2023-12-16 22:53:02 +01:00
|
|
|
<form id="ajout-justificatif-etud" method="post" enctype="multipart/form-data">
|
2023-12-12 03:05:31 +01:00
|
|
|
<fieldset>
|
|
|
|
{{ form.hidden_tag() }}
|
|
|
|
{# Dates et heures #}
|
|
|
|
<div class="dates-heures">
|
|
|
|
{{ form.date_debut.label }} : {{ form.date_debut }}
|
|
|
|
de {{ form.heure_debut }} à {{ form.heure_fin }}
|
|
|
|
<span class="help">laisser les heures vides pour indiquer la journée entière</span>
|
|
|
|
{{ render_field_errors(form, 'date_debut') }}
|
|
|
|
{{ render_field_errors(form, 'heure_debut') }}
|
|
|
|
{{ render_field_errors(form, 'heure_fin') }}
|
|
|
|
|
|
|
|
<div>
|
|
|
|
{{ form.date_fin.label }} : {{ form.date_fin }}
|
|
|
|
<span class="help">si le jour de fin est différent,
|
|
|
|
les heures seront ignorées (journées complètes)</span>
|
|
|
|
{{ render_field_errors(form, 'date_fin') }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{# Etat #}
|
|
|
|
<div>
|
|
|
|
<div>{{ form.etat.label }}</div>
|
|
|
|
{{ form.etat() }}
|
|
|
|
{{ render_field_errors(form, 'etat') }}
|
|
|
|
</div>
|
|
|
|
{# Raison #}
|
|
|
|
<div>
|
2024-01-21 18:07:56 +01:00
|
|
|
{% if (not justif) or can_view_justif_detail %}
|
|
|
|
<div>{{ form.raison.label }}</div>
|
|
|
|
{{ form.raison() }}
|
|
|
|
{{ render_field_errors(form, 'raison') }}
|
|
|
|
<div class="help">La raison sera visible aux utilisateurs ayant le droit
|
|
|
|
<tt>AbsJustifView</tt> et à celui ayant déposé le justificatif
|
2024-01-31 14:27:08 +01:00
|
|
|
{%- if justif and justif.user %} (<b>{{justif.user.get_prenomnom()}}</b>){%- endif -%}.
|
2024-01-21 18:07:56 +01:00
|
|
|
</div>
|
|
|
|
{% else %}
|
|
|
|
<div class="unauthorized">raison confidentielle</div>
|
|
|
|
{% endif %}
|
2023-12-12 03:05:31 +01:00
|
|
|
</div>
|
2023-12-22 15:59:24 +01:00
|
|
|
<div class="fichiers">
|
|
|
|
{# Liste des fichiers existants #}
|
|
|
|
{% if justif and nb_files > 0 %}
|
|
|
|
<div><b>{{nb_files}} fichiers justificatifs déposés
|
|
|
|
{% if filenames|length < nb_files %}
|
2024-01-21 18:07:56 +01:00
|
|
|
, dont {{filenames|length}} vous {{'sont accessibles' if filenames|length > 1 else 'est accessible'}}
|
2023-12-22 15:59:24 +01:00
|
|
|
{% endif %}
|
|
|
|
</b>
|
|
|
|
</div>
|
2023-12-22 15:31:30 +01:00
|
|
|
<ul>
|
|
|
|
{% for filename in filenames %}
|
|
|
|
<li><span data-justif_id="{{justif.id}}" class="suppr_fichier_just"
|
|
|
|
>{{scu.icontag("delete_img", alt="supprimer", title="Supprimer")|safe}}</span>
|
|
|
|
{{filename}}</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
2023-12-22 15:59:24 +01:00
|
|
|
{% endif %}
|
|
|
|
{# Ajout fichier(s) justificatif(s) #}
|
|
|
|
<div>
|
|
|
|
<div>{{ form.fichiers.label }}</div>
|
|
|
|
{{ form.fichiers() }}
|
|
|
|
{{ render_field_errors(form, 'fichiers') }}
|
|
|
|
</div>
|
2023-12-12 03:05:31 +01:00
|
|
|
</div>
|
2024-01-30 11:47:57 +01:00
|
|
|
{# Date dépôt #}
|
|
|
|
{{ form.entry_date.label }} : {{ form.entry_date }} à {{ form.entry_time }}
|
|
|
|
<span class="help" style="margin-left: 12px;">laisser vide pour date courante</span>
|
2023-12-12 03:05:31 +01:00
|
|
|
{{ render_field_errors(form, 'entry_date') }}
|
2024-01-21 18:07:56 +01:00
|
|
|
|
2023-12-12 03:05:31 +01:00
|
|
|
{# Submit #}
|
|
|
|
<div class="submit">
|
|
|
|
{{ form.submit }} {{ form.cancel }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
</section>
|
2023-12-22 15:31:30 +01:00
|
|
|
{% if tableau %}
|
2023-12-12 03:05:31 +01:00
|
|
|
<section class="assi-liste">
|
|
|
|
{{tableau | safe }}
|
|
|
|
</section>
|
2023-12-22 15:31:30 +01:00
|
|
|
{% endif %}
|
2023-12-12 03:05:31 +01:00
|
|
|
</div>
|
|
|
|
|
2023-12-23 13:53:02 +01:00
|
|
|
{% include "assiduites/explication_etats_justifs.j2" %}
|
|
|
|
|
2023-12-12 03:05:31 +01:00
|
|
|
{% endblock app_content %}
|
|
|
|
|
|
|
|
{% block scripts %}
|
|
|
|
{{ super() }}
|
|
|
|
<script src="{{scu.STATIC_DIR}}/js/assiduites.js"></script>
|
|
|
|
<script src="{{scu.STATIC_DIR}}/js/etud_info.js"></script>
|
2024-01-16 12:36:20 +01:00
|
|
|
{% include "sco_timepicker.j2" %}
|
2023-12-22 15:31:30 +01:00
|
|
|
<script>
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
// Suppression d'un fichier justificatif
|
|
|
|
function delete_file(justif_id, fileName, liElement) {
|
|
|
|
// Construct the URL
|
|
|
|
var url = "{{url_for('apiweb.justif_remove', justif_id=-1, scodoc_dept=g.scodoc_dept)}}".replace('-1', justif_id);
|
|
|
|
|
|
|
|
payload = {
|
|
|
|
"remove": "list",
|
|
|
|
"filenames" : [ fileName ],
|
|
|
|
}
|
|
|
|
// Send API request
|
|
|
|
fetch(url, {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Accept': 'application/json',
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(payload)
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
if (response.ok) {
|
|
|
|
// Hide the <li> element on successful deletion
|
|
|
|
liElement.style.display = 'none';
|
|
|
|
sco_message("fichier supprimé");
|
|
|
|
} else {
|
|
|
|
// Handle non-successful responses here
|
|
|
|
console.error('Deletion failed:', response.statusText);
|
|
|
|
sco_error_message("erreur lors de la suppression du fichier");
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error('Error:', error);
|
|
|
|
sco_error_message("erreur lors de la suppression du fichier (2)");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add event listeners to all elements with class 'suppr_fichier_just'
|
|
|
|
var deleteButtons = document.querySelectorAll('.suppr_fichier_just');
|
|
|
|
deleteButtons.forEach(function(button) {
|
|
|
|
button.addEventListener('click', function() {
|
|
|
|
// Get the text content of the next sibling node
|
|
|
|
var justif_id = this.dataset.justif_id;
|
|
|
|
var fileName = this.nextSibling.nodeValue.trim();
|
|
|
|
var liElement = this.parentNode; // Get the parent <li> element
|
|
|
|
delete_file(justif_id, fileName, liElement);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
2023-12-12 03:05:31 +01:00
|
|
|
{% endblock scripts %}
|