forked from Sid-Ahmed7/Projet_IW4
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_test_data.php
More file actions
48 lines (36 loc) · 1.33 KB
/
Copy pathcreate_test_data.php
File metadata and controls
48 lines (36 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require '/var/www/symfony/vendor/autoload.php';
use Symfony\Component\Dotenv\Dotenv;
(new Dotenv())->bootEnv('/var/www/symfony/.env');
$kernel = new \App\Kernel('dev', true);
$kernel->boot();
$container = $kernel->getContainer();
$em = $container->get('doctrine')->getManager();
// Créer un devis pour l'entreprise ESGI (ID: 1) et l'utilisateur company (ID: 3)
$devis = new \App\Entity\Devis();
$devis->setTitle('Séminaire Entreprise');
$devis->setContent('Organisation du séminaire annuel de l\'entreprise');
$devis->setPrice('15000.00');
$devis->setState('En attente');
$devis->setIsNegotiable(false);
$devis->setCreatedAt(new \DateTimeImmutable());
// Récupérer les entités
$company = $em->getRepository(\App\Entity\Company::class)->find(1);
$user = $em->getRepository(\App\Entity\User::class)->find(3);
$devis->setCompany($company);
$devis->setHubuser($user);
$em->persist($devis);
$em->flush();
echo "Devis créé avec succès!\n";
// Créer une facture pour tester
$invoice = new \App\Entity\Invoice();
$invoice->setNumber('202508-TEST-' . uniqid());
$invoice->setAmount(15000);
$invoice->setStatus('pending');
$invoice->setCreatedAt(new \DateTimeImmutable());
$invoice->setCompany($company);
$invoice->setHubuser($user);
$invoice->setDevis($devis);
$em->persist($invoice);
$em->flush();
echo "Facture créée avec succès!\n";