Skip to content
Snippets Groups Projects
Commit e2aad280 authored by DEMANGEL Mael's avatar DEMANGEL Mael
Browse files
parents 47e4c466 9e508a4f
Branches
No related tags found
No related merge requests found
...@@ -277,7 +277,6 @@ button { ...@@ -277,7 +277,6 @@ button {
width: 51px; width: 51px;
} }
<<<<<<< HEAD
.table_notif { .table_notif {
align-self: center; align-self: center;
width: 100%; width: 100%;
...@@ -286,7 +285,8 @@ button { ...@@ -286,7 +285,8 @@ button {
.table_notif tr td { .table_notif tr td {
text-align: center; text-align: center;
======= }
.choix-abonnement { .choix-abonnement {
display: flex; display: flex;
justify-content: space-around; justify-content: space-around;
...@@ -313,5 +313,20 @@ button { ...@@ -313,5 +313,20 @@ button {
.type-abonnement.selected { .type-abonnement.selected {
background-color: green; background-color: green;
color: white; color: white;
>>>>>>> e333f30cd614a9adb1ed98b040c0cc0feeeb487c }
.btn-like {
background-color: #ffffff;
border: 0px #ccc;
padding: 5px 10px;
cursor: pointer;
font-size: 30px;
}
.aime {
color: red;
}
.non_aime {
color: lightgray;
} }
\ No newline at end of file
...@@ -18,8 +18,7 @@ class AnnonceDetailController extends AbstractController ...@@ -18,8 +18,7 @@ class AnnonceDetailController extends AbstractController
{ {
private $doctrine; private $doctrine;
public function __construct(ManagerRegistry $doctrine) public function __construct(ManagerRegistry $doctrine) {
{
$this->doctrine = $doctrine; $this->doctrine = $doctrine;
} }
...@@ -27,17 +26,15 @@ class AnnonceDetailController extends AbstractController ...@@ -27,17 +26,15 @@ class AnnonceDetailController extends AbstractController
{ {
$entityManager = $this->doctrine->getManager(); $entityManager = $this->doctrine->getManager();
$annonce = $entityManager->getRepository(Prestations::class)->find($id); $annonce = $entityManager->getRepository(Prestations::class)->find($id);
$nbAimees = $annonce->getUtilisateursAimant()->count();
$prets = $entityManager->getRepository(Pret::class)->findAll(); $prets = $entityManager->getRepository(Pret::class)->findAll();
$services = $entityManager->getRepository(Services::class)->findAll(); $services = $entityManager->getRepository(Services::class)->findAll();
$user = $this->getUser(); $user = $this->getUser();
if (!$annonce) {
throw $this->createNotFoundException('Annonce non trouvée');
}
return [ return [
'entityManager' => $entityManager, 'entityManager' => $entityManager,
'annonce' => $annonce, 'annonce' => $annonce,
'nbAimees' => $nbAimees,
'prets' => $prets, 'prets' => $prets,
'services' => $services, 'services' => $services,
'user' => $user, 'user' => $user,
...@@ -50,17 +47,14 @@ class AnnonceDetailController extends AbstractController ...@@ -50,17 +47,14 @@ class AnnonceDetailController extends AbstractController
public function detail($id) public function detail($id)
{ {
$data = $this->getCommonData($id); $data = $this->getCommonData($id);
$prest = $data['annonce'];
if ($prest) {
$prest->setNbVues($prest->getNbVues() + 1);
$data['entityManager']->flush();
}
return $this->render('annonce_detail/annonce.html.twig', $data); return $this->render('annonce_detail/annonce.html.twig', $data);
} }
#[Route('/annonce/detail', name: 'app_annonce_detail')]
public function index(): Response
{
return $this->render('annonce_detail/annonce.html.twig', [
'controller_name' => 'AnnonceDetailController',
]);
}
#[Route('/deleteTransaction/{prestationId}', name: 'app_delete_transaction')] #[Route('/deleteTransaction/{prestationId}', name: 'app_delete_transaction')]
public function deleteTransaction($prestationId): Response public function deleteTransaction($prestationId): Response
{ {
...@@ -74,11 +68,20 @@ class AnnonceDetailController extends AbstractController ...@@ -74,11 +68,20 @@ class AnnonceDetailController extends AbstractController
if ($prestation->getIdClient() != null) { if ($prestation->getIdClient() != null) {
$notification = new Notification(); $notification = new Notification();
$notification->setDescription("L'utilisateur " . $this->getUser()->getLogin() . " a supprimé l'annonce " . $prestation->getTitre() . " que vous aviez réservé."); $notification->setDescription("L'utilisateur " . $this->getUser()->getLogin() . " a supprimé l'annonce " . $prestation->getTitre() . " que vous aviez réservé.");
$notification->setType("Suppression annonce"); $notification->setType("Suppression annonce réservée");
$notification->setDate(new DateTime()); $notification->setDate(new DateTime());
$notification->setUserId($entityManager->getRepository(Personne::class)->find($prestation->getIdClient())); $notification->setUserId($entityManager->getRepository(Personne::class)->find($prestation->getIdClient()));
$this->doctrine->getManager()->persist($notification); $this->doctrine->getManager()->persist($notification);
} }
foreach ($prestation->getUtilisateursAimant() as $u) {
$notification = new Notification();
$notification->setDescription("L'utilisateur " . $this->getUser()->getLogin() . " a supprimé l'annonce " . $prestation->getTitre() . " que vous aviez aimé.");
$notification->setType("Suppression annonce aimée");
$notification->setDate(new DateTime());
$notification->setUserId($u);
$this->doctrine->getManager()->persist($notification);
}
$entityManager->remove($prestation); $entityManager->remove($prestation);
$entityManager->flush(); $entityManager->flush();
...@@ -100,6 +103,12 @@ class AnnonceDetailController extends AbstractController ...@@ -100,6 +103,12 @@ class AnnonceDetailController extends AbstractController
$entityManager = $this->doctrine->getManager(); $entityManager = $this->doctrine->getManager();
$prestation = $data['annonce']; $prestation = $data['annonce'];
$notification = new Notification();
$notification->setDescription("Annulation de la réservation de l'annonce " . $prestation->getTitre() . " par " . $this->getUser()->getLogin());
$notification->setType("Annulation réservation annonce");
$notification->setDate(new DateTime());
$notification->setUserId($prestation->getProprietaire());
$this->doctrine->getManager()->persist($notification);
$prestation->setIdClient(null); $prestation->setIdClient(null);
$litiges = $prestation->getLitiges(); $litiges = $prestation->getLitiges();
...@@ -123,4 +132,32 @@ class AnnonceDetailController extends AbstractController ...@@ -123,4 +132,32 @@ class AnnonceDetailController extends AbstractController
$data['entityManager']->flush(); $data['entityManager']->flush();
return $this->redirectToRoute('annonce_detail', ['id' => $id]); return $this->redirectToRoute('annonce_detail', ['id' => $id]);
} }
#[Route('/aimerPrestation/{id}', name: 'app_aimer_prestation')]
public function aimerPrestation($id): Response
{
$data = $this->getCommonData($id);
$user = $data['user'];
$prestation = $data['annonce'];
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);
}
$data['entityManager']->flush();
return $this->redirectToRoute('annonce_detail', ['id' => $id]);
}
} }
...@@ -50,9 +50,16 @@ class Prestations ...@@ -50,9 +50,16 @@ class Prestations
#[ORM\OneToMany(mappedBy: 'id_prestation', targetEntity: Litige::class, orphanRemoval: true)] #[ORM\OneToMany(mappedBy: 'id_prestation', targetEntity: Litige::class, orphanRemoval: true)]
private Collection $litiges; private Collection $litiges;
#[ORM\Column]
private int $nbVues = 0;
#[ORM\ManyToMany(targetEntity: Utilisateur::class, mappedBy: 'prestations_aimees')]
private Collection $utilisateurs_aimant;
public function __construct() public function __construct()
{ {
$this->litiges = new ArrayCollection(); $this->litiges = new ArrayCollection();
$this->utilisateurs_aimant = new ArrayCollection();
} }
public function getId(): ?int public function getId(): ?int
...@@ -207,5 +214,40 @@ class Prestations ...@@ -207,5 +214,40 @@ class Prestations
} }
return $this; return $this;
} }
public function getNbVues(): ?int
{
return $this->nbVues;
}
public function setNbVues(int $nbVues): static
{
$this->nbVues = $nbVues;
return $this;
}
/**
* @return Collection<int, Utilisateur>
*/
public function getUtilisateursAimant(): Collection
{
return $this->utilisateurs_aimant;
}
public function addUtilisateursAimant(Utilisateur $utilisateursAimant): static
{
if (!$this->utilisateurs_aimant->contains($utilisateursAimant))
$this->utilisateurs_aimant->add($utilisateursAimant);
return $this;
}
public function removeUtilisateursAimant(Utilisateur $utilisateursAimant): static
{
$this->utilisateurs_aimant->removeElement($utilisateursAimant);
return $this;
}
} }
...@@ -72,6 +72,9 @@ class Utilisateur extends Personne ...@@ -72,6 +72,9 @@ class Utilisateur extends Personne
#[ORM\Column] #[ORM\Column]
private ?bool $sommeil = null; private ?bool $sommeil = null;
#[ORM\ManyToMany(targetEntity: Prestations::class, inversedBy: 'utilisateurs_aimant')]
private Collection $prestations_aimees;
public function __construct() public function __construct()
{ {
$this->inscriptions = new ArrayCollection(); $this->inscriptions = new ArrayCollection();
...@@ -80,6 +83,7 @@ class Utilisateur extends Personne ...@@ -80,6 +83,7 @@ class Utilisateur extends Personne
$this->prestations_client = new ArrayCollection(); $this->prestations_client = new ArrayCollection();
$this->prestations_proprietaire = new ArrayCollection(); $this->prestations_proprietaire = new ArrayCollection();
$this->litiges = new ArrayCollection(); $this->litiges = new ArrayCollection();
$this->prestations_aimees = new ArrayCollection();
} }
public function getNbFlorains(): ?int public function getNbFlorains(): ?int
...@@ -466,4 +470,34 @@ class Utilisateur extends Personne ...@@ -466,4 +470,34 @@ class Utilisateur extends Personne
return $this; return $this;
} }
/**
* @return Collection<int, Prestations>
*/
public function getPrestationsAimees(): Collection
{
return $this->prestations_aimees;
}
public function addPrestationsAimee(Prestations $prestationsAimee): static
{
if (!$this->prestations_aimees->contains($prestationsAimee)) {
$this->prestations_aimees->add($prestationsAimee);
}
return $this;
}
public function removePrestationsAimee(Prestations $prestationsAimee): static
{
$this->prestations_aimees->removeElement($prestationsAimee);
return $this;
}
public function aimePrestation(Prestations $prestation): bool
{
if (!$this->prestations_aimees) return false;
return $this->prestations_aimees->contains($prestation);
}
} }
...@@ -7,75 +7,101 @@ ...@@ -7,75 +7,101 @@
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; } .example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; } .example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style> </style>
<div class="annonce"> {% if annonce %}
<div class="annonce_img"> <div class="annonce">
<h1>{{ annonce.Titre }}</h1> <div class="annonce_img">
<img src={{asset('/img/logo.png')}} alt="logo eco-presto" width="50%"/> <h1>{{ annonce.Titre }}</h1>
{% if app.user.id is defined and (app.user.id == annonce.proprietaire.id or is_granted('ROLE_ADMIN'))%} <img src={{asset('/img/logo.png')}} alt="logo eco-presto" width="50%"/>
<button class="btn-suppression" id="deleteTransactionButton">Supprimer l'annonce</button> {% if app.user.id is defined and (app.user.id == annonce.proprietaire.id or is_granted('ROLE_ADMIN'))%}
<button class="btn-suppression" id="deleteTransactionButton">Supprimer l'annonce</button>
<script> <script>
document.getElementById('deleteTransactionButton').addEventListener('click', function() { document.getElementById('deleteTransactionButton').addEventListener('click', function() {
// Afficher une boîte de dialogue de confirmation // Afficher une boîte de dialogue de confirmation
var confirmation = confirm('Êtes-vous sûr de vouloir supprimer cette transaction ?'); var confirmation = confirm('Êtes-vous sûr de vouloir supprimer cette transaction ?');
// Si l'utilisateur confirme, rediriger vers la page de suppression de la transaction // Si l'utilisateur confirme, rediriger vers la page de suppression de la transaction
if (confirmation) { if (confirmation) {
window.location.href = '{{ path('app_delete_transaction', {'prestationId': annonce.id} ) }}'; window.location.href = '{{ path('app_delete_transaction', {'prestationId': annonce.id} ) }}';
} }
}); });
</script> </script>
{% elseif app.user.id is defined %} {% elseif app.user.id is defined %}
{% if not is_granted ("ROLE_ADMIN") and not app.user.isSommeil() %} {% if not is_granted ("ROLE_ADMIN") and not app.user.isSommeil() %}
{% if annonce.IdClient != NULL %} {% if annonce.IdClient != NULL %}
{% if user.id == annonce.IdClient.Id %} {% if user.id == annonce.IdClient.Id %}
<a href="{{ path('app_reserver_prestation', {'id': annonce.id, 'interet': false}) }}"><button class="btn-suppression" id="btnAnnuler">Annuler la réservation</button></a> <a href="{{ path('app_reserver_prestation', {'id': annonce.id, 'interet': false}) }}"><button class="btn-suppression" id="btnAnnuler">Annuler la réservation</button></a>
{% else %}
<p>Déjà réservé</p>
<a href=""><button class="btn-connexion2" id="btnListeAttente">Se mettre en liste d'attente</button></a>
{% endif %}
{% else %} {% else %}
<p>Déjà réservé</p> <a href="{{ path('app_reserver_prestation', {'id': annonce.id, 'interet': true}) }}"><button class="btn-connexion" id="btnRepondre">Répondre à l'annonce</button></a>
<a href=""><button class="btn-connexion2" id="btnListeAttente">Se mettre en liste d'attente</button></a>
{% endif %} {% endif %}
{% else %} {% endif %}
<a href="{{ path('app_reserver_prestation', {'id': annonce.id, 'interet': true}) }}"><button class="btn-connexion" id="btnRepondre">Répondre à l'annonce</button></a>
{% endif %}
{% endif %}
{% endif %}
{% if not is_granted('ROLE_ADMIN') and (annonce.fournisseur != NULL) and (annonce.IdClient != NULL) %}
<a href="{{ path('app_litige_creation', {'id': annonce.id}) }}"><button class="btn-suppression" id="btnCreerLitige">Créer un litige</button></a>
{% endif %}
</div>
<div class="annonce_desc">
<h3>Description</h3>
{% for pret in prets %}
{% if pret.id == annonce.id %}
<p class="tag_pret" id="tag">Prêt</p>
{% endif %} {% endif %}
{% endfor %}
{% for service in services %} {% if not is_granted('ROLE_ADMIN') and (annonce.fournisseur != NULL) and (annonce.IdClient != NULL) %}
{% if service.id == annonce.id %} <a href="{{ path('app_litige_creation', {'id': annonce.id}) }}"><button class="btn-suppression" id="btnCreerLitige">Créer un litige</button></a>
<p class="tag_service" id="tag">Service</p>
{% endif %} {% endif %}
{% endfor %} </div>
<br/>
{{ annonce.DescrPrestation }} <br/>
<hr>
<h3>Prix</h3>
{{ annonce.CoutPrestation }} florains <br/>
<hr>
<h3>Date de validité</h3>
{{ annonce.DateDebut | date('d-m-Y')}}
{% if is_granted('ROLE_ADMIN') and annonce.litiges|length > 0 %} <div class="annonce_desc">
<hr> {% if user %}
<h3>Litiges</h3> {% if user.id != annonce.proprietaire.id %}
{% for litige in annonce.litiges %} <a href="{{ path('app_aimer_prestation', {'id': annonce.id}) }}"><button class="btn-like">
{{litige.idUtilisateur.login}} : {{litige.descrLitige}} <bt> {{litige.getStringStatus}} {{litige.dateLitige|date('d/m/y')}} {% if user.aimePrestation(annonce) %}
<a href="{{ path('litige_detail', {'id': litige.id}) }}"><button class="btn-connexion2" id="btnLitige">Résoudre ce litige</button></a> <span class="aime">&#10084;</span>
<br/> {% else %}
<span class="non_aime">&#10084;</span>
{% endif %}
</button></a>
{% endif %}
{% else %}
<a href="{{ path('app_aimer_prestation', {'id': annonce.id}) }}"><button class="btn-like">
<span class="non_aime">&#10084;</span>
</button></a>
{% endif %}
<h3>Description</h3>
{% for pret in prets %}
{% if pret.id == annonce.id %}
<p class="tag_pret" id="tag">Prêt</p>
{% endif %}
{% endfor %}
{% for service in services %}
{% if service.id == annonce.id %}
<p class="tag_service" id="tag">Service</p>
{% endif %}
{% endfor %} {% endfor %}
{% endif %} <br/>
{{ annonce.DescrPrestation }} <br/>
<hr>
<h3>Prix</h3>
{{ annonce.CoutPrestation }} florains <br/>
<hr>
<h3>Date de validité</h3>
{{ annonce.DateDebut | date('d-m-Y')}}
<hr>
<h3>Statistiques</h3>
<p>{{ annonce.nbVues }}👁 | {{ nbAimees }} <u>J'aime</u></p>
{% if is_granted('ROLE_ADMIN') and annonce.litiges|length > 0 %}
<hr>
<h3>Litiges</h3>
{% for litige in annonce.litiges %}
{{litige.idUtilisateur.login}} : {{litige.descrLitige}} <bt> {{litige.getStringStatus}} {{litige.dateLitige|date('d/m/y')}}
<a href="{{ path('litige_detail', {'id': litige.id}) }}"><button class="btn-connexion2" id="btnLitige">Résoudre ce litige</button></a>
<br/>
{% endfor %}
{% endif %}
</div>
</div>
{% else %}
<div class="annonce">
<div class="annonce_img">
<h1>Annonce inexistante ou supprimée</h1>
</div>
</div> </div>
</div> {% endif %}
{% endblock %} {% endblock %}
...@@ -10,18 +10,18 @@ ...@@ -10,18 +10,18 @@
<h1>Notifications</h1> <h1>Notifications</h1>
<table class="table_notif"> <table class="table_notif">
<tr>
<td>Date</td>
<td>Type</td>
<td>Description</td>
</tr>
{% if notifs %} {% if notifs %}
{% for notif in notifs %} <tr>
<td><b>Date</b></td>
<td><b>Type</b></td>
<td><b>Description</b></td>
</tr>
{% for notif in notifs|reverse %}
<tr> <tr>
<td>{{ notif.date|date('d/m/y') }}</td> <td>{{ notif.date|date('d/m/y') }}</td>
<td>{{ notif.type }}</td> <td>{{ notif.type }}</td>
<td>{{ notif.description }}</td> <td>{{ notif.description }}</td>
</tr>> </tr>
{% endfor %} {% endfor %}
{% else %} {% else %}
<p>Aucune notification trouvée.</p> <p>Aucune notification trouvée.</p>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<li><strong>Code postal:</strong> {{ user.codepostal }}</li> <li><strong>Code postal:</strong> {{ user.codepostal }}</li>
<li><strong>Ville:</strong> {{ user.ville }}</li> <li><strong>Ville:</strong> {{ user.ville }}</li>
<li><strong>Téléphone:</strong> {{ user.telephone }}</li> <li><strong>Téléphone:</strong> {{ user.telephone }}</li>
<li><strong>Status abonnement:</strong> {% if user.statusabonnement == 0 %} Abonnement standard {% else %} Abonnement premium {% endif %}</li> <li><strong>Statut abonnement:</strong> {% if user.statusabonnement == 0 %} Abonnement standard {% else %} Abonnement premium {% endif %}</li>
</ul> </ul>
</div> </div>
<button class="btn-connexion2" onclick="window.location.href='{{ path("app_modif_user") }}'">Retour</button> <button class="btn-connexion2" onclick="window.location.href='{{ path("app_modif_user") }}'">Retour</button>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment