Compare commits
No commits in common. "master" and "develop" have entirely different histories.
@ -3,7 +3,6 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\Announcement;
|
use App\Entity\Announcement;
|
||||||
use App\Entity\Employee;
|
|
||||||
use App\Form\AnnouncementType;
|
use App\Form\AnnouncementType;
|
||||||
use App\Repository\AnnouncementRepository;
|
use App\Repository\AnnouncementRepository;
|
||||||
use App\Repository\InternApplicationRepository;
|
use App\Repository\InternApplicationRepository;
|
||||||
@ -77,13 +76,17 @@ final class AnnouncementController extends AbstractController
|
|||||||
#[Route('/new', name: 'app_announcement_new', methods: ['GET', 'POST'])]
|
#[Route('/new', name: 'app_announcement_new', methods: ['GET', 'POST'])]
|
||||||
public function new(Request $request,): Response
|
public function new(Request $request,): Response
|
||||||
{
|
{
|
||||||
$user = $this->getUser();
|
/*$user = $this->getUser();
|
||||||
|
|
||||||
if (!$user instanceof Employee) {
|
if (in_array('ROLE_EMPLOYEE', $user->getRoles())) {
|
||||||
$this->addFlash('error', "Vous n'etes pas autorisé à faire cette action.");
|
$company = $user->getCompany();
|
||||||
return $this->redirectToRoute('app_index');
|
|
||||||
}
|
if (!$company)
|
||||||
$company = $user->getCompany();
|
{
|
||||||
|
echo "Compétez votre profile avant de créer une annonce";
|
||||||
|
$this->redirectToRoute('app_user_edit',['id' => $user->getId(),]);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
$announcement = new Announcement();
|
$announcement = new Announcement();
|
||||||
$form = $this->createForm(AnnouncementType::class, $announcement);
|
$form = $this->createForm(AnnouncementType::class, $announcement);
|
||||||
@ -92,7 +95,6 @@ final class AnnouncementController extends AbstractController
|
|||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$announcement->setCreationDate(new \DateTime());
|
$announcement->setCreationDate(new \DateTime());
|
||||||
$announcement->setStatus('notVerified');
|
$announcement->setStatus('notVerified');
|
||||||
$announcement->setCompany($company);
|
|
||||||
$this->entityManager->persist($announcement);
|
$this->entityManager->persist($announcement);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
@ -102,7 +104,6 @@ final class AnnouncementController extends AbstractController
|
|||||||
return $this->render('announcement/new.html.twig', [
|
return $this->render('announcement/new.html.twig', [
|
||||||
'announcement' => $announcement,
|
'announcement' => $announcement,
|
||||||
'form' => $form,
|
'form' => $form,
|
||||||
'company' => $company,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,10 +99,8 @@ class InternFavoriteController extends AbstractController
|
|||||||
public function addFavorite(Announcement $announcement,): Response
|
public function addFavorite(Announcement $announcement,): Response
|
||||||
{
|
{
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
if (!$user instanceof Intern) {
|
|
||||||
throw new AccessDeniedHttpException('Seuls les stagiaires peuvent ajouter aux favoris.');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Vérifier si l'intern a déjà ce favori
|
||||||
$existingFavorite = $this->entityManager->getRepository(InternFavorite::class)->findOneBy([
|
$existingFavorite = $this->entityManager->getRepository(InternFavorite::class)->findOneBy([
|
||||||
'announcement' => $announcement,
|
'announcement' => $announcement,
|
||||||
'intern' => $user,
|
'intern' => $user,
|
||||||
|
@ -13,7 +13,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
class ProfileController extends AbstractController
|
class ProfileController extends AbstractController
|
||||||
@ -51,19 +50,12 @@ class ProfileController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('profile/{id}/edit', name: 'app_profile_edit', methods: ['GET', 'POST'])]
|
#[Route('profile/{id}/edit', name: 'app_profile_edit', methods: ['GET', 'POST'])]
|
||||||
public function edit(Request $request, UserApp $userApp, UserPasswordHasherInterface $passwordHasher): Response
|
public function edit(Request $request, UserApp $userApp,): Response
|
||||||
{
|
{
|
||||||
$form = $this->createForm(UserAppType::class, $userApp);
|
$form = $this->createForm(UserAppType::class, $userApp);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$plainPassword = $form->get('password')->getData();
|
|
||||||
|
|
||||||
if (!empty($plainPassword)) {
|
|
||||||
$hashedPassword = $passwordHasher->hashPassword($userApp, $plainPassword);
|
|
||||||
$userApp->setPassword($hashedPassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
return $this->redirectToRoute('app_profile', [], Response::HTTP_SEE_OTHER);
|
return $this->redirectToRoute('app_profile', [], Response::HTTP_SEE_OTHER);
|
||||||
|
@ -4,6 +4,7 @@ namespace App\Form;
|
|||||||
|
|
||||||
use App\Entity\Announcement;
|
use App\Entity\Announcement;
|
||||||
use App\Entity\Company;
|
use App\Entity\Company;
|
||||||
|
use App\Entity\Status;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
@ -17,6 +18,10 @@ class AnnouncementType extends AbstractType
|
|||||||
$builder
|
$builder
|
||||||
->add('title')
|
->add('title')
|
||||||
->add('description')
|
->add('description')
|
||||||
|
->add('company', EntityType::class, [
|
||||||
|
'class' => Company::class,
|
||||||
|
'choice_label' => 'name',
|
||||||
|
])
|
||||||
->add('date', TextType::class, [
|
->add('date', TextType::class, [
|
||||||
'label' => 'Date de stage',
|
'label' => 'Date de stage',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
@ -4,7 +4,6 @@ namespace App\Form;
|
|||||||
|
|
||||||
use App\Entity\UserApp;
|
use App\Entity\UserApp;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
@ -14,19 +13,12 @@ class UserAppType extends AbstractType
|
|||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('nickname')
|
->add('nickname')
|
||||||
|
->add('password')
|
||||||
->add('firstName')
|
->add('firstName')
|
||||||
->add('lastName')
|
->add('lastName')
|
||||||
->add('tel')
|
->add('tel')
|
||||||
->add('address')
|
->add('address')
|
||||||
->add('mail')
|
->add('mail')
|
||||||
->add('password', PasswordType::class, [
|
|
||||||
'mapped' => false,
|
|
||||||
'required' => false,
|
|
||||||
'attr' => [
|
|
||||||
'autocomplete' => 'new-password'
|
|
||||||
],
|
|
||||||
'label' => 'Nouveau mot de passe',
|
|
||||||
])
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,17 +43,15 @@
|
|||||||
<span class="text-green-500 font-semibold">Validée</span>
|
<span class="text-green-500 font-semibold">Validée</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if 'ROLE_INTERN' in app.user.roles %}
|
<form method="post" action="{{ path('app_favorite_toggle', {id: announcement.id}) }}">
|
||||||
<form method="post" action="{{ path('app_favorite_toggle', {id: announcement.id}) }}">
|
<button type="submit" class="text-xl">
|
||||||
<button type="submit" class="text-xl">
|
{% if announcement.id in favorites %}
|
||||||
{% if announcement.id in favorites %}
|
⭐
|
||||||
⭐
|
{% else %}
|
||||||
{% else %}
|
☆
|
||||||
☆
|
{% endif %}
|
||||||
{% endif %}
|
</button>
|
||||||
</button>
|
</form>
|
||||||
</form>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2 class="text-3xl font-semibold mb-2">{{ announcement.title }}</h2>
|
<h2 class="text-3xl font-semibold mb-2">{{ announcement.title }}</h2>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="container mx-auto p-6">
|
<div class="container mx-auto p-6">
|
||||||
<h1 class="text-3xl font-bold mb-4">Créer une Annonce pour {{ company.name }}</h1>
|
<h1 class="text-3xl font-bold mb-4">Créer une Annonce</h1>
|
||||||
|
|
||||||
{{ form_start(form) }}
|
{{ form_start(form) }}
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
@ -19,6 +19,10 @@
|
|||||||
{{ form_label(form.date) }}
|
{{ form_label(form.date) }}
|
||||||
{{ form_widget(form.date, {'attr': {'class': 'form-input w-full p-2 rounded border'}}) }}
|
{{ form_widget(form.date, {'attr': {'class': 'form-input w-full p-2 rounded border'}}) }}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-4">
|
||||||
|
{{ form_label(form.company) }}
|
||||||
|
{{ form_widget(form.company, {'attr': {'class': 'form-input w-full p-2 rounded border'}}) }}
|
||||||
|
</div>
|
||||||
<button type="submit" class="bg-teal-500 text-white px-4 py-2 rounded">
|
<button type="submit" class="bg-teal-500 text-white px-4 py-2 rounded">
|
||||||
Créer l'annonce
|
Créer l'annonce
|
||||||
</button>
|
</button>
|
||||||
|
@ -59,16 +59,6 @@
|
|||||||
<i class="fas fa-paper-plane"></i> Candidater à cette offre
|
<i class="fas fa-paper-plane"></i> Candidater à cette offre
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<!-- Vérifier si c'est un favori -->
|
|
||||||
<form method="post" action="{{ path(isFavorite ? 'app_favorite_remove' : 'app_favorite_add', {id: announcement.id}) }}">
|
|
||||||
<button type="submit" class="text-yellow-500">
|
|
||||||
{% if isFavorite %}
|
|
||||||
⭐ Retirer des favoris
|
|
||||||
{% else %}
|
|
||||||
☆ Ajouter aux favoris
|
|
||||||
{% endif %}
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if 'ROLE_ADMIN' in app.user.roles %}
|
{% if 'ROLE_ADMIN' in app.user.roles %}
|
||||||
@ -88,7 +78,18 @@
|
|||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<!-- Vérifier si c'est un favori -->
|
||||||
|
<form method="post" action="{{ path(isFavorite ? 'app_favorite_remove' : 'app_favorite_add', {id: announcement.id}) }}">
|
||||||
|
<button type="submit" class="text-yellow-500">
|
||||||
|
{% if isFavorite %}
|
||||||
|
⭐ Retirer des favoris
|
||||||
|
{% else %}
|
||||||
|
☆ Ajouter aux favoris
|
||||||
|
{% endif %}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Bouton de retour à la liste -->
|
<!-- Bouton de retour à la liste -->
|
||||||
|
@ -16,11 +16,7 @@
|
|||||||
{{ form_row(form.tel, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
{{ form_row(form.tel, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
||||||
{{ form_row(form.address, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
{{ form_row(form.address, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
||||||
{{ form_row(form.mail, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
{{ form_row(form.mail, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
||||||
{{ form_row(form.password, {
|
{{ form_row(form.password, {'attr': {'class': 'w-full p-3 border rounded-md'}}) }}
|
||||||
'attr': {'class': 'w-full p-3 border rounded-md'},
|
|
||||||
'label': 'Mot de passe (laissez vide pour ne pas changer)',
|
|
||||||
}) }}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
{{ form_widget(form) }}
|
{{ form_widget(form) }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user