Création d'intervention + ajout de celle-ci dans le calendrier (pas encore fonctionnel)

This commit is contained in:
Yacha-Shan 2025-05-08 10:48:41 +02:00
parent c640bdc4d3
commit 5cdf38794a
7 changed files with 252 additions and 19 deletions

View File

@ -139,5 +139,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="fullcalendar" level="application" />
</component>
</module>

4
.idea/dataSources.xml generated
View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="HegreEtConfort@localhost" uuid="21423ae4-3232-4641-affb-06399f70655a">
<data-source source="LOCAL" name="hegreetconfort@localhost" uuid="21423ae4-3232-4641-affb-06399f70655a">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://localhost:5433/HegreEtConfort</jdbc-url>
<jdbc-url>jdbc:postgresql://localhost:5432/hegreetconfort</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>

View File

@ -7,6 +7,7 @@ use App\Form\InterventionType;
use App\Repository\InterventionRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
@ -106,4 +107,25 @@ final class InterventionController extends AbstractController
return $this->redirectToRoute('app_intervention_index', [], Response::HTTP_SEE_OTHER);
}
#[Route('/api/interventions', name: 'api_interventions')]
public function apiInterventions(InterventionRepository $repo): JsonResponse
{
$interventions = $repo->findAll();
$events = [];
foreach ($interventions as $intervention) {
$events[] = [
'id' => $intervention->getId(),
'title' => $intervention->getWording(), // ou getTitre() selon ton entité
'start' => $intervention->getDate()->format('Y-m-d\TH:i:s'),
// ajoute 'end' si tu veux une durée
];
}
return $this->json($events);
}
}

View File

@ -1,4 +1,175 @@
<?php
//
//namespace App\Entity;
//
//use App\Repository\InterventionRepository;
//use Doctrine\DBAL\Types\Types;
//use Doctrine\ORM\Mapping as ORM;
//use Doctrine\Common\Collections\ArrayCollection;
//use Doctrine\Common\Collections\Collection;
//
//#[ORM\Entity(repositoryClass: InterventionRepository::class)]
//class Intervention
//{
// #[ORM\Id]
// #[ORM\GeneratedValue]
// #[ORM\Column]
// private ?int $id = null;
//
// #[ORM\Column(length: 255)]
// private ?string $Wording = null;
//
// #[ORM\Column(type: Types::DATETIME_MUTABLE)]
// private ?\DateTimeInterface $Timestamp = null;
//
// #[ORM\Column(length: 255)]
// private ?string $Description = null;
//
// #[ORM\Column(length: 255)]
// private ?string $Address = null;
//
// #[ORM\Column(length: 255)]
// private ?string $Status = null;
//
////<<<<<<< HEAD
//// #[ORM\ManyToOne(targetEntity: Vehicule::class)]
//// private ?Vehicule $vehicule = null;
////
////=======
// #[ORM\ManyToOne(inversedBy: 'interventions')]
// #[ORM\JoinColumn(nullable: false)]
// private ?Utilisateur $user = null;
//
// #[ORM\ManyToOne]
// #[ORM\JoinColumn(nullable: false)]
// private ?Fault $fault = null;
//
// #[ORM\ManyToOne(inversedBy: 'intervention')]
// private ?Vehicle $vehicle = null;
//
// #[ORM\ManyToMany(targetEntity: Stock::class)]
// #[ORM\JoinTable(name: "intervention_stock")]
// private Collection $stocks;
//
// public function __construct()
// {
// $this->stocks = new ArrayCollection();
// }
////>>>>>>> 4fc91211f0d814453d2ed97caf6a1d94d709058e
//
// public function getId(): ?int
// {
// return $this->id;
// }
//
// public function getWording(): ?string
// {
// return $this->Wording;
// }
//
// public function setWording(string $Wording): static
// {
// $this->Wording = $Wording;
// return $this;
// }
//
// public function getTimestamp(): ?\DateTimeInterface
// {
// return $this->Timestamp;
// }
//
// public function setTimestamp(\DateTimeInterface $Timestamp): static
// {
// $this->Timestamp = $Timestamp;
// return $this;
// }
//
// public function getDescription(): ?string
// {
// return $this->Description;
// }
//
// public function setDescription(string $Description): static
// {
// $this->Description = $Description;
// return $this;
// }
//
// public function getAddress(): ?string
// {
// return $this->Address;
// }
//
// public function setAddress(string $Address): static
// {
// $this->Address = $Address;
// return $this;
// }
//
// public function getStatus(): ?string
// {
// return $this->Status;
// }
//
// public function setStatus(string $Status): static
// {
// $this->Status = $Status;
// return $this;
// }
//
// public function getUser(): ?Utilisateur
// {
// return $this->user;
// }
//
// public function setUser(?Utilisateur $user): static
// {
// $this->user = $user;
// return $this;
// }
//
// public function getFault(): ?Fault
// {
// return $this->fault;
// }
//
// public function setFault(?Fault $fault): static
// {
// $this->fault = $fault;
// return $this;
// }
//
// public function getVehicle(): ?Vehicle
// {
// return $this->vehicle;
// }
//
// public function setVehicle(?Vehicle $vehicle): static
// {
// $this->vehicle = $vehicle;
// return $this;
// }
//
// public function getStocks(): Collection
// {
// return $this->stocks;
// }
//
// public function addStock(Stock $stock): static
// {
// if (!$this->stocks->contains($stock)) {
// $this->stocks[] = $stock;
// }
// return $this;
// }
//
// public function removeStock(Stock $stock): static
// {
// $this->stocks->removeElement($stock);
// return $this;
// }
//}
namespace App\Entity;
@ -31,11 +202,6 @@ class Intervention
#[ORM\Column(length: 255)]
private ?string $Status = null;
<<<<<<< HEAD
// #[ORM\ManyToOne(targetEntity: Vehicule::class)]
// private ?Vehicule $vehicule = null;
=======
#[ORM\ManyToOne(inversedBy: 'interventions')]
#[ORM\JoinColumn(nullable: false)]
private ?Utilisateur $user = null;
@ -51,11 +217,14 @@ class Intervention
#[ORM\JoinTable(name: "intervention_stock")]
private Collection $stocks;
// Ajout de la propriété StartDate
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $startDate = null;
public function __construct()
{
$this->stocks = new ArrayCollection();
}
>>>>>>> 4fc91211f0d814453d2ed97caf6a1d94d709058e
public function getId(): ?int
{
@ -168,4 +337,23 @@ class Intervention
$this->stocks->removeElement($stock);
return $this;
}
// Ajout de la méthode getStartDate
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(\DateTimeInterface $startDate): static
{
$this->startDate = $startDate;
return $this;
}
// Ajout de la méthode getTitle()
public function getTitle(): ?string
{
return $this->Wording;
}
}

