diff options
| -rwxr-xr-x | bin/doctrine | 2 | ||||
| -rw-r--r-- | src/model/doctrine-bootstrap.php | 7 | ||||
| -rw-r--r-- | src/model/entities/CESU.php | 14 | ||||
| -rw-r--r-- | src/model/entities/Devis.php | 14 | ||||
| -rw-r--r-- | src/model/entities/Facture.php | 14 | ||||
| -rw-r--r-- | src/model/entities/Location.php | 14 | ||||
| -rw-r--r-- | src/model/entities/NonVendue.php | 12 | ||||
| -rw-r--r-- | src/model/entities/Prestation.php | 45 |
8 files changed, 40 insertions, 82 deletions
diff --git a/bin/doctrine b/bin/doctrine index 50d5b78..2a2eab5 100755 --- a/bin/doctrine +++ b/bin/doctrine | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | // chemins des dossiers et nom de la base | 6 | // chemins des dossiers et nom de la base |
| 7 | require('src/File.php'); | 7 | require('src/File.php'); |
| 8 | require('src/Config.php'); // lit le config.ini et gère certaines erreurs (exemple les / aux chemins manquants) | 8 | require('src/Config.php'); |
| 9 | Config::readFile('config/config.ini'); | 9 | Config::readFile('config/config.ini'); |
| 10 | Config::hydrate(); | 10 | Config::hydrate(); |
| 11 | 11 | ||
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"; | |||
| 9 | 9 | ||
| 10 | // Create a simple "default" Doctrine ORM configuration for Attributes | 10 | // Create a simple "default" Doctrine ORM configuration for Attributes |
| 11 | $config = ORMSetup::createAttributeMetadataConfiguration( | 11 | $config = ORMSetup::createAttributeMetadataConfiguration( |
| 12 | //paths: array(__DIR__.'/entities'), | ||
| 13 | paths: array('src/model/entities'), | 12 | paths: array('src/model/entities'), |
| 14 | isDevMode: true, | 13 | isDevMode: true, |
| 15 | ); | 14 | ); |
| 16 | // or if you prefer XML | ||
| 17 | // $config = ORMSetup::createXMLMetadataConfiguration( | ||
| 18 | // paths: array(__DIR__."/config/xml"), | ||
| 19 | // isDevMode: true, | ||
| 20 | //); | ||
| 21 | 15 | ||
| 22 | // configuring the database connection | 16 | // configuring the database connection |
| 23 | $connection = DriverManager::getConnection([ | 17 | $connection = DriverManager::getConnection([ |
| 24 | 'driver' => 'pdo_sqlite', | 18 | 'driver' => 'pdo_sqlite', |
| 25 | //'path' => __DIR__ . '/../../data/' . Config::$db_name . '.sqlite', | ||
| 26 | 'path' => 'data/' . Config::$db_name . '.sqlite', | 19 | 'path' => 'data/' . Config::$db_name . '.sqlite', |
| 27 | ], $config); | 20 | ], $config); |
| 28 | 21 | ||
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; | |||
| 6 | 6 | ||
| 7 | #[ORM\Entity] | 7 | #[ORM\Entity] |
| 8 | #[ORM\Table(name: 'cesu')] | 8 | #[ORM\Table(name: 'cesu')] |
| 9 | class CESU | 9 | class CESU extends Prestation |
| 10 | { | 10 | { |
| 11 | #[ORM\Id] | ||
| 12 | #[ORM\Column(type: 'integer')] | ||
| 13 | #[ORM\GeneratedValue] | ||
| 14 | private int|null $id = null; | ||
| 15 | |||
| 16 | //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] | ||
| 17 | //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
| 18 | //~ private Prestation|null $presta = null; | ||
| 19 | #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'cesu', cascade: ['persist'])] | ||
| 20 | #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
| 21 | private ?Prestation $presta = null; | ||
| 22 | |||
| 23 | #[ORM\Column] | 11 | #[ORM\Column] |
| 24 | private string $taches; | 12 | private string $taches; |
| 25 | #[ORM\Column] | 13 | #[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; | |||
| 6 | 6 | ||
| 7 | #[ORM\Entity] | 7 | #[ORM\Entity] |
| 8 | #[ORM\Table(name: 'devis')] | 8 | #[ORM\Table(name: 'devis')] |
| 9 | class Devis | 9 | class Devis extends Prestation |
| 10 | { | 10 | { |
| 11 | #[ORM\Id] | ||
| 12 | #[ORM\Column(type: 'integer')] | ||
| 13 | #[ORM\GeneratedValue] | ||
| 14 | private int|null $id = null; | ||
| 15 | |||
| 16 | //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] | ||
| 17 | //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
| 18 | //~ private Prestation|null $presta = null; | ||
| 19 | #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'devis', cascade: ['persist'])] | ||
| 20 | #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
| 21 | private ?Prestation $presta = null; | ||
| 22 | |||
| 23 | #[ORM\Column] | 11 | #[ORM\Column] |
| 24 | private string $taches; | 12 | private string $taches; |
| 25 | #[ORM\Column] | 13 | #[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; | |||
| 6 | 6 | ||
| 7 | #[ORM\Entity] | 7 | #[ORM\Entity] |
| 8 | #[ORM\Table(name: 'factures')] | 8 | #[ORM\Table(name: 'factures')] |
| 9 | class Facture | 9 | class Facture extends Prestation |
| 10 | { | 10 | { |
| 11 | #[ORM\Id] | ||
| 12 | #[ORM\Column(type: 'integer')] | ||
| 13 | #[ORM\GeneratedValue] | ||
| 14 | private int|null $id = null; | ||
| 15 | |||
| 16 | //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] | ||
| 17 | //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
| 18 | //~ private Prestation|null $presta = null; | ||
| 19 | #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'facture', cascade: ['persist'])] | ||
| 20 | #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
| 21 | private ?Prestation $presta = null; | ||
| 22 | |||
| 23 | #[ORM\Column] | 11 | #[ORM\Column] |
| 24 | private string $taches; | 12 | private string $taches; |
| 25 | #[ORM\Column] | 13 | #[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; | |||
| 6 | 6 | ||
| 7 | #[ORM\Entity] | 7 | #[ORM\Entity] |
| 8 | #[ORM\Table(name: 'locations')] | 8 | #[ORM\Table(name: 'locations')] |
| 9 | class Location | 9 | class Location extends Prestation |
| 10 | { | 10 | { |
| 11 | #[ORM\Id] | ||
| 12 | #[ORM\Column(type: 'integer')] | ||
| 13 | #[ORM\GeneratedValue] | ||
| 14 | private int|null $id = null; | ||
| 15 | |||
| 16 | //~ #[ORM\ManyToOne(targetEntity: Prestation::class, cascade: ['persist'])] | ||
| 17 | //~ #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
| 18 | //~ private Prestation|null $presta = null; | ||
| 19 | #[ORM\OneToOne(targetEntity: Prestation::class, inversedBy: 'location', cascade: ['persist'])] | ||
| 20 | #[ORM\JoinColumn(name: 'id_presta', referencedColumnName: 'id')] | ||
| 21 | private ?Prestation $presta = null; | ||
| 22 | |||
| 23 | #[ORM\Column] | 11 | #[ORM\Column] |
| 24 | protected string $designation; | 12 | protected string $designation; |
| 25 | #[ORM\Column] | 13 | #[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 @@ | |||
| 1 | <?php | ||
| 2 | // src/entities/NonVendue.php | ||
| 3 | |||
| 4 | use Doctrine\ORM\Mapping as ORM; | ||
| 5 | |||
| 6 | #[ORM\Entity] | ||
| 7 | #[ORM\Table(name: 'non_vendues')] | ||
| 8 | class NonVendue extends Prestation | ||
| 9 | { | ||
| 10 | #[ORM\Column] | ||
| 11 | private string $taches; | ||
| 12 | } \ No newline at end of file | ||
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 | |||
| 4 | use Doctrine\ORM\Mapping as ORM; | 8 | use Doctrine\ORM\Mapping as ORM; |
| 5 | use Doctrine\ORM\EntityManager; | 9 | use Doctrine\ORM\EntityManager; |
| 6 | 10 | ||
| 7 | #[ORM\Entity] | 11 | #[ORM\Entity] |
| 8 | #[ORM\Table(name: 'prestations')] | 12 | #[ORM\Table(name: 'prestations')] |
| 9 | class 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 | ])] | ||
| 22 | abstract 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 | ||
