From d76eace8bdc50e208d9754ff50acb58525887048 Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 18 Oct 2026 22:48:47 +0200 Subject: oublis MAJ fichiers dans bin --- bin/livre_recettes.php | 52 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'bin/livre_recettes.php') diff --git a/bin/livre_recettes.php b/bin/livre_recettes.php index 54418a4..656aef6 100755 --- a/bin/livre_recettes.php +++ b/bin/livre_recettes.php @@ -2,14 +2,17 @@ bin/livre_recettes.csv +// commande pour l'obtenir (aucun paramètre = année en cours): +// php bin/livre_recettes.php +// php bin/livre_recettes.php 2026 +// php bin/livre_recettes.php 2024 2025 2026 // +// fichier CSV créé dans data/livre_recettes_année.csv // en ouvrant le CSV, choisir le pipe | comme séparateur // chemins des dossiers et nom de la base -require('src/files.php'); +require('src/File.php'); require('src/Config.php'); // lit le config.ini et gère certaines erreurs (exemple les / aux chemins manquants) Config::readFile('config/config.ini'); Config::hydrate(); @@ -50,18 +53,18 @@ catch(Exception $e){ // requête foreach($years as $year){ - $date_debut = $year . '-01-01'; + /*$date_debut = $year . '-01-01'; $date_fin = $year . '-12-31'; $debut = new DateTime($date_debut, new DateTimeZone('Europe/Paris')); $fin = new DateTime($date_fin, new DateTimeZone('Europe/Paris'));; - $fin->setTime(23, 59, 59); + $fin->setTime(23, 59, 59);*/ $dql = 'SELECT n FROM Prestation n WHERE n.date >= :debut AND n.date <= :fin'; $bulk_data = $entityManager ->createQuery($dql) - ->setParameter('debut', $debut->getTimestamp()) - ->setParameter('fin', $fin->getTimestamp()) + ->setParameter('debut', $year . '-01-01') + ->setParameter('fin', $year . '-12-31') ->getResult(); // affichage @@ -69,25 +72,22 @@ foreach($years as $year){ foreach($bulk_data as $presta){ if($presta->getTypePresta() !== 'devis' && $presta->getTypePresta() !== 'non_vendue'){ - $date = new DateTime()->setTimestamp($presta->getDate()); - - $result .= $presta->getClient()->getPrenomNom() . '|' - . $date->format('d/m/Y') . '|' - . $presta->getTypePresta() . '|' - . $presta->getModePaiement() . '|'; - - if($presta->getTypePresta() === 'facture'){ - $result .= $presta->getFacture()->getTotalPieces() . '|'; - $result .= $presta->getFacture()->getTotalHT() . '||'; - } - elseif($presta->getTypePresta() === 'cesu'){ - $result .= '||' . $presta->getCESU()->getSalaire() . '|'; - } - elseif($presta->getTypePresta() === 'location'){ - $result .= '|' . (string)($presta->getLocation()->getLoyer() * (float)$presta->getLocation()->getLoyersPayes()) . '||'; - } - - $result .= $presta->getCodePresta() . "\n"; + $result .= $presta->getClient()->getPrenomNom() . '|' + . $presta->getDate() . '|' + . $presta->getTypePresta() . '|' + . $presta->getModePaiement() . '|'; + + if($presta->getTypePresta() === 'facture'){ + $result .= $presta->getFacture()->getTotalPieces() . '|'; + $result .= $presta->getFacture()->getTotalHT() . '||'; + } + elseif($presta->getTypePresta() === 'cesu'){ + $result .= '||' . $presta->getCESU()->getSalaire() . '|'; + } + elseif($presta->getTypePresta() === 'location'){ + $result .= '|' . (string)($presta->getLocation()->getLoyer() * (float)$presta->getLocation()->getLoyersPayes()) . '||'; + } + $result .= $presta->getCodePresta() . "\n"; } } file_put_contents('data/livre_recettes_' . $year . '.csv', $result); // sortie fichier -- cgit v1.2.3