add produits devis into export thanato , WIP file name

This commit is contained in:
Tiavina 2024-12-28 22:03:48 +03:00
parent 1ed2ded93b
commit 881546f4bf
3 changed files with 81 additions and 5 deletions

View File

@ -359,9 +359,8 @@ class Bdd {
} }
public function getProduits($idNextcloud){ public function getProduits($idNextcloud){
// $sql = "SELECT * FROM ".$this->tableprefix."produit WHERE id_nextcloud = ?"; $sql = "SELECT * FROM ".$this->tableprefix."produit
$sql = "SELECT * FROM ".$this->tableprefix."produit"; WHERE $this->tableprefix.produit.id";
// return $this->execSQL($sql, array($idNextcloud));
return $this->execSQL($sql, array()); return $this->execSQL($sql, array());
} }
@ -1754,11 +1753,30 @@ class Bdd {
return $devisListGroupedByDateAndThenByThanato; 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){ private function getDevisListGroupedByDateAndThenByThanato(array $devisList){
$devisListGroupedByDateAndThenByThanato = []; $devisListGroupedByDateAndThenByThanato = [];
foreach($devisList as $devis){ foreach($devisList as $devis){
$devisDate = $devis["date"]; $devisDate = $devis["date"];
$devisThanatoId = $devis["id_thanato"]; $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])) { if (!isset($devisListGroupedByDateAndThenByThanato[$devisThanatoId])) {
$devisListGroupedByDateAndThenByThanato[$devisThanatoId] = []; $devisListGroupedByDateAndThenByThanato[$devisThanatoId] = [];
} }
@ -1769,14 +1787,23 @@ class Bdd {
"devisId" => [] "devisId" => []
]; ];
} }
$devis = $this->setDevisStartAndEndTime($devis);
$devis = $this->setDevisIsWeekendOrNotText($devis);
$devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devis"][] = $devis; $devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devis"][] = $devis;
$devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devisId"][] = $devis['id']; $devisListGroupedByDateAndThenByThanato[$devisThanatoId][$devisDate]["devisId"][] = $devis['id'];
} }
return $devisListGroupedByDateAndThenByThanato; 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){ private function setDevisIsWeekendOrNotText($devis){
$isWeekend = DateHelpers::isWeekend($devis['date']); $isWeekend = DateHelpers::isWeekend($devis['date']);
$value = $isWeekend ? "Ferie" : "J"; $value = $isWeekend ? "Ferie" : "J";

View File

@ -49,6 +49,7 @@ class ExportThanatoStatisticService {
'Date'.';'. 'Date'.';'.
'Heure Debut'.';'. 'Heure Debut'.';'.
'Heure Fin'.';'. 'Heure Fin'.';'.
'Soins'.';'.
utf8_decode(html_entity_decode('Jour/Ferie')).';'. utf8_decode(html_entity_decode('Jour/Ferie')).';'.
utf8_decode(html_entity_decode('Nom et Prénom')).';'. utf8_decode(html_entity_decode('Nom et Prénom')).';'.
'Lieu'.';'. 'Lieu'.';'.
@ -86,16 +87,29 @@ class ExportThanatoStatisticService {
''.';'. ''.';'.
''.';'. ''.';'.
''.';'. ''.';'.
''.';'.
utf8_decode(html_entity_decode("$distance"))."\n"; utf8_decode(html_entity_decode("$distance"))."\n";
return $fileContent; 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){ private function populateDevisDataIntoThanatoExportFileContent(string $fileContent,array $devis){
$produitAsString = $this->getFormatDevisProduitsAsString($devis["produits"]);
$fileContent = $fileContent. $fileContent = $fileContent.
utf8_decode(html_entity_decode($devis['nom_thanato'] . ' ' . $devis['prenom_thanatho'])).';'. utf8_decode(html_entity_decode($devis['nom_thanato'] . ' ' . $devis['prenom_thanatho'])).';'.
utf8_decode(html_entity_decode($devis["date"])).';'. utf8_decode(html_entity_decode($devis["date"])).';'.
utf8_decode(html_entity_decode($devis["startTime"])).';'. utf8_decode(html_entity_decode($devis["startTime"])).';'.
utf8_decode(html_entity_decode($devis["endTime"])).';'. 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["dayType"])).';'.
utf8_decode(html_entity_decode($devis["nom_defunt"])).';'. utf8_decode(html_entity_decode($devis["nom_defunt"])).';'.
utf8_decode(html_entity_decode($devis["nom_lieu"] ?? "")).';'. utf8_decode(html_entity_decode($devis["nom_lieu"] ?? "")).';'.

View File

@ -654,6 +654,17 @@
"node": ">= 8" "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": { "node_modules/@skjnldsv/sanitize-svg": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/@skjnldsv/sanitize-svg/-/sanitize-svg-1.0.2.tgz", "resolved": "https://registry.npmjs.org/@skjnldsv/sanitize-svg/-/sanitize-svg-1.0.2.tgz",
@ -2520,6 +2531,13 @@
"node": ">=8.0.0" "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": { "node_modules/iconv-lite": {
"version": "0.6.3", "version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
@ -3011,6 +3029,13 @@
"linkifyjs": "^4.0.0" "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": { "node_modules/loader-runner": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz",
@ -4540,6 +4565,16 @@
"base64-arraybuffer": "^1.0.2" "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": { "node_modules/v-click-outside": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/v-click-outside/-/v-click-outside-3.2.0.tgz", "resolved": "https://registry.npmjs.org/v-click-outside/-/v-click-outside-3.2.0.tgz",