From 87eb9864d7c738d7897be33c9a1aa06e33378acc Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 19 Oct 2026 23:42:34 +0200 Subject: =?UTF-8?q?mise=20en=20place=20de=20l'h=C3=A9ritage=201,=20changem?= =?UTF-8?q?ents=20BDD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/doctrine | 2 +- src/model/doctrine-bootstrap.php | 7 ------ src/model/entities/CESU.php | 14 +----------- src/model/entities/Devis.php | 14 +----------- src/model/entities/Facture.php | 14 +----------- src/model/entities/Location.php | 14 +----------- src/model/entities/NonVendue.php | 12 +++++++++++ src/model/entities/Prestation.php | 45 ++++++++++++++++++++------------------- 8 files changed, 40 insertions(+), 82 deletions(-) create mode 100644 src/model/entities/NonVendue.php diff --git a/bin/doctrine b/bin/doctrine index 50d5b78..2a2eab5 100755 --- a/bin/doctrine +++ b/bin/doctrine @@ -5,7 +5,7 @@ // chemins des dossiers et nom de la base require('src/File.php'); -require('src/Config.php'); // lit le config.ini et gère certaines erreurs (exemple les / aux chemins manquants) +require('src/Config.php'); Config::readFile('config/config.ini'); Config::hydrate(); diff --git a/src/model/doctrine-bootstrap.php b/src/model/doctrine-bootstrap.php index 029b1b1..019dce4 100644 --- a/src/model/doctrine-bootstrap.php +++ b/src/model/doctrine-bootstrap.php @@ -9,20 +9,13 @@ require_once "vendor/autoload.php"; // Create a simple "default" Doctrine ORM configuration for Attributes $config = ORMSetup::createAttributeMetadataConfiguration( - //paths: array(__DIR__.'/entities'), paths: array('src/model/entities'), isDevMode: true, ); -// or if you prefer XML -// $config = ORMSetup::createXMLMetadataConfiguration( -// paths: array(__DIR__."/config/xml"), -// isDevMode: true, -//); // configuring the database connection $connection = DriverManager::getConnection([ 'driver' => 'pdo_sqlite', - //'path' => __DIR__ . '/../../data/' . Config::$db_name . '.sqlite', 'path' => 'data/' . Config::$db_name . '.sqlite', ], $config); diff --git a/src/model/entities/CESU.php b/src/model/entities/CESU.php index 90eec69..b840ac9 100644 --- a/src/model/entities/CESU.php +++ b/src/model/entities/CESU.php @@ -6,20 +6,8 @@ use Doctrine\ORM\EntityManager; #[ORM\Entity] #[ORM\Table(name: 'cesu')] -class CESU +class CESU extends Prestation { - #[ORM\Id] - #[ORM\Column(type: 'integer')] - #[ORM\GeneratedValue] - private int|null $id = null; - - //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] - //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - //~ private Prestation|null $presta = null; - #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'cesu', cascade: ['persist'])] - #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - private ?Prestation $presta = null; - #[ORM\Column] private string $taches; #[ORM\Column] diff --git a/src/model/entities/Devis.php b/src/model/entities/Devis.php index 70a3cbf..f559243 100644 --- a/src/model/entities/Devis.php +++ b/src/model/entities/Devis.php @@ -6,20 +6,8 @@ use Doctrine\ORM\EntityManager; #[ORM\Entity] #[ORM\Table(name: 'devis')] -class Devis +class Devis extends Prestation { - #[ORM\Id] - #[ORM\Column(type: 'integer')] - #[ORM\GeneratedValue] - private int|null $id = null; - - //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] - //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - //~ private Prestation|null $presta = null; - #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'devis', cascade: ['persist'])] - #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - private ?Prestation $presta = null; - #[ORM\Column] private string $taches; #[ORM\Column] diff --git a/src/model/entities/Facture.php b/src/model/entities/Facture.php index 9a9a89d..fe04508 100644 --- a/src/model/entities/Facture.php +++ b/src/model/entities/Facture.php @@ -6,20 +6,8 @@ use Doctrine\ORM\EntityManager; #[ORM\Entity] #[ORM\Table(name: 'factures')] -class Facture +class Facture extends Prestation { - #[ORM\Id] - #[ORM\Column(type: 'integer')] - #[ORM\GeneratedValue] - private int|null $id = null; - - //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] - //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - //~ private Prestation|null $presta = null; - #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'facture', cascade: ['persist'])] - #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - private ?Prestation $presta = null; - #[ORM\Column] private string $taches; #[ORM\Column] diff --git a/src/model/entities/Location.php b/src/model/entities/Location.php index 11102f9..3574272 100644 --- a/src/model/entities/Location.php +++ b/src/model/entities/Location.php @@ -6,20 +6,8 @@ use Doctrine\ORM\EntityManager; #[ORM\Entity] #[ORM\Table(name: 'locations')] -class Location +class Location extends Prestation { - #[ORM\Id] - #[ORM\Column(type: 'integer')] - #[ORM\GeneratedValue] - private int|null $id = null; - - //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] - //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - //~ private Prestation|null $presta = null; - #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'location', cascade: ['persist'])] - #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] - private ?Prestation $presta = null; - #[ORM\Column] protected string $designation; #[ORM\Column] diff --git a/src/model/entities/NonVendue.php b/src/model/entities/NonVendue.php new file mode 100644 index 0000000..b6b2612 --- /dev/null +++ b/src/model/entities/NonVendue.php @@ -0,0 +1,12 @@ + Devis::class, + 'facture' => Facture::class, + 'cesu' => CESU::class, + 'location' => Location::class, + 'non_vendue' => NonVendue::class +])] +abstract class Prestation { #[ORM\Id] #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue] - private int|null $id = null; + private ?int $id = null; #[ORM\ManyToOne(targetEntity: Client::class, cascade: ['persist'])] #[ORM\JoinColumn(name: 'id_client', referencedColumnName: 'id')] @@ -21,23 +34,11 @@ class Prestation #[ORM\Column(type: 'string', length: 10)] // format 'aaaa-mm-jj' private string $date; #[ORM\Column] - private string $type_presta; - #[ORM\Column] private string $mode_paiement = ''; // non renseigné quand on fait un devis #[ORM\Column] private string $commentaires; - - #[ORM\OneToOne(mappedBy: 'presta', targetEntity: Facture::class)] - private ?facture $facture = null; - #[ORM\OneToOne(mappedBy: 'presta', targetEntity: Devis::class)] - private ?devis $devis; - #[ORM\OneToOne(mappedBy: 'presta', targetEntity: CESU::class)] - private ?cesu $cesu; - #[ORM\OneToOne(mappedBy: 'presta', targetEntity: Location::class)] - private ?location $location; public static EntityManager $entityManager; - public function __construct(?Client $client = null){ $this->setClient($client); @@ -56,10 +57,10 @@ class Prestation { return $this->date; } - public function getTypePresta(): string + /*public function getTypePresta(): string { return $this->type_presta; - } + }*/ public function getModePaiement(): string { return $this->mode_paiement; @@ -124,11 +125,11 @@ class Prestation }*/ } - public function setTypePresta(string $value) // appelée dans la section 2 uniquement, pour la 3 on verra plus tard + /*public function setTypePresta(string $value) // appelée dans la section 2 uniquement, pour la 3 on verra plus tard { $this->type_presta = $value; return $this; - } + }*/ public function setModePaiement(string $value) { $this->mode_paiement = $value; @@ -153,7 +154,7 @@ class Prestation //$input->typeToClient(); // on modifie $client ici (merci les références PHP) } - public function set(string $entry, string $input): void + /*public function set(string $entry, string $input): void { $input = $this->cleanSpecialChars($input); // possibilité que $input devienne une chaine vide @@ -176,7 +177,7 @@ class Prestation $this->setCommentaires($input); break; } - } + }*/ // code presta = année-mois-jour-codeclient-typedepresta-combientièmefois public function setCodePresta(int $increment): Prestation // 0 pour modif, 1 pour nouvelle presta @@ -191,7 +192,7 @@ class Prestation $date_array[1], // mois $date_array[2], // jour $this->client->getCodeClient(), // mise à jour éventuelle - $this->type_presta, + //$this->type_presta, $how_many_times ]; $this->code_presta = implode('-', $array_code); @@ -222,7 +223,7 @@ class Prestation $find_by = ['client' => $Customer->getId()]; if($type != '') { - $find_by['type_presta'] = 'devis'; + //$find_by['type_presta'] = 'devis'; } $PrestaList = $repository->findBy($find_by); -- cgit v1.2.3