summaryrefslogtreecommitdiff
path: root/src/model/entities/Prestation.php
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2026-10-19 23:42:34 +0200
committerpolo <ordipolo@gmx.fr>2026-10-19 23:42:34 +0200
commit79bc73d7985f51f2a6a1b3cb6e0115f59afb2ac4 (patch)
tree85ddbac0a01731030b021871736e05c4e1bd7696 /src/model/entities/Prestation.php
parentd76eace8bdc50e208d9754ff50acb58525887048 (diff)
downloadAppliGestionPHP-79bc73d7985f51f2a6a1b3cb6e0115f59afb2ac4.tar.gz
AppliGestionPHP-79bc73d7985f51f2a6a1b3cb6e0115f59afb2ac4.tar.bz2
AppliGestionPHP-79bc73d7985f51f2a6a1b3cb6e0115f59afb2ac4.zip
mise en place de l'héritage 1
Diffstat (limited to 'src/model/entities/Prestation.php')
-rw-r--r--src/model/entities/Prestation.php45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/model/entities/Prestation.php b/src/model/entities/Prestation.php
index a0489d3..fe18b70 100644
--- a/src/model/entities/Prestation.php
+++ b/src/model/entities/Prestation.php
@@ -1,17 +1,30 @@
1<?php 1<?php
2// src/entities/Prestation.php 2// src/entities/Prestation.php
3 3
4// MAJ champs id
5// 1/ supprimer les champ id des filles (retirer contrainte clé primaire avant)
6// 2/ renommer les champs id_presta des filles en id (même nom que l'id de la mère)
7
4use Doctrine\ORM\Mapping as ORM; 8use Doctrine\ORM\Mapping as ORM;
5use Doctrine\ORM\EntityManager; 9use Doctrine\ORM\EntityManager;
6 10
7#[ORM\Entity] 11#[ORM\Entity]
8#[ORM\Table(name: 'prestations')] 12#[ORM\Table(name: 'prestations')]
9class Prestation 13#[ORM\InheritanceType('JOINED')]
14#[ORM\DiscriminatorColumn(name: 'type_presta', type: 'string')]
15#[ORM\DiscriminatorMap([
16 'devis' => Devis::class,
17 'facture' => Facture::class,
18 'cesu' => CESU::class,
19 'location' => Location::class,
20 'non_vendue' => NonVendue::class
21])]
22abstract class Prestation
10{ 23{
11 #[ORM\Id] 24 #[ORM\Id]
12 #[ORM\Column(type: 'integer')] 25 #[ORM\Column(type: 'integer')]
13 #[ORM\GeneratedValue] 26 #[ORM\GeneratedValue]
14 private int|null $id = null; 27 private ?int $id = null;
15 28
16 #[ORM\ManyToOne(targetEntity: Client::class, cascade: ['persist'])] 29 #[ORM\ManyToOne(targetEntity: Client::class, cascade: ['persist'])]
17 #[ORM\JoinColumn(name: 'id_client', referencedColumnName: 'id')] 30 #[ORM\JoinColumn(name: 'id_client', referencedColumnName: 'id')]
@@ -21,23 +34,11 @@ class Prestation
21 #[ORM\Column(type: 'string', length: 10)] // format 'aaaa-mm-jj' 34 #[ORM\Column(type: 'string', length: 10)] // format 'aaaa-mm-jj'
22 private string $date; 35 private string $date;
23 #[ORM\Column] 36 #[ORM\Column]
24 private string $type_presta;
25 #[ORM\Column]
26 private string $mode_paiement = ''; // non renseigné quand on fait un devis 37 private string $mode_paiement = ''; // non renseigné quand on fait un devis
27 #[ORM\Column] 38 #[ORM\Column]
28 private string $commentaires; 39 private string $commentaires;
29
30 #[ORM\OneToOne(mappedBy: 'presta', targetEntity: Facture::class)]
31 private ?facture $facture = null;
32 #[ORM\OneToOne(mappedBy: 'presta', targetEntity: Devis::class)]
33 private ?devis $devis;
34 #[ORM\OneToOne(mappedBy: 'presta', targetEntity: CESU::class)]
35 private ?cesu $cesu;
36 #[ORM\OneToOne(mappedBy: 'presta', targetEntity: Location::class)]
37 private ?location $location;
38 40
39 public static EntityManager $entityManager; 41 public static EntityManager $entityManager;
40
41 42
42 public function __construct(?Client $client = null){ 43 public function __construct(?Client $client = null){
43 $this->setClient($client); 44 $this->setClient($client);
@@ -56,10 +57,10 @@ class Prestation
56 { 57 {
57 return $this->date; 58 return $this->date;
58 } 59 }
59 public function getTypePresta(): string 60 /*public function getTypePresta(): string
60 { 61 {
61 return $this->type_presta; 62 return $this->type_presta;
62 } 63 }*/
63 public function getModePaiement(): string 64 public function getModePaiement(): string
64 { 65 {
65 return $this->mode_paiement; 66 return $this->mode_paiement;
@@ -124,11 +125,11 @@ class Prestation
124 }*/ 125 }*/
125 } 126 }
126 127
127 public function setTypePresta(string $value) // appelée dans la section 2 uniquement, pour la 3 on verra plus tard 128 /*public function setTypePresta(string $value) // appelée dans la section 2 uniquement, pour la 3 on verra plus tard
128 { 129 {
129 $this->type_presta = $value; 130 $this->type_presta = $value;
130 return $this; 131 return $this;
131 } 132 }*/
132 public function setModePaiement(string $value) 133 public function setModePaiement(string $value)
133 { 134 {
134 $this->mode_paiement = $value; 135 $this->mode_paiement = $value;
@@ -153,7 +154,7 @@ class Prestation
153 //$input->typeToClient(); // on modifie $client ici (merci les références PHP) 154 //$input->typeToClient(); // on modifie $client ici (merci les références PHP)
154 } 155 }
155 156
156 public function set(string $entry, string $input): void 157 /*public function set(string $entry, string $input): void
157 { 158 {
158 $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide 159 $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide
159 160
@@ -176,7 +177,7 @@ class Prestation
176 $this->setCommentaires($input); 177 $this->setCommentaires($input);
177 break; 178 break;
178 } 179 }
179 } 180 }*/
180 181
181 // code presta = année-mois-jour-codeclient-typedepresta-combientièmefois 182 // code presta = année-mois-jour-codeclient-typedepresta-combientièmefois
182 public function setCodePresta(int $increment): Prestation // 0 pour modif, 1 pour nouvelle presta 183 public function setCodePresta(int $increment): Prestation // 0 pour modif, 1 pour nouvelle presta
@@ -191,7 +192,7 @@ class Prestation
191 $date_array[1], // mois 192 $date_array[1], // mois
192 $date_array[2], // jour 193 $date_array[2], // jour
193 $this->client->getCodeClient(), // mise à jour éventuelle 194 $this->client->getCodeClient(), // mise à jour éventuelle
194 $this->type_presta, 195 //$this->type_presta,
195 $how_many_times 196 $how_many_times
196 ]; 197 ];
197 $this->code_presta = implode('-', $array_code); 198 $this->code_presta = implode('-', $array_code);
@@ -222,7 +223,7 @@ class Prestation
222 $find_by = ['client' => $Customer->getId()]; 223 $find_by = ['client' => $Customer->getId()];
223 if($type != '') 224 if($type != '')
224 { 225 {
225 $find_by['type_presta'] = 'devis'; 226 //$find_by['type_presta'] = 'devis';
226 } 227 }
227 $PrestaList = $repository->findBy($find_by); 228 $PrestaList = $repository->findBy($find_by);
228 229