View File

@ -5,19 +5,38 @@
{% block body %}
<h1>📅 Calendrier des interventions</h1>
<a href="{{ path('app_intervention_new') }}" class="btn btn-success mt-3"> Ajouter une intervention</a>
<div id="calendar"></div>
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@6.1.8/index.global.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth',
events: {{ events | raw }},
eventClick: function(info) {
alert('Intervention : ' + info.event.title + '\n' + info.event.extendedProps.description);
}
events: '/api/interventions' // ✅ Point daccès API
});
calendar.render();
});
</script>
{# <div id="calendar"></div>#}
{# <script>#}
{# document.addEventListener('DOMContentLoaded', function() {#}
{# var calendarEl = document.getElementById('calendar');#}
{# var calendar = new FullCalendar.Calendar(calendarEl, {#}
{# initialView: 'dayGridMonth',#}
{# events: {{ events | raw }},#}
{# eventClick: function(info) {#}
{# alert('Intervention : ' + info.event.title + '\n' + info.event.extendedProps.description);#}
{# }#}
{# });#}
{# calendar.render();#}
{# });#}
{# </script>#}
{% endblock %}

View File

@ -50,4 +50,8 @@
</table>
<a href="{{ path('app_intervention_new') }}" class="btn btn-success">Créer une nouvelle intervention</a>
<div class="mt-3">
<a href="{{ path('app_calendrier_index') }}" class="btn btn-secondary">← Retour au calendrier</a>
</div>
{% endblock %}

View File

@ -5,9 +5,7 @@
{% block body %}
<h1 class="mb-4"> Créer une nouvelle intervention</h1>
{{ include('intervention/_form.html.twig') }}
<<<<<<< HEAD
{#<<<<<<< HEAD#}
<div class="background-intervention">
{# <input required id="nom" placeholder="Nom de l'intervention">#}
@ -59,14 +57,15 @@
{# <button type="reset" class="supprimer"> Supprimer </button>#}
{{ include('intervention/_form.html.twig') }}
<a href="{{ path('app_intervention_index') }}" id="liste">Retour à la liste</a>
</div>
</body>
</html>
=======
{#=======#}
<div class="mt-3">
<a href="{{ path('app_intervention_index') }}" class="btn btn-secondary">← Retour à la liste des interventions</a>
</div>
<div class="mt-3">
<a href="{{ path('app_calendrier_index') }}" class="btn btn-secondary">← Retour au calendrier</a>
</div>
{% endblock %}
>>>>>>> 4fc91211f0d814453d2ed97caf6a1d94d709058e
{#>>>>>>> 4fc91211f0d814453d2ed97caf6a1d94d709058e#}