{% extends 'base_front.html.twig' %}
{% set queryParams = app.request.query.all %}
{% block title %}{{ parent() }} | {{ r.nom }} | {{ ssr.nom }}{% endblock %}
{% macro filter(queryParams) %}
<div class="col-4" id="filterZone">
<input id="searchInput" class="form-control bg-white rounded pl-40" placeholder="Rechercher" {% if queryParams is not empty and queryParams.recherche is defined %} value="{{queryParams.recherche}}" {% endif %}>
<i id="searchBtn" class="toggle-password-alone fa fa-search text-primary" ></i>
{% if queryParams is not empty and queryParams.recherche is defined %}
<i id="resetBtn" class="refresh fa fa-refresh text-danger"></i>
{% endif %}
</div>
{% set options = [
{
'k' : '',
'v' : 'Trier par :'
},
{
'k' : 'titre-croissant',
'v' : 'Titre A-Z'
},
{
'k' : 'titre-decroissant',
'v' : 'Titre Z-A'
},
{
'k' : 'date-croissante',
'v' : 'Date croissante'
},
{
'k' : 'date-decroissante',
'v' : 'Date décroissante'
},
] %}
<div class="col-2">
<select class="bg-white rounded form-control" id="ordonnance">
{% for option in options %}
<option {% if queryParams is not empty and queryParams.ordre is defined and queryParams.ordre == option.k %} selected {% endif %} value="{{option.k}}">{{option.v|raw}}</option>
{% endfor %}
</select>
</div>
{% endmacro %}
{% block h1 %}
{{ ssr.nom }}
{% if app.user and is_granted('ROLE_MODO') %}
<a target="_blank" href="{{ path('app_admin_sous_rubrique_show', {'uuid': ssr.uuid}) }}"><i class="text-danger" data-feather="unlock"></i></a>
{% endif %}
{% endblock %}
{% block ariane %}
<nav class="navigateur" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ path("home") }}">{{ config.titreAccueil }}</a></li>
<li class="breadcrumb-item"><a href="{{ path('rubriques', {slug:r.slug })}}">{{ r.nom }}</a></li>
<li class="breadcrumb-item active" aria-current="page">{{ ssr.nom }}</li>
</ol>
</nav>
{% endblock %}
{% block body %}
{% if app.user %}
{% set co = true %}
{% else %}
{% set co = false %}
{% endif %}
<input type="hidden" value="{{co}}" id="co">
{% set acces = false %}
{% if form.children.parcours.vars.errors is not empty %}
{% set acces = true %}
{% endif %}
{% if form.children.competence.vars.errors is not empty %}
{% set acces = true %}
{% endif %}
{% if form.children.aspiration.vars.errors is not empty %}
{% set acces = true %}
{% endif %}
{% if form.children.nom.vars.errors is not empty %}
{% set acces = true %}
{% endif %}
{% if form.children.prenom.vars.errors is not empty %}
{% set acces = true %}
{% endif %}
{% if form.children.email.vars.errors is not empty %}
{% set acces = true %}
{% endif %}
{% if form.children.direction.vars.errors is not empty %}
{% set acces = true %}
{% endif %}
{% if form.children.grade.vars.errors is not empty %}
{% set acces = true %}
{% endif %}
{% if form.children.cv.vars.errors is not empty %}
{% set acces = true %}
{% endif %}
<input type="hidden" id="acces" value="{{acces}}">
<input type="hidden" id="test" value="{{app.session.get('test')}}">
{% if ssr.phrase %}
<div class="my-4 mx-12 bg-white p-4 rounded ck">{{ ssr.phrase|raw }}</div>
{% endif %}
{% if ssr.srcImg %}
<div class="mx-12">
<img
src="{{ asset('images/sousrubrique/' ~ ssr.srcImg) }}"
{% if ssr.altImg %}
alt="{{ ssr.altImg }}"
{% endif %}
{% if ssr.titleImg %}
title="{{ ssr.titleImg }}"
{% endif %}
class="imgRatio rounded"
>
</div>
{% endif %}
{% if ssr.description %}
<div class="my-4 mx-12 bg-white p-4 rounded ck">{{ ssr.description|raw }}</div>
{% endif %}
{% if app.user %}
<div class="row mx-0 px-0">
<div class="col-md-6">
<div id="zoneGestion">
{% if app.user.cvs|length > 0 %}
{% if app.user.cvs[0].moderate %}
<div class="row" id="gestionCV">
<button type="button" class="btn btn-primary rounded col-md-4 col-12" data-bs-toggle="modal" data-bs-target="#exampleModalAdd">
Modifier mon CV
</button>
<div
class="form-check form-switch mb-0 rounded col-md-4 col-12 btn {% if app.user.cvs[0].statut %} btn-danger {% else %} btn-success {% endif %} "
style=""
id="btnActivation"
>
{% if app.user.cvs[0].statut %} Désactiver {% else %} Activer {% endif %} mon CV
</div>
<span
class="cursorPointer btn btn-danger rounded col-md-4 col-12"
onclick="return confirmDelete(this);"
>
Supprimer mon CV
</span>
</div>
{% else %}
<div class="">
<h4 class="m-0">Votre CV est en cours de modération</h4>
</div>
{% endif %}
{% else %}
<button type="button" class="btn btn-primary rounded" data-bs-toggle="modal" data-bs-target="#exampleModalAdd">
Ajouter mon CV
</button>
{% endif %}
</div>
</div>
{{ _self.filter(queryParams) }}
</div>
{% else %}
<div class="mt-4 mx-12 bg-white p-4 rounded">
<h3 class="text-center">{{ ssr.info }}, {% include '_connexion_bouton.html.twig' with {'contenu': 'connectez-vous', 'class': "lien" } %} ou <a class="lien" href="{{ path('app_register')}}">créez votre compte</a></h3>
</div>
<div class="row justify-content-between mx-0 mt-4">
<div class="col-6"></div>
{{ _self.filter(queryParams) }}
</div>
{% endif %}
{% if items %}
<div id="zoneContent">
{% include "front/_ssr15_cv.html.twig" %}
</div>
{# {% else %}
<h4 class="text-center text-danger fst-italic my-4 mx-12 bg-white p-4 rounded">{{ config.messageDefault }}</h4> #}
{% endif %}
{% if app.user %}
<div class="modal fade" id="exampleModalAdd" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
{{form_start(form)}}
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">
{% if exist %}
Modifier
{% else %}
Ajouter
{% endif %}
votre Curriculum Vitae</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body row">
<div class="row">
{% if exist %}
<div class="col-md-4">
{{ form_row(form.nom) }}
</div>
<div class="col-md-4">
{{ form_row(form.prenom) }}
</div>
<div class="col-md-4">
{{ form_row(form.email) }}
</div>
{% else %}
<div class="col-md-4">
{{ form_row(form.nom, {'attr' : {'value' : app.user.nom}}) }}
</div>
<div class="col-md-4">
{{ form_row(form.prenom, {'attr' : {'value' : app.user.prenom}}) }}
</div>
<div class="col-md-4">
{{ form_row(form.email, {'attr' : {'value' : app.user.email}}) }}
</div>
{% endif %}
<div class="col-md-6">
{{ form_row(form.grade) }}
</div>
<div class="col-md-6">
{{ form_row(form.direction) }}
</div>
</div>
{{ form_row(form.parcours) }}
{{ form_row(form.competence) }}
{{ form_row(form.aspiration) }}
{{ form_row(form.cv) }}
{% if cv.cv %}
<a target="_blank" href="{{ path('app_cv_pdf', {uuid: cv.uuid}) }}" title="CV">
<i class="text-danger" data-feather="file"></i>
</a>
{% endif %}
<div class="row p-4 mt-3 mx-0 align-items-center">
<h4 class="text-center py-2">Photo (facultatif)</h4>
<hr class="py-3">
<div class="col-md-6">
{{ form_row(form.photo) }}
</div>
<div class="col-md-6">
<div class="row justify-content-center" id="zone"></div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" title="En annulant, vous réinitialiserez le formulaire" class="btn btn-danger rounded" data-bs-dismiss="modal">Annuler</button>
<button type="submit" class="btn btn-primary rounded">
{% if exist %}
Modifier
{% else %}
Ajouter
{% endif %}
</button>
</div>
</div>
{{form_end(form)}}
</div>
</div>
{% endif %}
{% endblock %}
{% block javascripts %}
<script src="{{ asset('js/cardShow.js') }}"></script>
<script>
function loadFile(event)
{
zone.textContent = "";
let image = document.createElement("img");
image.setAttribute("src", URL.createObjectURL(event.target.files[0]) );
image.setAttribute("class", "img60auto" );
zone.append(image);
let data = {
"token" : URL.createObjectURL(event.target.files[0])
}
let url = "{{ path('change_test') }}";
$.ajax({
method: 'post',
dataType: 'json',
url : url,
data : data,
success: function (data)
{
},
error: function()
{
alert('error');
}
});
}
$('body').on('click', '#btnActivation', function() {
console.log('test');
let data = {
}
let url = "{{ path('change_front_statut_cv') }}";
$.ajax({
method: 'post',
dataType: 'json',
url : url,
data : data,
success: function (data)
{
if(data.response){
const btnActivation = document.getElementById('btnActivation');
if (data.statut) {
btnActivation.classList.add('btn-danger');
btnActivation.classList.remove('btn-success');
const zoneCv = document.getElementById('zoneCv');
zoneCv.innerHTML = data.test + zoneCv.innerHTML;
btnActivation.textContent = "Désactiver mon CV";
} else {
btnActivation.classList.remove('btn-danger');
btnActivation.classList.add('btn-success');
$('#cv' + data.token).remove();
btnActivation.textContent = "Activer mon CV";
}
}
},
error: function()
{
alert('error');
}
});
});
let acces = $("#acces").val();
let test = $("#test").val();
if(acces){
var myModal = new bootstrap.Modal(document.getElementById('exampleModalAdd'))
myModal.show();
zone.textContent = "";
let image = document.createElement("img");
image.setAttribute("src", test );
image.setAttribute("class", "img60auto" );
zone.append(image);
}
function confirmDelete(element) {
var confirmDelete = confirm('Êtes-vous sûr de vouloir supprimer votre CV ?');
if (confirmDelete) {
let data = {
}
let url = "{{ path('supprimer_front_cv') }}";
$.ajax({
method: 'post',
dataType: 'json',
url : url,
data : data,
success: function (data)
{
if(data.response){
$('#cv' + data.token).remove();
const gestionCVElement = document.getElementById('gestionCV');
if (gestionCVElement) {
gestionCVElement.remove();
}
const addButton = document.createElement('button');
addButton.setAttribute('type', 'button');
addButton.setAttribute('class', 'btn btn-primary rounded');
addButton.setAttribute('data-bs-toggle', 'modal');
addButton.setAttribute('data-bs-target', '#exampleModalAdd');
addButton.textContent = 'Ajouter';
const zoneGestion = document.getElementById('zoneGestion');
zoneGestion.appendChild(addButton);
}
},
error: function()
{
alert('Une erreur est survenue, veuillez recommencer');
}
});
}
}
$("#searchBtn").click(function() {
updateData();
});
$("#ordonnance").change(function() {
updateData();
});
$('body').on('click', '#resetBtn', function() {
$("#searchInput").val('');
$('#ordonnance').prop('selectedIndex', 0);
updateData();
});
function updateData(){
var inputValue = $("#searchInput").val();
const selectElement = document.querySelector("#ordonnance");
const selectedValue = selectElement.value;
const Params = new URLSearchParams();
if(inputValue){
Params.append('recherche', inputValue);
}
if(selectedValue){
Params.append('ordre', selectedValue);
}
const Url = new URL(window.location.href);
fetch(Url.pathname + "?" + Params.toString() + "&ajax=xxx", {
headers: {
"X-Requested-With": "XMLHttpRequest"
}
}).then(response => {
return response.json()
}).then(data => {
const content = document.querySelector("#zoneContent");
content.innerHTML = data.content;
history.pushState({}, null, Url.pathname + "?" + Params.toString());
var elements = document.querySelectorAll(".taille");
sizeCard(elements);
if ($('#resetBtn').length > 0) {
$('#resetBtn').remove();
}
if (inputValue){
$('#filterZone').each(function() {
$(this).append('<i id="resetBtn" class="refresh fa fa-refresh text-danger"></i>');
});
}
}).catch(e => alert(e));
}
var coElement = document.getElementById('co').value;
if (coElement) {
var cancelButton = document.querySelector('#exampleModalAdd .btn-danger');
cancelButton.addEventListener('click', function () {
var form = document.querySelector('#exampleModalAdd form');
form.reset();
});
}
var elements = document.querySelectorAll(".taille");
sizeCard(elements);
$(window).on('resize', function() {
var elements = document.querySelectorAll(".taille");
sizeCard(elements);
});
</script>
{% endblock %}