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

Merge branch 'master' into 'main'

modif de la création des notifs et ajout de certaines notifs

See merge request !70
parents e3bccaa8 9f193de0
Branches
No related tags found
1 merge request!70modif de la création des notifs et ajout de certaines notifs
......@@ -66,21 +66,15 @@ class AnnonceDetailController extends AbstractController
}
if ($prestation->getIdClient() != null) {
$notification = new Notification();
$notification->setDescription("L'utilisateur " . $this->getUser()->getLogin() . " a supprimé l'annonce " . $prestation->getTitre() . " que vous aviez réservé.");
$notification->setType("Suppression annonce réservée");
$notification->setDate(new DateTime());
$notification->setUserId($entityManager->getRepository(Personne::class)->find($prestation->getIdClient()));
$this->doctrine->getManager()->persist($notification);
$this->makeNotif("L'utilisateur " . $this->getUser()->getLogin() . " a supprimé l'annonce " . $prestation->getTitre() . " que vous aviez réservé.",
"Suppression annonce réservée",
$entityManager->getRepository(Personne::class)->find($prestation->getIdClient()));
}
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);
$this->makeNotif("L'utilisateur " . $this->getUser()->getLogin() . " a supprimé l'annonce " . $prestation->getTitre() . " que vous aviez aimé.",
"Suppression annonce aimée",
$u);
}
$entityManager->remove($prestation);
......@@ -111,12 +105,9 @@ class AnnonceDetailController extends AbstractController
$prestation->setFournisseurValide(false);
$prestation->setClientValide(false);
$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);
$this->makeNotif("Annulation de la réservation de l'annonce " . $prestation->getTitre() . " par " . $this->getUser()->getLogin(),
"Annulation réservation annonce",
$prestation->getProprietaire());
$prestation->setIdClient(null);
$litiges = $prestation->getLitiges();
......@@ -132,12 +123,9 @@ class AnnonceDetailController extends AbstractController
//On prélève le compte du client sans verser le propriétaire
$data['user']->setNbFlorains($data['user']->getNbFlorains() - $data['annonce']->getCoutPrestation());
$notification = new Notification();
$notification->setDescription("Réservation de l'annonce " . $data['annonce']->getTitre() . " par " . $this->getUser()->getLogin());
$notification->setType("Réservation annonce");
$notification->setDate(new DateTime());
$notification->setUserId($data['annonce']->getProprietaire());
$this->doctrine->getManager()->persist($notification);
$this->makeNotif("Réservation de l'annonce " . $data['annonce']->getTitre() . " par " . $this->getUser()->getLogin(),
"Réservation annonce",
$data['annonce']->getProprietaire());
}
}
......@@ -153,12 +141,9 @@ class AnnonceDetailController extends AbstractController
$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);
$this->makeNotif($user->getLogin(). " a aimé votre annonce " . $prestation->getTitre(),
"Annonce aimée",
$prestation->getProprietaire());
$prestation->setIdClient(null);
} else return $this->redirectToRoute('app_login');
......@@ -180,8 +165,14 @@ class AnnonceDetailController extends AbstractController
$prestation = $data['annonce'];
if($user->getId() == $prestation->getFournisseur()->getId()) {
$this->makeNotif("Le fournisseur de la prestation " . $prestation->getTitre() . " a validé votre réservation.",
"Réservation validée",
$data['entityManager']->getRepository(Personne::class)->find($prestation->getIdClient()));
$prestation->setFournisseurValide(true);
}else if ($user->getId() == $prestation->getIdClient()->getId()){
$this->makeNotif("Le client de la prestation " . $prestation->getTitre() . " a validé sa réservation.",
"Réservation validée",
$data['entityManager']->getRepository(Personne::class)->find($prestation->getFournisseur()));
$prestation->setClientValide(true);
}
......@@ -190,6 +181,14 @@ class AnnonceDetailController extends AbstractController
if(count($prestation->getLitiges()) == 0 && $prestation->isFournisseurValide() && $prestation->isClientValide()){
//La prestation est validé, donc on verse le montant de florain au fournisseur
// Notif pour le propriétaire
$this->makeNotif("La prestation " . $prestation->getTitre() . " a été validé des deux côtés. Elle est terminée.",
"Prestation conclue",
$data['entityManager']->getRepository(Personne::class)->find($prestation->getFournisseur()));
// Notif pour le client
$this->makeNotif("La prestation " . $prestation->getTitre() . " a été validé des deux côtés. Elle est terminée.",
"Prestation conclue",
$data['entityManager']->getRepository(Personne::class)->find($prestation->getIdClient()));
$prestation->getFournisseur()->setNbFlorains($prestation->getFournisseur()->getNbFlorains() + $prestation->getCoutPrestation());
$prestation->setTermine(true);
......@@ -200,4 +199,14 @@ class AnnonceDetailController extends AbstractController
return $this->redirectToRoute('annonce_detail', ['id' => $id]);
}
public function makeNotif($desc,$type,$userID) {
$notification = new Notification();
$notification->setDescription($desc);
$notification->setType($type);
$notification->setDate(new DateTime());
$notification->setUserId($userID);
$this->doctrine->getManager()->persist($notification);
$this->doctrine->getManager()->flush();
}
}
......@@ -75,7 +75,7 @@
{% endif %}
{% endif %}
{% else %}
{% if user.nb_florains >= annonce.cout_prestation %}
{% if user.NbFlorains() >= annonce.CoutPrestation %}
<a href="{{ path('app_reserver_prestation', {'id': annonce.id, 'interet': true}) }}"><button class="btn-connexion" id="btnRepondre">Répondre à l'annonce</button></a>
{% else %}
<a href=""><button class="btn-connexion" id="btnRepondre">Trop pauvre pour payer</button></a>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment