Skip to content
Snippets Groups Projects
Commit 92b2b8fe authored by SAVERGNE Yvan's avatar SAVERGNE Yvan
Browse files

Merge branch 'master' into 'main'

Master

See merge request !66
parents 8c30b85d f053c5bb
Branches
No related tags found
1 merge request!66Master
......@@ -316,7 +316,7 @@ button {
}
.btn-like {
background-color: #ffffff;
background-color: transparent;
border: 0px #ccc;
padding: 5px 10px;
cursor: pointer;
......
......@@ -22,4 +22,8 @@ filtmes_annonces_filtres:
filtmes_annonces_repondues_filtres:
path: /mes_annonces_repondues/filtres/
controller: App\Controller\ModifUserController::mesAnnoncesReponduesFiltres
\ No newline at end of file
controller: App\Controller\ModifUserController::mesAnnoncesReponduesFiltres
filtmes_annonces_likees_filtres:
path: /mes_annonces_likees/filtres/
controller: App\Controller\ModifUserController::mesAnnoncesLikeesFiltres
\ No newline at end of file
......@@ -7,15 +7,27 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\Persistence\ManagerRegistry;
use App\Entity\Notification;
use App\Entity\Prestations;
use DateTime;
class HomePageController extends AbstractController
{
private $doctrine;
public function __construct(ManagerRegistry $doctrine) {
$this->doctrine = $doctrine;
}
#[Route('', name: 'app_home_page')]
public function index(Request $request, PrestationsRepository $prestationsRepository): Response
{
$prestations = $prestationsRepository->findFilteredPrestations();
$user = $this->getUser();
return $this->render('home_page/index.html.twig', [
'prestations' => $prestations
'prestations' => $prestations,
'user' => $user
]);
}
......@@ -30,9 +42,39 @@ class HomePageController extends AbstractController
if ($prixMax == '') $prixMax = null;
$prestations = $prestationsRepository->findFilteredPrestations($keyword, $prixMin, $prixMax, $typePrestation);
$user = $this->getUser();
return $this->render('home_page/index.html.twig', [
'prestations' => $prestations
'prestations' => $prestations,
'user' => $user
]);
}
#[Route('/aimer/{id}', name: 'app_like_home_page')]
public function aimerPrestation($id,PrestationsRepository $prestationsRepository): Response
{
$user = $this->getUser();
$entityManager = $this->doctrine->getManager();
$prestation = $entityManager->getRepository(Prestations::class)->find($id);
if ($user != null) {
$notification = new Notification();
$notification->setDescription($user->getLogin(). " a aimé votre annonce " . $prestation->getTitre());
$notification->setType("Annonce aimée");
$notification->setDate(new DateTime());
$notification->setUserId($prestation->getProprietaire());
$this->doctrine->getManager()->persist($notification);
$prestation->setIdClient(null);
} else return $this->redirectToRoute('app_login');
if ($user->getPrestationsAimees()->contains($prestation)) {
$user->removePrestationsAimee($prestation);
$prestation->removeUtilisateursAimant($user);
} else {
$user->addPrestationsAimee($prestation);
$prestation->addUtilisateursAimant($user);
}
$entityManager->flush();
return $this->redirectToRoute('app_home_page');
}
}
\ No newline at end of file
......@@ -101,7 +101,7 @@ class ModifUserController extends AbstractController
}
#[Route('/mettreCompteSommeil/{errorType}', name: 'app_compte_sommeil')]
public function mettreCompteSommeil(Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, $errorType): Response
public function mettreCompteSommeil(Request $request, EntityManagerInterface $entityManager, $errorType): Response
{
$user = $this->getUser();
$form = $this->createForm(CompteSommeilFormType::class, $user);
......@@ -159,7 +159,7 @@ class ModifUserController extends AbstractController
}
#[Route('/mes_annonces', name: 'app_mes_annonces')]
public function mesAnnonces(Request $request, EntityManagerInterface $entityManager, PrestationsRepository $prestationsRepository): Response
public function mesAnnonces(EntityManagerInterface $entityManager, PrestationsRepository $prestationsRepository): Response
{
$user = $this->getUser();
......@@ -175,11 +175,33 @@ class ModifUserController extends AbstractController
'prets' => $prets,
'services' => $services,
'prestations' => $prestations,
'publiee' => true,
'reservee' => false,
'likee' => false,
]);
}
#[Route('/mes_likes', name: 'app_mes_likes')]
public function mesLikes(EntityManagerInterface $entityManager): Response
{
$prestations = $this->getUser()->getPrestationsAimees();
$entrees = $entityManager->getRepository(Prestations::class)->findAll();
$prets = $entityManager->getRepository(Pret::class)->findAll();
$services = $entityManager->getRepository(Services::class)->findAll();
return $this->render('security/mes_annonces_likes.html.twig', [
'entrees' => $entrees,
'prets' => $prets,
'services' => $services,
'prestations' => $prestations,
'publiee' => false,
'reservee' => false,
'likee' => true,
]);
}
#[Route('/mes_annonces_repondues', name: 'app_mes_annonces_repondues')]
public function mesAnnoncesRepondues(Request $request, EntityManagerInterface $entityManager, PrestationsRepository $prestationsRepository): Response
public function mesAnnoncesRepondues(EntityManagerInterface $entityManager, PrestationsRepository $prestationsRepository): Response
{
$user = $this->getUser();
......@@ -195,6 +217,9 @@ class ModifUserController extends AbstractController
'prets' => $prets,
'services' => $services,
'prestations' => $prestations,
'publiee' => false,
'reservee' => true,
'likee' => false,
]);
}
......@@ -231,6 +256,9 @@ class ModifUserController extends AbstractController
'prets' => $prets,
'services' => $services,
'prestations' => $res,
'publiee' => true,
'reservee' => false,
'likee' => false,
]);
}
......@@ -262,11 +290,51 @@ class ModifUserController extends AbstractController
$services = $entityManager->getRepository(Services::class)->findAll();
return $this->render('security/mes_annonces_repondues.html.twig', [
'entrees' => $entrees,
'prets' => $prets,
'services' => $services,
'prestations' => $res,
'publiee' => false,
'reservee' => true,
'likee' => false,
]);
}
#[Route('', name: 'mes_annonces_likees_filtres')]
public function mesAnnoncesLikeesFiltres(Request $request, EntityManagerInterface $entityManager, PrestationsRepository $prestationsRepository): Response
{
$user = $this->getUser();
$keyword = $request->query->get('keyword');
$prixMin = $request->query->get('prixMin');
$prixMax = $request->query->get('prixMax');
$typePrestation = $request->query->get('type_prestation');
if ($prixMin == '') $prixMin = null;
if ($prixMax == '') $prixMax = null;
$res = [];
$prestations = $user->getPrestationsAimees();
$prestations2 = $prestationsRepository->findFilteredPrestations($keyword, $prixMin, $prixMax, $typePrestation);
foreach ($prestations as $pres) {
foreach ($prestations2 as $pres2) {
if ($pres === $pres2)
array_push($res,$pres);
}
}
$entrees = $entityManager->getRepository(Prestations::class)->findAll();
$prets = $entityManager->getRepository(Pret::class)->findAll();
$services = $entityManager->getRepository(Services::class)->findAll();
return $this->render('security/mes_annonces.html.twig', [
'controller_name' => 'ModifUserController',
'entrees' => $entrees,
'prets' => $prets,
'services' => $services,
'prestations' => $res,
'publiee' => false,
'reservee' => false,
'likee' => true,
]);
}
......
......@@ -47,6 +47,17 @@
{% if is_granted('ROLE_ADMIN') %}
<p class="tag_litige" id="tag">{{prestation.litiges|length}}</p>
{% endif %}
{% if user and not is_granted ("ROLE_ADMIN") %}
{% if user.id != prestation.proprietaire.id %}
<a href="{{ path('app_like_home_page', {'id': prestation.id}) }}"><button class="btn-like">
{% if user.aimePrestation(prestation) %}
<span class="aime">&#10084;</span>
{% else %}
<span class="non_aime">&#10084;</span>
{% endif %}
</button></a>
{% endif %}
{% endif %}
{% if prestation.getType() == 'Pret' %}
<p class="tag_pret" id="tag">Prêt</p>
......
{% block body %}
<div class="container-recherche">
<form id="filterForm" method="post">
<input class="txt_form" type="text" name="keyword" value="{{ app.request.query.get('keyword') }}" placeholder="Mot-clé">
<input class="txt_form prix" type="number" name="prixMin" value="{{ app.request.query.get('prixMin') }}" placeholder="€ minimum">
<input class="txt_form prix" type="number" name="prixMax" value="{{ app.request.query.get('prixMax') }}" placeholder="€ maximum">
<select class="txt_form" name="type_prestation">
<option value="">Tous les types de prestation</option>
<option value="pret" {% if app.request.query.get('type_prestation') == 'pret' %} selected {% endif %}>Prêts</option>
<option value="service" {% if app.request.query.get('type_prestation') == 'service' %} selected {% endif %}>Services</option>
</select>
<button type="submit" class="btn_recherche">Filtrer</button>
</form>
<script>
document.getElementById("filterForm").addEventListener("submit", function(event) {
event.preventDefault();
var keyword = document.getElementsByName("keyword")[0].value;
var prixMin = document.getElementsByName("prixMin")[0].value;
var prixMax = document.getElementsByName("prixMax")[0].value;
var typePrestation = document.getElementsByName("type_prestation")[0].value;
{% if publiee %}
var url = "../../mes_annonces/filtres/?keyword=" + encodeURIComponent(keyword) + "&prixMin=" + encodeURIComponent(prixMin) + "&prixMax=" + encodeURIComponent(prixMax) + "&type_prestation=" + encodeURIComponent(typePrestation);
{% else %}
{% if reservee %}
var url = "../../mes_annonces_repondues/filtres/?keyword=" + encodeURIComponent(keyword) + "&prixMin=" + encodeURIComponent(prixMin) + "&prixMax=" + encodeURIComponent(prixMax) + "&type_prestation=" + encodeURIComponent(typePrestation);
{% else %}
var url = "../../mes_annonces_likees/filtres/?keyword=" + encodeURIComponent(keyword) + "&prixMin=" + encodeURIComponent(prixMin) + "&prixMax=" + encodeURIComponent(prixMax) + "&type_prestation=" + encodeURIComponent(typePrestation);
{% endif %}
{% endif %}
window.location.href = url;
});
</script>
</div>
<div class="container-mes-annonces">
{% if publiee %}
<a id="btnPostees" class="btn-navigation active" href="{{ path('app_mes_annonces') }}">Annonces postées</a>
{% else %}
<a id="btnPostees" class="btn-navigation" href="{{ path('app_mes_annonces') }}">Annonces postées</a>
{% endif %}
{% if reservee %}
<a id="btnRepondues" class="btn-navigation active" href="{{ path('app_mes_annonces_repondues') }}">Annonces répondues</a>
{% else %}
<a id="btnRepondues" class="btn-navigation" href="{{ path('app_mes_annonces_repondues') }}">Annonces répondues</a>
{% endif %}
{% if likee %}
<a id="btnRepondues" class="btn-navigation active" href="{{ path('app_mes_likes') }}">Annonces likées</a>
{% else %}
<a id="btnRepondues" class="btn-navigation" href="{{ path('app_mes_likes') }}">Annonces likées</a>
{% endif %}
</div>
{% endblock %}
\ No newline at end of file
......@@ -3,39 +3,8 @@
{% block title %}Mes annonces{% endblock %}
{% block body %}
<div class="container-recherche">
<form id="filterForm" method="post">
<input class="txt_form" type="text" name="keyword" value="{{ app.request.query.get('keyword') }}" placeholder="Mot-clé">
<input class="txt_form prix" type="number" name="prixMin" value="{{ app.request.query.get('prixMin') }}" placeholder="€ minimum">
<input class="txt_form prix" type="number" name="prixMax" value="{{ app.request.query.get('prixMax') }}" placeholder="€ maximum">
<select class="txt_form" name="type_prestation">
<option value="">Tous les types de prestation</option>
<option value="pret" {% if app.request.query.get('type_prestation') == 'pret' %} selected {% endif %}>Prêts</option>
<option value="service" {% if app.request.query.get('type_prestation') == 'service' %} selected {% endif %}>Services</option>
</select>
<button type="submit" class="btn_recherche">Filtrer</button>
</form>
<script>
document.getElementById("filterForm").addEventListener("submit", function(event) {
event.preventDefault();
var keyword = document.getElementsByName("keyword")[0].value;
var prixMin = document.getElementsByName("prixMin")[0].value;
var prixMax = document.getElementsByName("prixMax")[0].value;
var typePrestation = document.getElementsByName("type_prestation")[0].value;
var url = "../../mes_annonces/filtres/?keyword=" + encodeURIComponent(keyword) + "&prixMin=" + encodeURIComponent(prixMin) + "&prixMax=" + encodeURIComponent(prixMax) + "&type_prestation=" + encodeURIComponent(typePrestation);
window.location.href = url;
});
</script>
</div>
<div class="container-mes-annonces">
<a id="btnPostees" class="btn-navigation active" href="{{ path('app_mes_annonces') }}">Annonces postées</a>
<a id="btnRepondues" class="btn-navigation" href="{{ path('app_mes_annonces_repondues') }}">Annonces répondues</a>
</div>
{% include 'security/entete_mes_annonces.html.twig' %}
<div class="prestations">
{% for prestation in prestations %}
......
{% extends 'base.html.twig' %}
{% block title %}Mes annonces{% endblock %}
{% block body %}
{% include 'security/entete_mes_annonces.html.twig' %}
<div class="prestations">
{% for prestation in prestations %}
<div class="prestation">
{% if prestation.getType() == 'Pret' %}
<p class="tag_pret" id="tag">Prêt</p>
<p>{{ prestation.titre }}</p>
<p>{{ prestation.CoutPrestation }} florains</p>
<a href="{{ path('annonce_detail', {'id': prestation.id}) }}"><button class="tag_pret">Voir le détail >></button></a>
{% elseif prestation.getType() == 'Service' %}
<p class="tag_service" id="tag">Service</p>
<p>{{ prestation.titre }}</p>
<p>{{ prestation.CoutPrestation }} florains</p>
<a href="{{ path('annonce_detail', {'id': prestation.id}) }}"><button class="tag_service">Voir le détail >></button></a>
{% endif %}
</div>
{% endfor %}
</div>
<script>
const btnPostees = document.getElementById('btnPostees');
const btnRepondues = document.getElementById('btnRepondues');
btnPostees.addEventListener('click', () => {
btnPostees.classList.add('active');
btnRepondues.classList.remove('active');
});
btnRepondues.addEventListener('click', () => {
btnRepondues.classList.add('active');
btnPostees.classList.remove('active');
});
</script>
{% endblock %}
\ No newline at end of file
......@@ -3,39 +3,8 @@
{% block title %}Mes annonces{% endblock %}
{% block body %}
<div class="container-recherche">
<form id="filterForm" method="post">
<input class="txt_form" type="text" name="keyword" value="{{ app.request.query.get('keyword') }}" placeholder="Mot-clé">
<input class="txt_form prix" type="number" name="prixMin" value="{{ app.request.query.get('prixMin') }}" placeholder="€ minimum">
<input class="txt_form prix" type="number" name="prixMax" value="{{ app.request.query.get('prixMax') }}" placeholder="€ maximum">
<select class="txt_form" name="type_prestation">
<option value="">Tous les types de prestation</option>
<option value="pret" {% if app.request.query.get('type_prestation') == 'pret' %} selected {% endif %}>Prêts</option>
<option value="service" {% if app.request.query.get('type_prestation') == 'service' %} selected {% endif %}>Services</option>
</select>
<button type="submit" class="btn_recherche">Filtrer</button>
</form>
<script>
document.getElementById("filterForm").addEventListener("submit", function(event) {
event.preventDefault();
var keyword = document.getElementsByName("keyword")[0].value;
var prixMin = document.getElementsByName("prixMin")[0].value;
var prixMax = document.getElementsByName("prixMax")[0].value;
var typePrestation = document.getElementsByName("type_prestation")[0].value;
var url = "../../mes_annonces_repondues/filtres/?keyword=" + encodeURIComponent(keyword) + "&prixMin=" + encodeURIComponent(prixMin) + "&prixMax=" + encodeURIComponent(prixMax) + "&type_prestation=" + encodeURIComponent(typePrestation);
window.location.href = url;
});
</script>
</div>
<div class="container-mes-annonces">
<a id="btnPostees" class="btn-navigation" href="{{ path('app_mes_annonces') }}">Annonces postées</a>
<a id="btnRepondues" class="btn-navigation active" href="{{ path('app_mes_annonces_repondues') }}">Annonces répondues</a>
</div>
{% include 'security/entete_mes_annonces.html.twig' %}
<div class="prestations">
{% for prestation in prestations %}
......
......@@ -16,8 +16,8 @@
<div class="container-connexion3">
<div class="container-connexion">
<div class="container-connexion2">
<button class="btn-connexion2" onclick="window.location.href='{{ path("app_user_coord") }}'">Mon profil</button>
<button class="btn-connexion2" onclick="window.location.href='{{ path("app_mes_annonces") }}'">Consulter mes transactions</button>
<button class="btn-connexion2" onclick="window.location.href='{{ path("app_user_coord") }}'">Consulter mon profil</button>
<button class="btn-connexion2" onclick="window.location.href='{{ path("app_mes_annonces") }}'">Consulter mes annonces</button>
<button class="btn-connexion2" onclick="window.location.href='{{ path("app_modif_user_coord") }}'">Modifier mes coordonnées</button>
<button class="btn-connexion2" onclick="window.location.href='{{ path("app_modif_user_abonnement") }}'">Modifier mon abonnement</button>
<button class="btn-connexion2" onclick="window.location.href='{{ path("app_modif_user_mdp") }}'">Modifier mon mot de passe</button>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment