From 010702f67d2560d6435c4e7f39fe7a567aac080b Mon Sep 17 00:00:00 2001 From: polo Date: Wed, 9 Jul 2025 00:54:15 +0200 Subject: =?UTF-8?q?mieux=20comme=20=C3=A7a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/livre_recettes.php | 66 ++++++++++++++++++++++++++++++++++++++++++ src/model/entities/Facture.php | 8 +++++ 2 files changed, 74 insertions(+) create mode 100755 bin/livre_recettes.php diff --git a/bin/livre_recettes.php b/bin/livre_recettes.php new file mode 100755 index 0000000..28c08a1 --- /dev/null +++ b/bin/livre_recettes.php @@ -0,0 +1,66 @@ +#!/usr/bin/env php + bin/livre_recettes.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/Config.php'); // lit le config.ini et gère certaines erreurs (exemple les / aux chemins manquants) +Config::readFile('config/config.ini'); +Config::hydrate(); + +// créer les dossiers si nécéssaire +makeFolder(Config::$db_path); +makeFolder(Config::$latex_path); +makeFolder(Config::$pdf_path); + +//require 'src/model/doctrine-bootstrap.php'; +require __DIR__ . '/../src/model/doctrine-bootstrap.php'; // chemin absolu + +// requête +$date_debut = '2024-01-01'; +$date_fin = '2024-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); + +$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()) + ->getResult(); + +// affichage +echo "client|date|type|mode paiement|débours|total HT|salaire CESU|code presta\n"; + +foreach($bulk_data as $presta){ + if($presta->getTypePresta() !== 'devis'){ + $date = new DateTime()->setTimestamp($presta->getDate()); + + echo $presta->getClient()->getPrenomNom() . '|' + . $date->format('d/m/Y') . '|' + . $presta->getTypePresta() . '|' + . $presta->getModePaiement() . '|'; + + if($presta->getTypePresta() === 'facture'){ + echo $presta->getFacture()->getTotalPieces() . '|'; + echo $presta->getFacture()->getTotalHT() . '||'; + } + elseif($presta->getTypePresta() === 'cesu'){ + echo '||' . $presta->getCESU()->getSalaire() . '|'; + } + elseif($presta->getTypePresta() === 'location'){ + echo '|' . (string)($presta->getLocation()->getLoyer() * (float)$presta->getLocation()->getLoyersPayes()) . '||'; + } + + echo $presta->getCodePresta(); + echo "\n"; + } +} diff --git a/src/model/entities/Facture.php b/src/model/entities/Facture.php index 75d1a6e..2eea0e5 100644 --- a/src/model/entities/Facture.php +++ b/src/model/entities/Facture.php @@ -65,6 +65,14 @@ class Facture { return $this->total_main_d_oeuvre; } + public function getTotalPieces(): float + { + return $this->total_pieces; + } + public function getTotalHT(): float + { + return $this->total_HT; + } public function getAllWithWindowFields(): array { -- cgit v1.2.3