diff --git a/gestion/lib/Db/Bdd.php b/gestion/lib/Db/Bdd.php index 1af1f8f..a20a230 100644 --- a/gestion/lib/Db/Bdd.php +++ b/gestion/lib/Db/Bdd.php @@ -359,9 +359,8 @@ class Bdd { } public function getProduits($idNextcloud){ - // $sql = "SELECT * FROM ".$this->tableprefix."produit WHERE id_nextcloud = ?"; - $sql = "SELECT * FROM ".$this->tableprefix."produit"; - // return $this->execSQL($sql, array($idNextcloud)); + $sql = "SELECT * FROM ".$this->tableprefix."produit + WHERE $this->tableprefix.produit.id"; return $this->execSQL($sql, array()); } @@ -1754,11 +1753,30 @@ class Bdd { return $devisListGroupedByDateAndThenByThanato; } + public function getProduitsDevisByDevisId($devisId){ + $sql = "SELECT + produit_devis.id as produit_devis_id, + produit.id as produit_id, + produit.reference as produit_reference, + produit.description as produit_description + FROM ".$this->tableprefix."produit_devis as produit_devis + LEFT JOIN ".$this->tableprefix."produit as produit on produit_devis.produit_id = produit.id + WHERE produit_devis.devis_id = ?;"; + $produitsList = $this->execSQLNoJsonReturn( + $sql, + [$devisId]); + return $produitsList; + } + private function getDevisListGroupedByDateAndThenByThanato(array $devisList){ $devisListGroupedByDateAndThenByThanato = []; foreach($devisList as $devis){ $devisDate = $devis["date"]; $devisThanatoId = $devis["id_thanato"]; + $devis = $this->setDevisStartAndEndTime($devis); + $devis = $this->setDevisIsWeekendOrNotText($devis); + $devis = $this->setDevisProduitsList($devis); + //set devis articles list into devis data if (!isset($devisListGroupedByDateAndThenByThanato[$devisThanatoId])) { $devisListGroupedByDateAndThenByThanato[$devisThanatoId] = []; } @@ -1769,14 +1787,23 @@ class Bdd { "devisId" => [] ]; } - $devis = $this->setDevisStartAndEndTime($devis); - $devis = $this->setDevisIsWeekendOrNotText($devis); $devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devis"][] = $devis; $devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devisId"][] = $devis['id']; } return $devisListGroupedByDateAndThenByThanato; } + private function setDevisProduitsList($devis){ + $produitsList = $this->getProduitsDevisByDevisId($devis['id']); + foreach($produitsList as $produit){ + if (!isset($devis['produits'])) { + $devis['produits'] = []; + } + $devis['produits'][] = $produit; + } + return $devis; + } + private function setDevisIsWeekendOrNotText($devis){ $isWeekend = DateHelpers::isWeekend($devis['date']); $value = $isWeekend ? "Ferie" : "J"; diff --git a/gestion/lib/Service/ExportThanatoStatisticService.php b/gestion/lib/Service/ExportThanatoStatisticService.php index 18032b5..b3f6b67 100644 --- a/gestion/lib/Service/ExportThanatoStatisticService.php +++ b/gestion/lib/Service/ExportThanatoStatisticService.php @@ -49,6 +49,7 @@ class ExportThanatoStatisticService { 'Date'.';'. 'Heure Debut'.';'. 'Heure Fin'.';'. + 'Soins'.';'. utf8_decode(html_entity_decode('Jour/Ferie')).';'. utf8_decode(html_entity_decode('Nom et Prénom')).';'. 'Lieu'.';'. @@ -86,16 +87,29 @@ class ExportThanatoStatisticService { ''.';'. ''.';'. ''.';'. + ''.';'. utf8_decode(html_entity_decode("$distance"))."\n"; return $fileContent; } + private function getFormatDevisProduitsAsString($devisProduits){ + $result = ''; + foreach ($devisProduits as $produit) { + $result .= $produit['produit_reference'] . '-' . $produit['produit_description'] . '--'; + } + // Remove the trailing "--" at the end + $result = rtrim($result, '-'); + return $result; + } + private function populateDevisDataIntoThanatoExportFileContent(string $fileContent,array $devis){ + $produitAsString = $this->getFormatDevisProduitsAsString($devis["produits"]); $fileContent = $fileContent. utf8_decode(html_entity_decode($devis['nom_thanato'] . ' ' . $devis['prenom_thanatho'])).';'. utf8_decode(html_entity_decode($devis["date"])).';'. utf8_decode(html_entity_decode($devis["startTime"])).';'. utf8_decode(html_entity_decode($devis["endTime"])).';'. + utf8_decode(html_entity_decode($produitAsString)).';'. utf8_decode(html_entity_decode($devis["dayType"])).';'. utf8_decode(html_entity_decode($devis["nom_defunt"])).';'. utf8_decode(html_entity_decode($devis["nom_lieu"] ?? "")).';'. diff --git a/gestion/package-lock.json b/gestion/package-lock.json index ad64cd2..c9254a0 100644 --- a/gestion/package-lock.json +++ b/gestion/package-lock.json @@ -654,6 +654,17 @@ "node": ">= 8" } }, + "node_modules/@popperjs/core": { + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", + "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", + "dev": true, + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/@skjnldsv/sanitize-svg": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@skjnldsv/sanitize-svg/-/sanitize-svg-1.0.2.tgz", @@ -2520,6 +2531,13 @@ "node": ">=8.0.0" } }, + "node_modules/ical.js": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/ical.js/-/ical.js-1.5.0.tgz", + "integrity": "sha512-7ZxMkogUkkaCx810yp0ZGKvq1ZpRgJeornPttpoxe6nYZ3NLesZe1wWMXDdwTkj/b5NtXT+Y16Aakph/ao98ZQ==", + "dev": true, + "peer": true + }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", @@ -3011,6 +3029,13 @@ "linkifyjs": "^4.0.0" } }, + "node_modules/linkifyjs": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.2.0.tgz", + "integrity": "sha512-pCj3PrQyATaoTYKHrgWRF3SJwsm61udVh+vuls/Rl6SptiDhgE7ziUIudAedRY9QEfynmM7/RmLEfPUyw1HPCw==", + "dev": true, + "peer": true + }, "node_modules/loader-runner": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", @@ -4540,6 +4565,16 @@ "base64-arraybuffer": "^1.0.2" } }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "peer": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/v-click-outside": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/v-click-outside/-/v-click-outside-3.2.0.tgz",