diff options
| author | polo <ordipolo@gmx.fr> | 2026-10-21 16:18:35 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-10-21 16:18:35 +0200 |
| commit | 26fbb91d0047e901afffbc6e21e7767d546fec9b (patch) | |
| tree | 5712b2b60d4d5dce9931b21578c4ba55cf231504 /src/functions.php | |
| parent | 30b3819db6742a1851ca8af8b9763cbd17bffeca (diff) | |
| download | AppliGestionPHP-master.tar.gz AppliGestionPHP-master.tar.bz2 AppliGestionPHP-master.zip | |
Diffstat (limited to 'src/functions.php')
| -rw-r--r-- | src/functions.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/functions.php b/src/functions.php index d9fbfca..6042eaf 100644 --- a/src/functions.php +++ b/src/functions.php | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/functions.php | 2 | // src/functions.php |
| 3 | 3 | ||
| 4 | use Doctrine\ORM\EntityManager; | ||
| 4 | 5 | ||
| 5 | // commande pour lancer une application graphique en ouvrant un fichier | 6 | // commande pour lancer une application graphique en ouvrant un fichier |
| 6 | function windowAppCommand(string $app, string $path = ''): string | 7 | function windowAppCommand(string $app, string $path = ''): string |
| @@ -18,3 +19,49 @@ function windowAppCommand(string $app, string $path = ''): string | |||
| 18 | // stderr > stdout pour cacher un message inutile | 19 | // stderr > stdout pour cacher un message inutile |
| 19 | return $command; | 20 | return $command; |
| 20 | } | 21 | } |
| 22 | |||
| 23 | // appelée par bin/livre_recettes.php | ||
| 24 | function makeRecipeBook(EntityManager $entityManager, array $years): void | ||
| 25 | { | ||
| 26 | foreach($years as $year){ | ||
| 27 | /*$date_debut = $year . '-01-01'; | ||
| 28 | $date_fin = $year . '-12-31'; | ||
| 29 | |||
| 30 | $debut = new DateTime($date_debut, new DateTimeZone('Europe/Paris')); | ||
| 31 | $fin = new DateTime($date_fin, new DateTimeZone('Europe/Paris'));; | ||
| 32 | $fin->setTime(23, 59, 59);*/ | ||
| 33 | |||
| 34 | $dql = 'SELECT n FROM Prestation n WHERE n.date >= :debut AND n.date <= :fin'; | ||
| 35 | $bulk_data = $entityManager | ||
| 36 | ->createQuery($dql) | ||
| 37 | ->setParameter('debut', $year . '-01-01') | ||
| 38 | ->setParameter('fin', $year . '-12-31') | ||
| 39 | ->getResult(); | ||
| 40 | |||
| 41 | // affichage | ||
| 42 | $result = "client|date|type|mode paiement|débours|total HT|salaire CESU|code presta\n"; | ||
| 43 | |||
| 44 | foreach($bulk_data as $presta){ | ||
| 45 | if($presta->getTypePresta() !== 'devis' && $presta->getTypePresta() !== 'non_vendue'){ | ||
| 46 | $result .= $presta->getClient()->getPrenomNom() . '|' | ||
| 47 | . $presta->getDate() . '|' | ||
| 48 | . $presta->getTypePresta() . '|' | ||
| 49 | . $presta->getModePaiement() . '|'; | ||
| 50 | |||
| 51 | if($presta->getTypePresta() === 'facture'){ | ||
| 52 | $result .= $presta->getTotalPieces() . '|'; | ||
| 53 | $result .= $presta->getTotalHT() . '||'; | ||
| 54 | } | ||
| 55 | elseif($presta->getTypePresta() === 'cesu'){ | ||
| 56 | $result .= '||' . $presta->getSalaire() . '|'; | ||
| 57 | } | ||
| 58 | elseif($presta->getTypePresta() === 'location'){ | ||
| 59 | $result .= '|' . (string)($presta->getLoyer() * (float)$presta->getLoyersPayes()) . '||'; | ||
| 60 | } | ||
| 61 | $result .= $presta->getCodePresta() . "\n"; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | file_put_contents('data/livre_recettes_' . $year . '.csv', $result); // sortie fichier | ||
| 65 | echo $result . "\n"; // sortie console | ||
| 66 | } | ||
| 67 | } \ No newline at end of file | ||
